def __delitem__(self, id): dirpath = id_to_dirpath(id, self._rl_dir) if os.path.isdir(dirpath): for f in os.listdir(dirpath): os.remove(os.path.join(dirpath, f)) os.removedirs(dirpath) # will throw OSError if the dir cannot be removed. self._init_store() # just in case
def __delitem__(self, id): dirpath = id_to_dirpath(id, self._rl_dir) if os.path.isdir(dirpath): for f in os.listdir(dirpath): os.remove(os.path.join(dirpath, f)) os.removedirs( dirpath) # will throw OSError if the dir cannot be removed. self._init_store() # just in case
def _id_to_dirpath(self, id): """ Internal - method for turning an identifier into a pairtree directory tree of shorties. - I{"foobar://ark.1" --> "fo/ob/ar/+=/ar/k,/1"} @param id: Identifer for a pairtree object @type id: identifier @returns: A directory path to the object's root directory """ # return os.sep.join(self._id_to_dir_list(id)) return ppath.id_to_dirpath(id, self.pairtree_root, self.shorty_length)
def id2path(id): """ pass in a pairtree id and get back a path """ path = ppath.id_to_dirpath(id) return path
def __init__(self, rl_dir, id): self._rl_dir = rl_dir self._id = id self._dirpath = id_to_dirpath(self._id, self._rl_dir)