dirtree.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:knowledge_linker 作者: glciampaglia 项目源码 文件源码
def __init__(self, prefix, children, suffix='.dat', root='root', createdirs=True):
        '''
        Parameters
        ----------

        prefix : string
            All paths are prefixed with this string.

        children: sequence of ints
            Creates a directory tree rooted at path given by `root` with levels
            specified by the `children` array: level ``i`` had ``children[i]``
            children. ``children[-1]`` specifies the arity of the leaves.

        suffix : string
            The suffix of the leafs (i.e. files) of the tree.

        root : path
            The path to the root of the tree.

        createdirs : bool.
            If True, actually create the directories. Note: this is not thread-safe.
        '''
        if len(children) == 0:
            raise ValueError("need at least one level")
        self.children = np.asarray(children)
        self.root = root
        self.prefix = prefix
        self.suffix = suffix
        self.depth = len(children)
        self._cap = np.cumprod(self.children[::-1])[::-1]
        self.capacity = self._cap[0]
        self._den = self._cap / self.children
        self.width = int(np.ceil(np.log10(self.capacity)))
        if createdirs:
            self._mktree()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号