add listing.py to list out data
This commit is contained in:
parent
4b4da419dd
commit
72f45811c7
|
@ -0,0 +1,44 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import record
|
||||||
|
import sys
|
||||||
|
|
||||||
|
red = '\033[31m'
|
||||||
|
blue = '\033[34m'
|
||||||
|
green = '\033[32m'
|
||||||
|
reset = '\033[0m'
|
||||||
|
|
||||||
|
def printRecord(rec, level):
|
||||||
|
try: filename = rec.data['file']
|
||||||
|
except KeyError: filename = None
|
||||||
|
|
||||||
|
# TODO: if multi-inherit, specify correct inherit_order
|
||||||
|
try: index = rec.data['inherit_order']
|
||||||
|
except KeyError: index = None
|
||||||
|
|
||||||
|
print(" " * level +
|
||||||
|
f"[{red}{index}{reset}] {green}{rec.name}{reset}, {blue}{filename}{reset}")
|
||||||
|
|
||||||
|
for i in rec.children:
|
||||||
|
printRecord(rec.children[i], level + 1)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
try:
|
||||||
|
rec = record.RecordCollection(sys.argv[1])
|
||||||
|
except IndexError:
|
||||||
|
print(f"[{red}error{reset}] you didn't specify the file!")
|
||||||
|
return
|
||||||
|
except FileNotFoundError:
|
||||||
|
print(f"[{red}error{reset}] the file doesn't exist!")
|
||||||
|
return
|
||||||
|
except FileParsingError:
|
||||||
|
print(f"[{red}error{reset}] error parsing file!")
|
||||||
|
return
|
||||||
|
|
||||||
|
entries = rec.findEntrypoints()
|
||||||
|
|
||||||
|
for i in entries:
|
||||||
|
printRecord(i, 0)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in New Issue