human number representation

This commit is contained in:
Amber 2024-01-31 12:01:46 +01:00
parent 179b2ab3f9
commit 8e174308a3
1 changed files with 16 additions and 15 deletions

View File

@ -11,7 +11,8 @@ CHILD_CONNECTOR = '├── '
LAST_CHILD_CONNECTOR = '└── ' LAST_CHILD_CONNECTOR = '└── '
### is the length of child connector and last_child_connector ### is the length of child connector and last_child_connector
LEVEL_INDENT = 4 LEVEL_INDENT = 4
ITEMS_TO_EXCLUDE = ['__pycache__'] # ITEMS_TO_EXCLUDE = ['__pycache__']
ITEMS_TO_EXCLUDE = []
KB = 1024 KB = 1024
MB = 1024*1024 MB = 1024*1024
@ -51,19 +52,19 @@ def produce_treeline(prec_seps, lsep):
return tree_line.rstrip() return tree_line.rstrip()
def format(num, unit=None): def format(num, unit=None):
# if num/GB >=1: if num/GB >=1 or unit == 'G':
# unit = 'GB' unit = 'G'
# human_number = round(num/GB, 2) human_number = round(num/GB, 2)
# elif num/MB >=1: elif num/MB >=1 or unit == 'M':
# unit = 'MB' unit = 'M'
# human_number = round(num/MB, 2) human_number = round(num/MB, 2)
# elif num/KB >=1: elif num/KB >=1 or unit == 'K':
# unit = 'kB' unit = 'K'
# human_number = round(num/KB, 2) human_number = round(num/KB, 2)
# else: else:
unit = 'B'
human_number = num
# unit = 'b' # unit = 'b'
# human_number = num # human_number = num
unit = 'b'
human_number = num
return human_number, unit return human_number, unit