pull/29/head
deadc0de6 2 years ago
parent 173dca1d34
commit 7775a941a7

@ -39,14 +39,16 @@ class Decomp:
return self.ext[ext](path) return self.ext[ext](path)
return None return None
def _tar(self, path): @staticmethod
def _tar(path):
"""return list of file names in tar""" """return list of file names in tar"""
if not tarfile.is_tarfile(path): if not tarfile.is_tarfile(path):
return None return None
with tarfile.open(path, "r") as tar: with tarfile.open(path, "r") as tar:
return tar.getnames() return tar.getnames()
def _zip(self, path): @staticmethod
def _zip(path):
"""return list of file names in zip""" """return list of file names in zip"""
if not zipfile.is_zipfile(path): if not zipfile.is_zipfile(path):
return None return None

@ -57,7 +57,8 @@ class Noder:
if self.arc: if self.arc:
self.decomp = Decomp() self.decomp = Decomp()
def get_storage_names(self, top): @staticmethod
def get_storage_names(top):
"""return a list of all storage names""" """return a list of all storage names"""
return [x.name for x in list(top.children)] return [x.name for x in list(top.children)]
@ -79,7 +80,8 @@ class Noder:
found.ts = int(time.time()) found.ts = int(time.time())
return found return found
def get_node(self, top, path, quiet=False): @staticmethod
def get_node(top, path, quiet=False):
"""get the node by internal tree path""" """get the node by internal tree path"""
resolv = anytree.resolver.Resolver('name') resolv = anytree.resolver.Resolver('name')
try: try:
@ -272,7 +274,8 @@ class Noder:
cnt += 1 cnt += 1
return cnt return cnt
def flag(self, node): @staticmethod
def flag(node):
"""flag a node""" """flag a node"""
node.flag = True node.flag = True
@ -713,11 +716,13 @@ class Noder:
return self._sort_size(lst) return self._sort_size(lst)
return self._sort_fs(lst) return self._sort_fs(lst)
def _sort_fs(self, node): @staticmethod
def _sort_fs(node):
"""sorting nodes dir first and alpha""" """sorting nodes dir first and alpha"""
return (node.type, node.name.lstrip('.').lower()) return (node.type, node.name.lstrip('.').lower())
def _sort_size(self, node): @staticmethod
def _sort_size(node):
"""sorting nodes by size""" """sorting nodes by size"""
try: try:
if not node.size: if not node.size:
@ -732,7 +737,8 @@ class Noder:
return node return node
return node.ancestors[1] return node.ancestors[1]
def _has_attr(self, node, attr): @staticmethod
def _has_attr(node, attr):
"""return True if node has attr as attribute""" """return True if node has attr as attribute"""
return attr in node.__dict__.keys() return attr in node.__dict__.keys()
@ -747,7 +753,8 @@ class Noder:
return os.sep.join([parent, node.name]) return os.sep.join([parent, node.name])
return node.name return node.name
def _get_hash(self, path): @staticmethod
def _get_hash(path):
"""return md5 hash of node""" """return md5 hash of node"""
try: try:
return md5sum(path) return md5sum(path)
@ -755,7 +762,8 @@ class Noder:
Logger.err(str(exc)) Logger.err(str(exc))
return None return None
def _sanitize(self, node): @staticmethod
def _sanitize(node):
"""sanitize node strings""" """sanitize node strings"""
node.name = fix_badchars(node.name) node.name = fix_badchars(node.name)
node.relpath = fix_badchars(node.relpath) node.relpath = fix_badchars(node.relpath)

Loading…
Cancel
Save