コード例 #1
0
ファイル: resource_.py プロジェクト: matrixorz/ikaaro
    def get_resource(self, path, soft=False):
        if type(path) is not Path:
            path = Path(path)

        # 1. Get the metadata
        if path.is_absolute():
            abspath = path
        else:
            abspath = self.abspath.resolve2(path)

        return self.database.get_resource(abspath, soft=soft)
コード例 #2
0
ファイル: resource_.py プロジェクト: staverne/ikaaro
    def get_resource(self, path, soft=False):
        if type(path) is not Path:
            path = Path(path)

        # 1. Get the metadata
        if path.is_absolute():
            abspath = path
        else:
            abspath = self.abspath.resolve2(path)

        return self.database.get_resource(abspath, soft=soft)
コード例 #3
0
    def get_resource(self, path, soft=False):
        if type(path) is not Path:
            path = Path(path)

        if path.is_absolute():
            here = self.get_root()
        else:
            here = self

        while path and path[0] == '..':
            here = here.parent
            path = path[1:]

        for name in path:
            resource = here._get_resource(name)
            if resource is None:
                if soft is True:
                    return None
                raise LookupError, 'resource "%s" not found' % path
            resource.parent = here
            resource.name = name
            here = resource

        return here