diff --git a/guider/guider.py b/guider/guider.py index 9f106c8e..35bd5ae2 100755 --- a/guider/guider.py +++ b/guider/guider.py @@ -7,7 +7,7 @@ __credits__ = "Peace Lee" __license__ = "GPLv2" __version__ = "3.9.8" -__revision__ = "240810" +__revision__ = "240811" __maintainer__ = "Peace Lee" __email__ = "iipeace5@gmail.com" __repository__ = "https://github.com/iipeace/guider" @@ -6498,6 +6498,11 @@ def printAllAttrs(objList, name, rep=None, nameFilter=[]): printTree = "PRINTTREE" in SysMgr.environList treeList = {} + # get shotcuts and filters # + convColor = UtilMgr.convColor + incFilter = SysMgr.environList.get("INCFILTER", []) + exFilter = SysMgr.environList.get("EXFILTER", []) + def _applyTreeItem(treeList, items, val): if not isinstance(treeList, dict): return @@ -6512,21 +6517,38 @@ def _applyTreeItem(treeList, items, val): elif "size" in val: treeList[name] = val["size"] - def _printTreeItems(data, indent=0): - for key, value in data.items(): + def _printTreeItems(data, indent=1): + for key, value in sorted( + data.items(), + key=lambda x: (1, x[0]) + if isinstance(x[1], (int, long)) + else (0, x[0]), + ): if key: - if isinstance(value, (int, long)): - size = " (%s)" % UtilMgr.convSize2Unit(value) + if incFilter and not UtilMgr.isValidStr(key, incFilter): + isValid = False + elif exFilter and UtilMgr.isValidStr(key, exFilter): + isValid = False else: - key = "[%s]" % key + isValid = True + + if not isValid: + pass + elif isinstance(value, (int, long)): + size = " (%s)" % convColor( + UtilMgr.convSize2Unit(value), "CYAN" + ) + else: + key = "[%s]" % convColor(key, "GREEN") size = "" - SysMgr.printPipe( - " " * indent - + ("|-" if indent else "") - + str(key) - + size - ) + if isValid: + SysMgr.printPipe( + ("| " * indent if indent > 1 else "") + + ("|-" if indent else "") + + str(key) + + size + ) if isinstance(value, dict): _printTreeItems(value, indent + 1) @@ -40746,6 +40768,7 @@ def _getDesc(s, t=0): - Print target files in compressed data in tree structure # {0:1} {1:1} {3:1} -q PRINTTREE + # {0:1} {1:1} {3:1} -q PRINTTREE, INCFILTER:"*test*", EXFILTER:"*zip" - Print specific target files in compressed data and save them to files # {0:1} {1:1} {3:1} -g "*.so" -q EXTRACT