2021-11-22 22:38:32 -06:00
|
|
|
#!/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
|
2021-11-23 11:15:47 -06:00
|
|
|
except record.FileParsingError:
|
2021-11-22 22:38:32 -06:00
|
|
|
print(f"[{red}error{reset}] error parsing file!")
|
|
|
|
return
|
|
|
|
|
|
|
|
entries = rec.findEntrypoints()
|
|
|
|
|
|
|
|
for i in entries:
|
|
|
|
printRecord(i, 0)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|