Beispiel #1
0
    def load_dir(self, pn, generate=True, dirty=False, merge=False):

        if not os.path.isdir(pn):
            return None

        blob = self.get_root_blob()
        abspath = os.path.abspath(pn)
        relpath = self.metasync.get_relative_path(abspath)
        if (relpath == "."):
            return blob
        for (_, name) in util.iter_path_crumb(relpath):
            # create one if not exist
            if not name in blob:
                if generate:
                    if merge:
                        blob.add(name, MBlobDir2(self))
                    else:
                        blob.add(name, BlobDir2(self))
                else:
                    raise NotTrackedException(name)
            elif dirty:
                blob.add(name, blob[name])
            # fetch child
            blob = blob[name]

        return blob
Beispiel #2
0
    def load_dir(self, pn, generate=True, dirty=False, merge=False):

        if not os.path.isdir(pn):
            return None

        blob = self.get_root_blob()
        abspath = os.path.abspath(pn)
        relpath = self.metasync.get_relative_path(abspath)
        if(relpath == "."): 
            return blob
        for (_, name) in util.iter_path_crumb(relpath):
            # create one if not exist
            if not name in blob:
                if generate:
                    if merge:
                        blob.add(name, MBlobDir2(self))
                    else:
                        blob.add(name, BlobDir2(self))
                else:
                    raise NotTrackedException(name)
            elif dirty:
                blob.add(name, blob[name])
            # fetch child
            blob = blob[name]

        return blob
Beispiel #3
0
def test_util(metasync, opts):
    "test functions in util.py"

    opts.notree = True

    rtn = ["a", "a/b", "a/b/c"]
    for (crumb, name) in util.iter_path_crumb("./a/b/c/"):
        assert crumb == rtn.pop(0)
Beispiel #4
0
def test_util(metasync, opts):
    "test functions in util.py"

    opts.notree = True

    rtn = ["a", "a/b", "a/b/c"]
    for (crumb, name) in util.iter_path_crumb("./a/b/c/"):
        assert crumb == rtn.pop(0)