def __init__(self, directory, name=None):
     self._directory = directory
     self._name = name
     isdir(self._directory) or makedirs(self._directory)
     self._storage = {}
     for name in listdir(directory):
         self._getStorage(unescapeFilename(name))
 def invalidRecords(self, domainId, repositoryId):
     invalidFile = join(self._statePath, domainId, escapeFilename("%s_invalid.ids" % repositoryId))
     if not isfile(invalidFile):
         return []
     return reversed(
         [x[:-1] if x[-1] == '\n' else x for x in
             (unescapeFilename(line) for line in open(invalidFile) if line.strip())
         ]
     )
 def invalidRecords(self, domainId, repositoryId):
     invalidFile = join(self._statePath, domainId,
                        escapeFilename("%s_invalid.ids" % repositoryId))
     if not isfile(invalidFile):
         return []
     with open(invalidFile) as fp:
         return reversed([
             x[:-1] if x[-1] == '\n' else x for x in (unescapeFilename(line)
                                                      for line in fp
                                                      if line.strip())
         ])
示例#4
0
def readIds(filename):
    ids = []
    uniqueIds = set()
    for id in (unescapeFilename(id) for id in open(filename)):
        if id[-1] == '\n':
            id = id[:-1]
        if id in uniqueIds:
            continue
        ids.append(id)
        uniqueIds.add(id)
    return ids
示例#5
0
def readIds(filename):
    uniqueIds = set()
    ids = []
    with open(filename, 'a+') as fp:
        fp.seek(0)
        for id in (unescapeFilename(id) for id in fp):
            if id[-1] == '\n':
                id = id[:-1]
            if id in uniqueIds:
                continue
            ids.append(id)
            uniqueIds.add(id)
    return ids
示例#6
0
 def __iter__(self):
     for id in iter(self._ids[:]):
         yield unescapeFilename(id)
示例#7
0
 def __iter__(self):
     for id in self._ids:
         yield unescapeFilename(id)