From: <lu...@us...> - 2009-11-22 16:56:48
|
Revision: 357 http://pyscard.svn.sourceforge.net/pyscard/?rev=357&view=rev Author: ludov Date: 2009-11-22 16:56:41 +0000 (Sun, 22 Nov 2009) Log Message: ----------- pep8: E701 multiple statements on one line (colon) Modified Paths: -------------- trunk/pyscard/src/smartcard/ATR.py trunk/pyscard/src/smartcard/CardMonitoring.py trunk/pyscard/src/smartcard/CardNames.py trunk/pyscard/src/smartcard/ExclusiveConnectCardConnection.py trunk/pyscard/src/smartcard/Observer.py trunk/pyscard/src/smartcard/ReaderMonitoring.py trunk/pyscard/src/smartcard/Synchronization.py trunk/pyscard/src/smartcard/pcsc/PCSCCardConnection.py trunk/pyscard/src/smartcard/pcsc/PCSCCardRequest.py trunk/pyscard/src/smartcard/pcsc/PCSCReader.py trunk/pyscard/src/smartcard/test/framework/testcase_ErrorChecking.py trunk/pyscard/src/smartcard/test/framework/testcase_readermonitorstress.py trunk/pyscard/src/smartcard/test/manual/testcase_manualCardRequest.py Modified: trunk/pyscard/src/smartcard/ATR.py =================================================================== --- trunk/pyscard/src/smartcard/ATR.py 2009-11-22 16:47:03 UTC (rev 356) +++ trunk/pyscard/src/smartcard/ATR.py 2009-11-22 16:56:41 UTC (rev 357) @@ -94,10 +94,14 @@ self.TC += [None] self.TD += [None] - if self.hasTA[n]: self.TA[n]=self.bytes[ offset+self.hasTA[n] ] - if self.hasTB[n]: self.TB[n]=self.bytes[ offset+self.hasTA[n]+self.hasTB[n] ] - if self.hasTC[n]: self.TC[n]=self.bytes[ offset+self.hasTA[n]+self.hasTB[n]+self.hasTC[n] ] - if self.hasTD[n]: self.TD[n]=self.bytes[ offset+self.hasTA[n]+self.hasTB[n]+self.hasTC[n]+self.hasTD[n] ] + if self.hasTA[n]: + self.TA[n]=self.bytes[ offset+self.hasTA[n] ] + if self.hasTB[n]: + self.TB[n]=self.bytes[ offset+self.hasTA[n]+self.hasTB[n] ] + if self.hasTC[n]: + self.TC[n]=self.bytes[ offset+self.hasTA[n]+self.hasTB[n]+self.hasTC[n] ] + if self.hasTD[n]: + self.TD[n]=self.bytes[ offset+self.hasTA[n]+self.hasTB[n]+self.hasTC[n]+self.hasTD[n] ] self.interfaceBytesCount += self.hasTA[n]+self.hasTB[n]+self.hasTC[n]+self.hasTD[n] TD=self.TD[n] @@ -241,10 +245,14 @@ """Dump the details of an ATR.""" for i in range( 0, len(self.TA) ): - if self.TA[i]!=None: print "TA%d: %x" % (i+1,self.TA[i]) - if self.TB[i]!=None: print "TB%d: %x" % (i+1,self.TB[i]) - if self.TC[i]!=None: print "TC%d: %x" % (i+1,self.TC[i]) - if self.TD[i]!=None: print "TD%d: %x" % (i+1,self.TD[i]) + if self.TA[i]!=None: + print "TA%d: %x" % (i+1,self.TA[i]) + if self.TB[i]!=None: + print "TB%d: %x" % (i+1,self.TB[i]) + if self.TC[i]!=None: + print "TC%d: %x" % (i+1,self.TC[i]) + if self.TD[i]!=None: + print "TD%d: %x" % (i+1,self.TD[i]) print 'supported protocols', self.getSupportedProtocols() print 'T=0 supported', self.isT0Supported() Modified: trunk/pyscard/src/smartcard/CardMonitoring.py =================================================================== --- trunk/pyscard/src/smartcard/CardMonitoring.py 2009-11-22 16:47:03 UTC (rev 356) +++ trunk/pyscard/src/smartcard/CardMonitoring.py 2009-11-22 16:56:41 UTC (rev 357) @@ -174,8 +174,10 @@ # by the __del__() method may already have been deleted. # this causes ReaderMonitoringThread.run() to except with a TypeError # or AttributeError - except TypeError: pass - except AttributeError: pass + except TypeError: + pass + except AttributeError: + pass except: try: Modified: trunk/pyscard/src/smartcard/CardNames.py =================================================================== --- trunk/pyscard/src/smartcard/CardNames.py 2009-11-22 16:47:03 UTC (rev 356) +++ trunk/pyscard/src/smartcard/CardNames.py 2009-11-22 16:56:41 UTC (rev 357) @@ -67,7 +67,8 @@ def find( self, atr, reader=None ): for k,v in self.db.iteritems(): - if loads(v).matches( atr, reader ): return k + if loads(v).matches( atr, reader ): + return k synchronize( __CardNames__, "add delete dump find" ) Modified: trunk/pyscard/src/smartcard/ExclusiveConnectCardConnection.py =================================================================== --- trunk/pyscard/src/smartcard/ExclusiveConnectCardConnection.py 2009-11-22 16:47:03 UTC (rev 356) +++ trunk/pyscard/src/smartcard/ExclusiveConnectCardConnection.py 2009-11-22 16:56:41 UTC (rev 357) @@ -42,7 +42,8 @@ while True: if isinstance( component, smartcard.pcsc.PCSCCardConnection.PCSCCardConnection ): pcscprotocol = PCSCCardConnection.translateprotocolmask( protocol ) - if 0==pcscprotocol: pcscprotocol = component.getProtocol() + if 0==pcscprotocol: + pcscprotocol = component.getProtocol() if None!=component.hcard: hresult = SCardDisconnect( component.hcard, SCARD_LEAVE_CARD ) Modified: trunk/pyscard/src/smartcard/Observer.py =================================================================== --- trunk/pyscard/src/smartcard/Observer.py 2009-11-22 16:47:03 UTC (rev 356) +++ trunk/pyscard/src/smartcard/Observer.py 2009-11-22 16:56:41 UTC (rev 357) @@ -44,7 +44,8 @@ self.mutex.acquire() try: - if not self.changed: return + if not self.changed: + return # Make a local copy in case of synchronous # additions of observers: localArray = self.obs[:] @@ -55,11 +56,16 @@ for observer in localArray: observer.update(self, arg) - def deleteObservers(self): self.obs = [] - def setChanged(self): self.changed = 1 - def clearChanged(self): self.changed = 0 - def hasChanged(self): return self.changed - def countObservers(self): return len(self.obs) + def deleteObservers(self): + self.obs = [] + def setChanged(self): + self.changed = 1 + def clearChanged(self): + self.changed = 0 + def hasChanged(self): + return self.changed + def countObservers(self): + return len(self.obs) synchronize(Observable, "addObserver deleteObserver deleteObservers " + Modified: trunk/pyscard/src/smartcard/ReaderMonitoring.py =================================================================== --- trunk/pyscard/src/smartcard/ReaderMonitoring.py 2009-11-22 16:47:03 UTC (rev 356) +++ trunk/pyscard/src/smartcard/ReaderMonitoring.py 2009-11-22 16:56:41 UTC (rev 357) @@ -167,7 +167,8 @@ if addedReaders or removedReaders: # Notify observers self.readers=[] - for r in currentReaders: self.readers.append(r) + for r in currentReaders: + self.readers.append(r) self.observable.setChanged() self.observable.notifyObservers((addedReaders, removedReaders)) Modified: trunk/pyscard/src/smartcard/Synchronization.py =================================================================== --- trunk/pyscard/src/smartcard/Synchronization.py 2009-11-22 16:47:03 UTC (rev 356) +++ trunk/pyscard/src/smartcard/Synchronization.py 2009-11-22 16:56:41 UTC (rev 357) @@ -24,7 +24,8 @@ """Synchronize methods in the given class. Only synchronize the methods whose names are given, or all methods if names=None.""" - if type(names)==type(''): names = names.split() + if type(names)==type(''): + names = names.split() for (name, val) in klass.__dict__.items(): if callable(val) and name != '__init__' and \ (names == None or name in names): Modified: trunk/pyscard/src/smartcard/pcsc/PCSCCardConnection.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCCardConnection.py 2009-11-22 16:47:03 UTC (rev 356) +++ trunk/pyscard/src/smartcard/pcsc/PCSCCardConnection.py 2009-11-22 16:56:41 UTC (rev 357) @@ -90,9 +90,11 @@ If mode is not specified, connect with SCARD_SHARE_SHARED.""" CardConnection.connect( self, protocol ) pcscprotocol = translateprotocolmask( protocol ) - if 0==pcscprotocol: pcscprotocol = self.getProtocol() + if 0==pcscprotocol: + pcscprotocol = self.getProtocol() - if mode==None: mode = SCARD_SHARE_SHARED + if mode==None: + mode = SCARD_SHARE_SHARED hresult, self.hcard, dwActiveProtocol = SCardConnect( self.hcontext, str(self.reader), mode, pcscprotocol ) if hresult!=0: Modified: trunk/pyscard/src/smartcard/pcsc/PCSCCardRequest.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCCardRequest.py 2009-11-22 16:47:03 UTC (rev 356) +++ trunk/pyscard/src/smartcard/pcsc/PCSCCardRequest.py 2009-11-22 16:56:41 UTC (rev 357) @@ -107,8 +107,10 @@ # for non infinite timeout, a timer will signal the end of the time-out by setting the evt event evt = threading.Event() - if INFINITE==self.timeout: timertimeout=1 - else: timertimeout=self.timeout + if INFINITE==self.timeout: + timertimeout=1 + else: + timertimeout=self.timeout timer = threading.Timer( timertimeout, signalEvent, [evt, INFINITE==self.timeout] ) # create a dictionary entry for new readers @@ -224,7 +226,8 @@ # update state dictionary readerstates[readername] = ( readername, eventstate ) - if evt.isSet(): raise CardRequestTimeoutException() + if evt.isSet(): + raise CardRequestTimeoutException() @@ -235,8 +238,10 @@ evt = threading.Event() # for non infinite timeout, a timer will signal the end of the time-out - if INFINITE==self.timeout: timertimeout=1 - else: timertimeout=self.timeout + if INFINITE==self.timeout: + timertimeout=1 + else: + timertimeout=self.timeout timer = threading.Timer( timertimeout, signalEvent, [evt, INFINITE==self.timeout] ) # get status change until time-out, e.g. evt is set @@ -301,7 +306,8 @@ presentcards.append( Card.Card( readername, atr ) ) return presentcards - if evt.isSet(): raise CardRequestTimeoutException() + if evt.isSet(): + raise CardRequestTimeoutException() if __name__ == '__main__': """Small sample illustrating the use of PCSCCardRequest.py.""" Modified: trunk/pyscard/src/smartcard/pcsc/PCSCReader.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCReader.py 2009-11-22 16:47:03 UTC (rev 356) +++ trunk/pyscard/src/smartcard/pcsc/PCSCReader.py 2009-11-22 16:56:41 UTC (rev 357) @@ -38,7 +38,8 @@ """ # in case we have a string instead of a list - if isinstance( groups, type("")): groups=[groups] + if isinstance( groups, type("")): + groups=[groups] hresult, readers = SCardListReaders( hcontext, groups ) if hresult!=0: if hresult==SCARD_E_NO_READERS_AVAILABLE: Modified: trunk/pyscard/src/smartcard/test/framework/testcase_ErrorChecking.py =================================================================== --- trunk/pyscard/src/smartcard/test/framework/testcase_ErrorChecking.py 2009-11-22 16:47:03 UTC (rev 356) +++ trunk/pyscard/src/smartcard/test/framework/testcase_ErrorChecking.py 2009-11-22 16:56:41 UTC (rev 357) @@ -83,8 +83,10 @@ except excClass, e: return e else: - if hasattr(excClass,'__name__'): excName = excClass.__name__ - else: excName = str(excClass) + if hasattr(excClass,'__name__'): + excName = excClass.__name__ + else: + excName = str(excClass) raise self.failureException, excName Modified: trunk/pyscard/src/smartcard/test/framework/testcase_readermonitorstress.py =================================================================== --- trunk/pyscard/src/smartcard/test/framework/testcase_readermonitorstress.py 2009-11-22 16:47:03 UTC (rev 356) +++ trunk/pyscard/src/smartcard/test/framework/testcase_readermonitorstress.py 2009-11-22 16:56:41 UTC (rev 357) @@ -80,8 +80,10 @@ mutexvreaders.acquire() if newreader not in virtualreaders: virtualreaders.append( newreader ) - if insertedreaderstats.has_key(newreader): insertedreaderstats[newreader]+=1 - else: insertedreaderstats[newreader]=1 + if insertedreaderstats.has_key(newreader): + insertedreaderstats[newreader]+=1 + else: + insertedreaderstats[newreader]=1 finally: readerEvent.clear() mutexvreaders.release() @@ -100,8 +102,10 @@ if virtualreaders: oldreader=random.choice( virtualreaders ) virtualreaders.remove(oldreader) - if removedreaderstats.has_key(oldreader): removedreaderstats[oldreader]+=1 - else: removedreaderstats[oldreader]=1 + if removedreaderstats.has_key(oldreader): + removedreaderstats[oldreader]+=1 + else: + removedreaderstats[oldreader]=1 finally: readerEvent.clear() mutexvreaders.release() @@ -117,11 +121,15 @@ def update( self, observable, (addedreaders, removedreaders) ): self.countnotified+=1 for newreader in addedreaders: - if self.insertedreaderstats.has_key(newreader): self.insertedreaderstats[newreader]+=1 - else: self.insertedreaderstats[newreader]=1 + if self.insertedreaderstats.has_key(newreader): + self.insertedreaderstats[newreader]+=1 + else: + self.insertedreaderstats[newreader]=1 for oldreader in removedreaders: - if self.removedreaderstats.has_key(oldreader): self.removedreaderstats[oldreader]+=1 - else: self.removedreaderstats[oldreader]=1 + if self.removedreaderstats.has_key(oldreader): + self.removedreaderstats[oldreader]+=1 + else: + self.removedreaderstats[oldreader]=1 class testcase_readermonitorstress( unittest.TestCase ): Modified: trunk/pyscard/src/smartcard/test/manual/testcase_manualCardRequest.py =================================================================== --- trunk/pyscard/src/smartcard/test/manual/testcase_manualCardRequest.py 2009-11-22 16:47:03 UTC (rev 356) +++ trunk/pyscard/src/smartcard/test/manual/testcase_manualCardRequest.py 2009-11-22 16:56:41 UTC (rev 357) @@ -43,17 +43,21 @@ print 'insert two smartcard readers' while True: readerz=readers() - if 2<=len( readerz ): break + if 2<=len( readerz ): + break time.sleep(.3) -for reader in readerz: print '\t', reader +for reader in readerz: + print '\t', reader print 'insert two cards in the readers' cardrequest = CardRequest() while True: cardz=cardrequest.waitforcardevent() - if 2<=len( cardz ): break + if 2<=len( cardz ): + break time.sleep(.3) -for card in cardz: print '\t', toHexString(card.atr) +for card in cardz: + print '\t', toHexString(card.atr) # @@ -74,7 +78,8 @@ cardrequest = CardRequest() while True: cards=cardrequest.waitforcardevent() - if 0==len( cards ): break + if 0==len( cards ): + break time.sleep(.3) print 'ok' @@ -173,7 +178,8 @@ _readerz=readers() while True: readerz=readers() - if len(_readerz)>len( readerz ): break + if len(_readerz)>len( readerz ): + break time.sleep(.1) for reader in readerz: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |