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
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")
def build(fname, *args, **kwargs): type = FileTask if kwargs.get("recreate", True) else FileCreationTask return task(*args, type=type, name=aspath(fname))
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)
def _resolve_add(self, fn): if re.search(r"[*?\[\{]", fn): self._add_matching(fn) else: self.append(aspath(fn))
def remove(self, obj): self.resolve() self._items.remove(aspath(obj))
def pop(self, index): self.resolve() return aspath(self._items.pop(index))
def insert(self, index, obj): self.resolve() self._items.insert(index, aspath(obj))
def index(self, obj, *args): self.resolve() return self._items.index(aspath(obj), *args)
def extend(self, iterobj): self.resolve() self._items.extend(aspath(p) for p in iterobj)
def count(self, obj): self.resolve() return self._items.count(aspath(obj))
def append(self, obj): self.resolve() self._items.append(aspath(obj))
def next(self): return aspath(self.source.next())
def __contains__(self, item): self.resolve() return aspath(item) in self._items