summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-11-04 18:27:41 +0200
committerPhilip Sargent <philip.sargent@gmail.com>2023-11-04 18:27:41 +0200
commita63275f9137eee453c6a4ce86b2d35c4eba3f06c (patch)
treea0869b89428085ece3ab6450418dd1ab32af1b93
parent55bbccb4ca465e57e658b1d68d96e2d79305963a (diff)
downloadtroggle-a63275f9137eee453c6a4ce86b2d35c4eba3f06c.tar.gz
troggle-a63275f9137eee453c6a4ce86b2d35c4eba3f06c.tar.bz2
troggle-a63275f9137eee453c6a4ce86b2d35c4eba3f06c.zip
do NOT inherit *date between *include files - policy decision
-rw-r--r--parsers/survex.py43
1 files changed, 25 insertions, 18 deletions
diff --git a/parsers/survex.py b/parsers/survex.py
index 1214e0c..15a4c67 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -399,6 +399,10 @@ class LoadingSurvex:
but inheriting dates across *include files is almost certainly NOT
expected behaviour, even though it is syntactically "correct",
so triggers a Warning.
+
+ In fact, rather than give a warning, I think this is where troggle should diverge from
+ a strict interpretation of how survex works. So I will change this so that *date
+ is NOT inherited between different files.
"""
if survexblock.parent.name == "troggle_unseens":
# Bolluxed up if we try to inherit from this random junk, so don't.
@@ -429,27 +433,30 @@ class LoadingSurvex:
# parser="survex", message=message, url=None, sb=(survexblock.survexfile.path) # child
# )
if survexblock.survexfile != survexblock.parent.survexfile:
- # This is noteworthy, however.
+ # This is noteworthy, however. FORBID inheriting dates between files. NOT documented survex behaviour !!
+ survexblock.date = None
+ self.currentdate = None # unecessary duplication
+ return None
- 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)
+ # 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.survexfile.path)
+ # parser="survex", message=message, url=None, sb=(survexblock.survexfile.path) # not the parent
# )
- 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
+ # return self.inheritdate
else:
# This is not an error in the Expo dataset.
# Many files just holding *include lines do not have dates.