summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parsers/survex.py30
1 files changed, 18 insertions, 12 deletions
diff --git a/parsers/survex.py b/parsers/survex.py
index d3db234..ba90a84 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -300,7 +300,6 @@ class LoadingSurvex:
rx_commteam = re.compile(r"(?i)\s*(Messteam|Zeichner)\s*[:]?(.*)")
rx_quotedtitle = re.compile(r'(?i)^"(.*)"$')
- rx_fixline = re.compile(r"(?i)^\s*([\w\d_\.\-]+)\s+(?:reference)?\s*([\d\.]*)\s+([\d\.]*)\s+([\d\.]*)(.*)$")
@@ -615,19 +614,25 @@ class LoadingSurvex:
def LoadSurvexFix(self, survexblock, line):
"""*fix is a station geolocation, units depend on a previous *cs setting
NOTE 'line' is not the full line, it is 'arg' and the comments have been stripped !
+ SO we have to recognise the '*fix' too
"""
- # fixline = re.match("(?i)\s*([\w\d_\.\-]+)\s+(?:reference)?\s*([\d\.]*)\s+([\d\.]*)\s+([\d\.]*)\s*(.*)$", line)
- fixline = self.rx_fixline.match(line)
+ # *fix|36|reference|36359.40|82216.08|2000.00\n
+ rx_fixline = re.compile(r"(?i)^\s*[*]fix\s+([\w\d_\.\-]+)\s+(?:reference)?\s*([\d\.]*)\s+([\d\.]*)\s+([\d\.]*).*$")
+
+ line = line.replace("\n","")
+ #fixline = self.rx_fixline.match(line)
+ fixline = rx_fixline.match(line)
if not fixline:
- message = f'BAD fix regex {line.replace(" ","|")} {survexblock.survexfile.path}:{survexblock}'
+ display = line.replace(" ","|")
+ message = f'BAD fix regex {display}++{survexblock.parent}:{survexblock}@{survexblock.survexfile}'
print(self.insp + message)
stash_data_issue(parser="survex", message=message)
else:
fixdata = fixline.groups()
#print(fixline.group(1), fixline.group(5))
- print(f"'{line}'")
+ #print(f"'{line}'")
name = fixdata[0]
- if name in self.fixes:
+ if (survexblock, name) in self.fixes:
message = f"! Duplicate *FIX: id '{line}' ({survexblock}) {survexblock.survexfile.path}"
print(self.insp + message)
stash_data_issue(parser="survex", message=message)
@@ -636,10 +641,10 @@ class LoadingSurvex:
return
try:
- #_, _, alt, *rest = (fixdata + [None]*4)[:4]
- name, _, _, alt, comment = fixdata
+ #_, _, alt, *rest = (fixdata + [None]*5)[:5]
+ name, _, _, alt, comment = (list(fixdata) + [None]*5)[:5]
fixid = str(survexblock.id)+ ":"+ name
- self.fixes[fixid] = (survexblock, alt, comment)
+ self.fixes[fixid] = (survexblock, name)
message = f"{name}, {fixdata=}, last:{fixline.groups()[-1]}"
print(self.insp + message)
except Exception as e:
@@ -1718,7 +1723,7 @@ class LoadingSurvex:
if oldflags["skiplegs"] != self.flagsstar["skiplegs"]:
print(f" # POP 'any' flag now:'{self.flagsstar['skiplegs']}' was:{oldflags['skiplegs']} ")
- def starstatement(star):
+ def starstatement(star, fullline):
"""Interprets a survex comamnd where * is the first character on the line, e.g. *begin"""
nonlocal survexblock
nonlocal blkid
@@ -1837,7 +1842,7 @@ class LoadingSurvex:
elif self.rx_date.match(cmd):
self.LoadSurvexDate(survexblock, args)
elif self.rx_fix.match(cmd):
- self.LoadSurvexFix(survexblock, args)
+ self.LoadSurvexFix(survexblock, fullline) # but we want the comment on this line
elif self.rx_units.match(cmd):
self.LoadSurvexUnits(survexblock, args)
elif self.rx_team.match(cmd):
@@ -1863,6 +1868,7 @@ class LoadingSurvex:
self.lineno += 1
sline, comment = self.rx_comment.match(svxline).groups()
if comment:
+ # ; at beginning of line
# this catches the ;|*include NEWFILE and ;|*edulcni ENDOFFILE lines too
self.LoadSurvexComment(survexblock, comment)
else:
@@ -1885,7 +1891,7 @@ class LoadingSurvex:
star = self.rx_star.match(sline)
if star:
# yes we are reading a *command
- starstatement(star)
+ starstatement(star, svxline)
else: # not a *cmd so we are reading data OR a ";" rx_comment failed. We hope.
self.LoadSurvexLeg(survexblock, sline, comment, svxline)