2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-02-08 13:03:46 +00:00

*team new code to fit updated survex

This commit is contained in:
2025-02-25 00:54:49 +00:00
parent c98f386c13
commit 54717a436c

View File

@@ -269,10 +269,19 @@ class LoadingSurvex:
#rx_names = re.compile(r"(?i)names") #rx_names = re.compile(r"(?i)names")
rx_flagsnot = re.compile(r"not\s") rx_flagsnot = re.compile(r"not\s")
rx_linelen = re.compile(r"[\d\-+.]+$") 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|shoot|sketch|slacker|something|surface|tape|topodroid|unknown|useless|varnish|waiting_patiently)"
rx_teammem = re.compile(r"(?i)" + instruments + r"?(?:es|s)?\s+(.*)$") # this extensive list of expo roles are now (after 24/2/2025) just comments and not legal survex code.
rx_teamold = re.compile(r"(?i)(.*)\s+" + instruments + r"?(?:es|s)?$") roles = "(assistant|bitch|bodger|bolt|bolter|bolting|book|clino|comp|compass|consultant|disto|distox|distox2|"
rx_teamabs = re.compile(r"(?i)^\s*(" + instruments + r")?(?:es|s)?\s*$") roles += "dog|dogsbody|drawing|drill|gps|helper|inst|instr|instrument|length|monkey|nagging|nail|"
roles += "nail_polish|nail_polish_bitch|nail_polish_monkey|nail_varnish|nail_varnish_bitch|note|notebook|"
roles += "paint|photo|pic|pictures|point|polish|powerdrill|rig|rigger|rigging|shoot|sketch|slacker|"
roles += "something|station|surface|tape|topodroid|unknown|useless|varnish|waiting_patiently)"
#rx_teammem = re.compile(r"(?i)" + roles + r"?(?:es|s)?\s+(.*)$") no longer legal survex ordering
teamfix = r"(?i)(.*?)\s+" + roles + r"?(?:es|s)?$"
rx_teamfix = re.compile(teamfix)
rx_teamabs = re.compile(r"(?i)^\s*(" + roles + r")?(?:es|s)?\s*$")
rx_teamone = re.compile(r"(?i)^\s*(.*)\s*$")
rx_person = re.compile(r"(?i) and |/| / |, | , |&| & | \+ |^both$|^none$") rx_person = re.compile(r"(?i) and |/| / |, | , |&| & | \+ |^both$|^none$")
rx_qm = re.compile( rx_qm = re.compile(
# r"(?i)^\s*QM(\d+)\s+(.+)\s+([\w\-\_]+)\.([\w\.\-]+)\s+(([\w\-]+)\.([\w\.\-]+)|\-)\s+(.+)$" # r"(?i)^\s*QM(\d+)\s+(.+)\s+([\w\-\_]+)\.([\w\.\-]+)\s+(([\w\-]+)\.([\w\.\-]+)|\-)\s+(.+)$"
@@ -579,6 +588,12 @@ class LoadingSurvex:
# we will have to attach them to the survexblock anyway, and then do a # we will have to attach them to the survexblock anyway, and then do a
# later check on whether they are valid when we get the date. # later check on whether they are valid when we get the date.
# big changes 24/2/2025 when Olly changed survex behaviour, and unilaterally eddited hundreds of
# survex files to match. So troggle has to change to match the revised, stricter syntax.
if not tm: # i.e. null person inthe *team
return # ignore: troggle does not need to know. Survex want to though.
self.currentteam.add(tm) # used in push/pop block code self.currentteam.add(tm) # used in push/pop block code
expo = survexblock.expedition # may be None if no *date yet expo = survexblock.expedition # may be None if no *date yet
@@ -588,12 +603,12 @@ class LoadingSurvex:
put_person_on_trip(survexblock, personexpedition, tm) put_person_on_trip(survexblock, personexpedition, tm)
elif known_foreigner(tm): # note, not using .lower() elif known_foreigner(tm): # note, not using .lower()
message = f"- *team {expo.year} '{tm}' known foreigner on *team {survexblock.survexfile.path} ({survexblock}) in '{line}'" message = f"- *team {expo.year} '{tm}' known foreigner on *team {survexblock.survexfile.path} ({survexblock}) in '{line=}'"
print(self.insp + message) print(self.insp + message)
# stash_data_issue(parser='survex', message=message, url=None, sb=(survexblock.survexfile.path)) # stash_data_issue(parser='survex', message=message, url=None, sb=(survexblock.survexfile.path))
else: else:
# we know the date and expo, but can't find the person # we know the date and expo, but can't find the person
message = f"! *team {expo.year} '{tm}' FAIL personexpedition lookup on *team {survexblock.survexfile.path} ({survexblock}) in '{line}'" message = f"! *team {expo.year} '{tm}' FAIL personexpedition lookup on *team {survexblock.survexfile.path} ({survexblock}) in '{line=}' {tm=}"
print(self.insp + message) print(self.insp + message)
stash_data_issue( stash_data_issue(
parser="survex", message=message, url=None, sb=(survexblock.survexfile.path) parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
@@ -611,41 +626,61 @@ class LoadingSurvex:
# parser="survex team", message=message, url=None, sb=(survexblock.survexfile.path) # parser="survex team", message=message, url=None, sb=(survexblock.survexfile.path)
# ) # )
mteammember = self.rx_teammem.match(line) # matches the role at the beginning # teamfix = r"(?i)(.*?)\s+" + roles + r"?(?:es|s)?$" -- (.*?) means a non-greedy capture
if not mteammember: if fixstyle := self.rx_teamfix.match(line): # matches the optional role at the the end of the string WALRUS
moldstyle = self.rx_teamold.match(line) # matches the role at the the end of the string tmlist = fixstyle.group(1).strip('\"') # remove quotes, if present
if moldstyle: for tm in self.rx_person.split(tmlist):
for tm in self.rx_person.split(moldstyle.group(1)): if tm.lower() =="":
if tm: # message = f"! *team {survexblock.survexfile.path} ({survexblock}) NONE PERSON '{line=}'"
record_team_member(tm, survexblock) # print(self.insp + message)
# seems to be working # stash_data_issue(
# msg = "! OLD tm='{}' line: '{}' ({}) {}".format(tm, line, survexblock, survexblock.survexfile.path) # parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
# print(msg, file=sys.stderr) # )
pass # does not add any information troggle is interested in
else: else:
message = f"! *team {survexblock.survexfile.path} ({survexblock}) Weird '{mteammember.group(1)}' oldstyle line: '{line}'" record_team_member(tm.strip('\"'), survexblock)
# else:
# message = f"! *team {survexblock.survexfile.path} ({survexblock}) Weird '{fixstyle.group(1)}' strictstyle {line=} {tm=}"
# print(self.insp + message)
# stash_data_issue(
# parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
# )
elif nullperson := self.rx_teamabs.match(line): # matches role but no person. Ignore these. WALRUS
return
elif line.startswith("unknown "):
message = f"! *team {survexblock.survexfile.path} ({survexblock}) role 'unknown' in wrong place '{line=}'"
print(self.insp + message) print(self.insp + message)
stash_data_issue( stash_data_issue(
parser="survex", message=message, url=None, sb=(survexblock.survexfile.path) parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
) )
record_team_member(line.replace("unknown ","").strip('\"'), survexblock)
elif no_role_person := self.rx_teamone.match(line):
nrp = no_role_person.group(1).strip('\"')
# message = f"! *team {survexblock.survexfile.path} ({survexblock}) person {nrp=} has no role '{line=}'"
# print(self.insp + message)
# stash_data_issue(
# parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
# )
record_team_member(nrp, survexblock)
else: else:
nullmember = self.rx_teamabs.match(line) # matches empty role line. Ignore these. message = f"! *team {survexblock.survexfile.path} ({survexblock}) Bad '{line=}'"
if not nullmember:
message = f"! *team {survexblock.survexfile.path} ({survexblock}) Bad line: '{line}'"
print(self.insp + message)
stash_data_issue(
parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
)
else:
for tm in self.rx_person.split(mteammember.group(2)):
if tm:
record_team_member(tm, survexblock)
else:
if mteammember.group(2).lower() not in ("none", "both"):
message = f"! Weird *team '{mteammember.group(2)}' newstyle line: '{line}' ({survexblock}) {survexblock.survexfile.path}"
print(self.insp + message) print(self.insp + message)
stash_data_issue( stash_data_issue(
parser="survex", message=message, url=None, sb=(survexblock.survexfile.path) parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
) )
# mteammember = self.rx_teammem.match(line) # matches the role at the beginning [deprecated after 24/2/2025]
# if not mteammember:
# else:
# for tm in self.rx_person.split(mteammember.group(2)):
# if tm:
# record_team_member(tm, survexblock)
# else:
# if mteammember.group(2).lower() not in ("none", "both"):
# message = f"! Weird *team '{mteammember.group(2)}' expostyle line: '{line}' ({survexblock}) {survexblock.survexfile.path}"
# print(self.insp + message)
# stash_data_issue(
# parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
# )
def LoadSurvexSet(self, survexblock, line): def LoadSurvexSet(self, survexblock, line):
"""survex *set can reset the character for space, decinmal point, field separator """survex *set can reset the character for space, decinmal point, field separator