diff options
Diffstat (limited to 'parsers/survex.py')
-rw-r--r-- | parsers/survex.py | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/parsers/survex.py b/parsers/survex.py index b3db9e7..2be2217 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -271,7 +271,7 @@ class LoadingSurvex: rx_names = re.compile(r"(?i)names") rx_flagsnot = re.compile(r"not\s") rx_linelen = re.compile(r"[\d\-+.]+$") - instruments = "(bitch|bodger|bolt|bolter|bolting|book|clino|comp|compass|consultant|disto|distox|distox2|dog|dogsbody|drawing|drill|gps|helper|inst|instr|instrument|monkey|nagging|nail|nail_polish|nail_polish_bitch|nail_polish_monkey|nail_varnish|nail_varnish_bitch|note|paint|photo|pic|point|polish|powerdrill|rig|rigger|rigging|sketch|slacker|something|tape|topodroid|unknown|useless|varnish|waiting_patiently)" + instruments = "(bitch|bodger|bolt|bolter|bolting|book|clino|comp|compass|consultant|disto|distox|distox2|dog|dogsbody|drawing|drill|gps|helper|inst|instr|instrument|monkey|nagging|nail|nail_polish|nail_polish_bitch|nail_polish_monkey|nail_varnish|nail_varnish_bitch|note|paint|photo|pic|point|polish|powerdrill|rig|rigger|rigging|shoot|sketch|slacker|something|tape|topodroid|unknown|useless|varnish|waiting_patiently)" rx_teammem = re.compile(r"(?i)" + instruments + "?(?:es|s)?\s+(.*)$") rx_teamold = re.compile(r"(?i)(.*)\s+" + instruments + "?(?:es|s)?$") rx_teamabs = re.compile(r"(?i)^\s*(" + instruments + ")?(?:es|s)?\s*$") @@ -435,23 +435,34 @@ class LoadingSurvex: self.currentdate = self.inheritdate # unecessary duplication # Not an error, so not put in DataIssues, but is printed to debug output message = ( - f"- No *date. INHERITING date from ({survexblock.parent})-{survexblock.parent.survexfile.path} to ({survexblock})-{survexblock.survexfile.path} {self.inheritdate:%Y-%m-%d}" + f"- No *date. INHERITING date '{self.inheritdate:%Y-%m-%d}' from ({survexblock.parent})-{survexblock.parent.survexfile.path} to ({survexblock})-{survexblock.survexfile.path} {self.inheritdate:%Y-%m-%d}" ) print(self.insp + message) # stash_data_issue( # parser="survex", message=message, url=None, sb=(survexblock.survexfile.path) # child # ) if survexblock.survexfile != survexblock.parent.survexfile: - # This is noteworthy, however. - message = ( - f"- Warning *date INHERITED from DIFFERENT file:\n ({survexblock.parent})-{survexblock.parent.survexfile.path} to ({survexblock})-{survexblock.survexfile.path} {self.inheritdate:%Y-%m-%d}\n {self.stackbegin} {self.inheritdate:%Y-%m-%d}" - ) - print(self.insp + message) - stash_data_issue( - parser="survex", message=message, url=None, sb=(survexblock.parent.survexfile.path) # PARENT - ) - - return self.inheritdate + # This is noteworthy, however. + + if survexblock.parent.name == "rootblock": + # Not a sensible thing to inherit a date from, even if a date exists, which it shouldn't... + message = ( + f"- No *date. But not sensible to inherit from rootblock. From ({survexblock.parent})-{survexblock.parent.survexfile.path} to ({survexblock})-{survexblock.survexfile.path} {self.inheritdate:%Y-%m-%d}" + ) + print(self.insp + message) + # stash_data_issue( + # parser="survex", message=message, url=None, sb=(survexblock.survexfile.path) + # ) + return + else: + message = ( + f"- Warning *date '{self.inheritdate:%Y-%m-%d}' INHERITED from DIFFERENT file:\n ({survexblock.parent})-{survexblock.parent.survexfile.path} to ({survexblock})-{survexblock.survexfile.path} {self.inheritdate:%Y-%m-%d}\n {self.stackbegin} {self.inheritdate:%Y-%m-%d}" + ) + print(self.insp + message) + stash_data_issue( + parser="survex", message=message, url=None, sb=(survexblock.parent.survexfile.path) # PARENT + ) + return self.inheritdate else: # This is not an error in the Expo dataset. # Many files just holding *include lines do not have dates. @@ -1550,9 +1561,9 @@ class LoadingSurvex: nonlocal blockcount blockcount += 1 - if blockcount % 20 == 0: + if blockcount % 40 == 0: print(".", file=sys.stderr, end="") - if blockcount % 800 == 0: + if blockcount % 1600 == 0: print("\n", file=sys.stderr, end="") mem = get_process_memory() print(f" - MEM: {mem:7.2f} MB in use", file=sys.stderr) @@ -2186,7 +2197,7 @@ def FindAndLoadSurvex(survexblockroot): ) unseensroot = re.sub(r"\.svx$", "", UNSEENS) - excpts = ["surface/terrain", "kataster/kataster-boundaries", "template", "docs", unseensroot] + excpts = ["surface/terrain", "kataster/kataster-boundaries", "template", "docs", "deprecated", "subsections", unseensroot] removals = [] for x in unseens: for o in excpts: @@ -2202,7 +2213,8 @@ def FindAndLoadSurvex(survexblockroot): file=sys.stderr, ) check_team_cache() - print(" -- Now loading the previously-omitted survex files.", file=sys.stderr) + print(f" -- Now loading the previously-omitted survex files.", file=sys.stderr) + print(f" - (except: {excpts})", file=sys.stderr) with open(Path(settings.SURVEX_DATA, UNSEENS), "w") as u: u.write( @@ -2498,7 +2510,11 @@ def MakeFileRoot(fn): print(f" - Making/finding a new root survexfile for this import: {fn}") fileroot = SurvexFile(path=fn, cave=cave) - fileroot.survexdirectory = SurvexDirectory.objects.get(id=1) # default + try: + fileroot.survexdirectory = SurvexDirectory.objects.get(id=1) # default + except: + fileroot.survexdirectory = None + if cave: # But setting the SurvexDirectory does work ! |