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()
评论列表
文章目录