def in_dir(self, d, e): """ Filter only those archive entries which exist in the same directory level """ if e.startswith(d.lstrip(os.sep)) and \ len(util.split_path(e)) == (len(util.split_path(d)) + 1): return True else: return False
def _init_members(self, tarobj): """ Init members from archive contents """ members = {} for name in tarobj.getnames(): data = util.split_path(name) current = [] for obj in data: current.append(obj) path = os.path.join(*current) if path not in members: try: item = tarobj.getmember(path) except KeyError: try: item = tarobj.getmember(path + os.sep) except KeyError: # Create dummy dir item = self._make_dummy_dir(path) members[path] = item return members