2019-03-12 17:15:42 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- encoding: utf-8 -*-
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
from .documents import fromFile as DocumentFromFile
|
2019-04-05 10:00:06 +00:00
|
|
|
from .document_finder import classes as docClasses
|
2019-04-05 19:39:40 +00:00
|
|
|
from .document_finder import find_references as referenceFinder
|
2019-03-12 17:15:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2019-04-05 10:00:06 +00:00
|
|
|
rootsrc, rootname = Path("rootdoc.txt").read_text().splitlines()
|
2019-04-06 15:52:28 +00:00
|
|
|
analyzedDocPaths = list()
|
|
|
|
pendingDocCchMgr = [docClasses[rootsrc](rootname)]
|
|
|
|
while len(pendingDocCchMgr) > 0:
|
|
|
|
docCchMgr, *pendingDocCchMgr = pendingDocCchMgr
|
|
|
|
print("Document: %s" % docCchMgr._identifier)
|
|
|
|
docPath = docCchMgr.cached()
|
|
|
|
if docPath in analyzedDocPaths:
|
|
|
|
continue
|
|
|
|
analyzedDocPaths.append(docPath)
|
|
|
|
docFF = DocumentFromFile(str(docPath))
|
|
|
|
if docFF is None:
|
|
|
|
continue
|
|
|
|
doc = docFF.parse()
|
|
|
|
newReferences = referenceFinder(doc, docCchMgr.context(docPath))
|
|
|
|
pendingDocCchMgr = [*pendingDocCchMgr, *newReferences]
|
|
|
|
print("Pending queue: %03d" % len(pendingDocCchMgr))
|