示例#1
0
 def __getitem__(self, item):
     self.resolve()
     if not isinstance(item, slice):
         return aspath(self._items[item])
     ret = FileList(self)
     ret._items = self._items[item]
     return ret
示例#2
0
 def __setitem__(self, item, value):
     self.resolve()
     if not isinstance(item, slice):
         self._items[item] = aspath(value)
     elif isinstance(value, list):
         self._items[item] = map(aspath, value)
     elif isinstance(value, FileList):
         value.resolve()
         self._items[item] = value._items
     else:
         raise TypeError("%r is not an instance of list or FileList")
示例#3
0
def build(fname, *args, **kwargs):
    type = FileTask if kwargs.get("recreate", True) else FileCreationTask
    return task(*args, type=type, name=aspath(fname))
示例#4
0
def build(fname, *args, **kwargs):
    type = FileTask if kwargs.get("recreate", True) else FileCreationTask
    return task(*args, type=type, name=aspath(fname))
示例#5
0
 def _add_matching(self, pattern):
     "Add files matching the glob pattern."
     fnames = filter(lambda fn: not self.is_excluded(fn), glob.glob(pattern))
     self.extend(aspath(fn) for fn in fnames)
示例#6
0
 def _resolve_add(self, fn):
     if re.search(r"[*?\[\{]", fn):
         self._add_matching(fn)
     else:
         self.append(aspath(fn))
示例#7
0
 def remove(self, obj):
     self.resolve()
     self._items.remove(aspath(obj))
示例#8
0
 def pop(self, index):
     self.resolve()
     return aspath(self._items.pop(index))
示例#9
0
 def insert(self, index, obj):
     self.resolve()
     self._items.insert(index, aspath(obj))
示例#10
0
 def index(self, obj, *args):
     self.resolve()
     return self._items.index(aspath(obj), *args)
示例#11
0
 def extend(self, iterobj):
     self.resolve()
     self._items.extend(aspath(p) for p in iterobj)
示例#12
0
 def count(self, obj):
     self.resolve()
     return self._items.count(aspath(obj))
示例#13
0
 def append(self, obj):
     self.resolve()
     self._items.append(aspath(obj))
示例#14
0
 def next(self):
     return aspath(self.source.next())
示例#15
0
 def __contains__(self, item):
     self.resolve()
     return aspath(item) in self._items