def __init__(self, source, factory, key = None):
        """Initialize the CSV data source
        
        The CSV data source, where the first data row in the represented file
        contains the field headers (names).
        
        Args:
            source: This can be a String, a csv.DictReader, or a generic object
                 that supports the iterator protocol (see csv.reader).  If 
                 this is a String, it should point to either a CSV file, 
                 or a directory containing CSV files.  If it is a 
                 object supporting the iterator protocol, each call to next()
                 should return a valid csv line.
            factory: A callable that implements zope.component.factory.IFactory 
                 that generates instances of ICachableItem.
            key: String name of CSV header field that acts as the unique key for each 
                 CSV item entry (i.e. the primary key field)
        
        Raises:
            ValueError: if string source parameter does not point a referencable file or directory
        
        """
        # TODO: This class current has more methods than ICachableSource.  We either 
        #       need to update the interface, or create a new one for the extra methods
        self._key = key
        self.source = source
        self.factory = factory
        self._files = list()
        self._csv_dictreader_list = list()
        
        if isinstance(source, str):
            if os.path.isfile(source):
                _file = open(source,'rb')
                self._files.append(_file)
                self._csv_dictreader_list.append(DictReader(_file))
            elif os.path.isdir(source):
                for _entry in os.listdir(source):
                    _file = open(_entry,'rb')
                    self._files.append(_file)
                    self._csv_dictreader_list.append(DictReader(_file))
            else:
                raise ValueError("expected string source parameter to reference a valid file or directory: " + str(source))
        elif isinstance(source, DictReader):
            self._csv_dictreader_list.append(source)
        else:
            self._csv_dictreader_list.append(DictReader(source))
def __init__ ( self , source , factory , key = None ) : self . _key = key self . source = source self . factory = factory self . _files = list ( ) self . _csv_dictreader_list = list ( ) if isinstance ( source , str ) : if os . path . isfile ( source ) : _file = open ( source , 'rb' ) self . _files . append ( _file ) self . _csv_dictreader_list . append ( DictReader ( _file ) ) elif os . path . isdir ( source ) : for _entry in os . listdir ( source ) : _file = open ( _entry , 'rb' ) self . _files . append ( _file ) self . _csv_dictreader_list . append ( DictReader ( _file ) ) else : raise ValueError ( "expected string source parameter to reference a valid file or directory: " + str ( source ) ) elif isinstance ( source , DictReader ) : self . _csv_dictreader_list . append ( source ) else : self . _csv_dictreader_list . append ( DictReader ( source ) )
Initialize the CSV data source
        
        The CSV data source, where the first data row in the represented file
        contains the field headers (names).
        
        Args:
            source: This can be a String, a csv.DictReader, or a generic object
                 that supports the iterator protocol (see csv.reader).  If 
                 this is a String, it should point to either a CSV file, 
                 or a directory containing CSV files.  If it is a 
                 object supporting the iterator protocol, each call to next()
                 should return a valid csv line.
            factory: A callable that implements zope.component.factory.IFactory 
                 that generates instances of ICachableItem.
            key: String name of CSV header field that acts as the unique key for each 
                 CSV item entry (i.e. the primary key field)
        
        Raises:
            ValueError: if string source parameter does not point a referencable file or directory