From: <jda...@us...> - 2010-06-23 17:05:44
|
Revision: 501 http://pyscard.svn.sourceforge.net/pyscard/?rev=501&view=rev Author: jdaussel Date: 2010-06-23 17:05:38 +0000 (Wed, 23 Jun 2010) Log Message: ----------- Reader list is now created by ReaderFactory static method Modified Paths: -------------- trunk/pyscard/src/smartcard/System.py trunk/pyscard/src/smartcard/pcsc/PCSCReader.py trunk/pyscard/src/smartcard/reader/ReaderFactory.py Modified: trunk/pyscard/src/smartcard/System.py =================================================================== --- trunk/pyscard/src/smartcard/System.py 2010-06-23 16:39:34 UTC (rev 500) +++ trunk/pyscard/src/smartcard/System.py 2010-06-23 17:05:38 UTC (rev 501) @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ -import smartcard.pcsc.PCSCReader +import smartcard.reader.ReaderFactory import smartcard.pcsc.PCSCReaderGroups @@ -38,7 +38,7 @@ r=smartcard.readers(['SCard$DefaultReaders', 'MyReaderGroup']) """ - return smartcard.pcsc.PCSCReader.PCSCReader.readers(groups) + return smartcard.reader.ReaderFactory.ReaderFactory.readers(groups) def readergroups(): Modified: trunk/pyscard/src/smartcard/pcsc/PCSCReader.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCReader.py 2010-06-23 16:39:34 UTC (rev 500) +++ trunk/pyscard/src/smartcard/pcsc/PCSCReader.py 2010-06-23 17:05:38 UTC (rev 501) @@ -23,7 +23,6 @@ """ from smartcard.CardConnectionDecorator import CardConnectionDecorator -from smartcard.reader.ReaderFactory import ReaderFactory from smartcard.reader.Reader import Reader from smartcard.pcsc.PCSCContext import PCSCContext from smartcard.pcsc.PCSCCardConnection import PCSCCardConnection @@ -99,16 +98,16 @@ class Factory: - def create(self, readername): + def create(readername): return PCSCReader(readername) + create = staticmethod(create) def readers(groups=[]): creaders = [] hcontext = PCSCContext().getContext() for reader in __PCSCreaders__(hcontext, groups): - creaders.append(ReaderFactory.createReader( - 'smartcard.pcsc.PCSCReader.PCSCReader', reader)) + creaders.append(PCSCReader.Factory.create(reader)) return creaders readers = staticmethod(readers) Modified: trunk/pyscard/src/smartcard/reader/ReaderFactory.py =================================================================== --- trunk/pyscard/src/smartcard/reader/ReaderFactory.py 2010-06-23 16:39:34 UTC (rev 500) +++ trunk/pyscard/src/smartcard/reader/ReaderFactory.py 2010-06-23 17:05:38 UTC (rev 501) @@ -31,18 +31,15 @@ """ from smartcard.ClassLoader import get_class +from smartcard.pcsc.PCSCReader import PCSCReader class ReaderFactory: """Class to create readers from reader type id.""" factories = {} + factorymethods = [PCSCReader.readers] - def addFactory(id, ReaderFactory): - """Static method to add a ReaderFactory associated to a reader id.""" - ReaderFactory.factories.put[id] = ReaderFactory - addFactory = staticmethod(addFactory) - # A Template Method: def createReader(clazz, readername): """Static method to create a reader from a reader clazz. @@ -55,3 +52,10 @@ ReaderFactory.factories[clazz] = get_class(clazz).Factory() return ReaderFactory.factories[clazz].create(readername) createReader = staticmethod(createReader) + + def readers(groups=[]): + zreaders = [] + for fm in ReaderFactory.factorymethods: + zreaders += fm(groups) + return zreaders + readers = staticmethod(readers) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |