diff --git a/parsers/survex.py b/parsers/survex.py index 8ba7866..2be2217 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -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. @@ -2203,7 +2214,7 @@ def FindAndLoadSurvex(survexblockroot): ) check_team_cache() print(f" -- Now loading the previously-omitted survex files.", file=sys.stderr) - print(f" - (except the exceptions: {excpts})", file=sys.stderr) + print(f" - (except: {excpts})", file=sys.stderr) with open(Path(settings.SURVEX_DATA, UNSEENS), "w") as u: u.write(