Example #1
0
    def _iter_contents(self):
        self.clear()
        for line in self._get_fd():
            if not line:
                continue
            s = line.split(" ")
            if s[0] in ("dir", "dev", "fif"):
                path = ' '.join(s[1:])
                if s[0] == 'dir':
                    obj = fs.fsDir(path, strict=False)
                elif s[0] == 'dev':
                    obj = LookupFsDev(path, strict=False)
                else:
                    obj = fs.fsFifo(path, strict=False)
            elif s[0] == "obj":
                path = ' '.join(s[1:-2])
                obj = fs.fsFile(
                    path, chksums={"md5":int(s[-2], 16)},
                        mtime=int(s[-1]), strict=False)
            elif s[0] == "sym":
                try:
                    p = s.index("->")
                    obj = fs.fsLink(' '.join(s[1:p]), ' '.join(s[p+1:-1]),
                        mtime=int(s[-1]), strict=False)

                except ValueError:
                    # XXX throw a corruption error
                    raise
            else:
                raise Exception(f"unknown entry type {line!r}")

            yield obj
Example #2
0
    def _iter_contents(self):
        self.clear()
        for line in self._get_fd():
            if not line:
                continue
            s = line.split(" ")
            if s[0] in ("dir", "dev", "fif"):
                path = ' '.join(s[1:])
                if s[0] == 'dir':
                    obj = fs.fsDir(path, strict=False)
                elif s[0] == 'dev':
                    obj = LookupFsDev(path, strict=False)
                else:
                    obj = fs.fsFifo(path, strict=False)
            elif s[0] == "obj":
                path = ' '.join(s[1:-2])
                obj = fs.fsFile(
                    path, chksums={"md5":long(s[-2], 16)},
                        mtime=long(s[-1]), strict=False)
            elif s[0] == "sym":
                try:
                    p = s.index("->")
                    obj = fs.fsLink(' '.join(s[1:p]), ' '.join(s[p+1:-1]),
                        mtime=long(s[-1]), strict=False)

                except ValueError:
                    # XXX throw a corruption error
                    raise
            else:
                raise Exception(
                    "unknown entry type %r" % (line,))

            yield obj
Example #3
0
 def __init__(self, *a, **kw):
     TestCase.__init__(self, *a, **kw)
     self.files = list(map(self.mk_file, ["/etc/blah", "/etc/foo", "/etc/dar",
          "/tmp/dar",
          "/tmp/blah/foo/long/ass/file/name/but/not/that/bad/really"]))
     self.dirs = list(map(self.mk_dir, ["/tmp", "/blah", "/tmp/dar",
         "/usr/", "/usr/bin"]))
     self.links = [fs.fsLink(x, os.path.dirname(x), strict=False) for x in
         ["/tmp/foo", "/usr/X11R6/lib", "/nagga/noo"]]
     self.devs = list(map(self.mk_dev,
         [pjoin("dev", x) for x in ["sda1", "hda", "hda2", "disks/ide1"]]))
     self.fifos = list(map(self.mk_fifo,
         [pjoin("tmp", y) for y in ("dar", "boo", "bah")]))
     self.all = self.dirs + self.links + self.devs + self.fifos