mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-17 22:27:04 +00:00
working regex
This commit is contained in:
@@ -300,7 +300,6 @@ class LoadingSurvex:
|
|||||||
rx_commteam = re.compile(r"(?i)\s*(Messteam|Zeichner)\s*[:]?(.*)")
|
rx_commteam = re.compile(r"(?i)\s*(Messteam|Zeichner)\s*[:]?(.*)")
|
||||||
rx_quotedtitle = re.compile(r'(?i)^"(.*)"$')
|
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):
|
def LoadSurvexFix(self, survexblock, line):
|
||||||
"""*fix is a station geolocation, units depend on a previous *cs setting
|
"""*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 !
|
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)
|
# *fix|36|reference|36359.40|82216.08|2000.00\n
|
||||||
fixline = self.rx_fixline.match(line)
|
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:
|
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)
|
print(self.insp + message)
|
||||||
stash_data_issue(parser="survex", message=message)
|
stash_data_issue(parser="survex", message=message)
|
||||||
else:
|
else:
|
||||||
fixdata = fixline.groups()
|
fixdata = fixline.groups()
|
||||||
#print(fixline.group(1), fixline.group(5))
|
#print(fixline.group(1), fixline.group(5))
|
||||||
print(f"'{line}'")
|
#print(f"'{line}'")
|
||||||
name = fixdata[0]
|
name = fixdata[0]
|
||||||
if name in self.fixes:
|
if (survexblock, name) in self.fixes:
|
||||||
message = f"! Duplicate *FIX: id '{line}' ({survexblock}) {survexblock.survexfile.path}"
|
message = f"! Duplicate *FIX: id '{line}' ({survexblock}) {survexblock.survexfile.path}"
|
||||||
print(self.insp + message)
|
print(self.insp + message)
|
||||||
stash_data_issue(parser="survex", message=message)
|
stash_data_issue(parser="survex", message=message)
|
||||||
@@ -636,10 +641,10 @@ class LoadingSurvex:
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
#_, _, alt, *rest = (fixdata + [None]*4)[:4]
|
#_, _, alt, *rest = (fixdata + [None]*5)[:5]
|
||||||
name, _, _, alt, comment = fixdata
|
name, _, _, alt, comment = (list(fixdata) + [None]*5)[:5]
|
||||||
fixid = str(survexblock.id)+ ":"+ name
|
fixid = str(survexblock.id)+ ":"+ name
|
||||||
self.fixes[fixid] = (survexblock, alt, comment)
|
self.fixes[fixid] = (survexblock, name)
|
||||||
message = f"{name}, {fixdata=}, last:{fixline.groups()[-1]}"
|
message = f"{name}, {fixdata=}, last:{fixline.groups()[-1]}"
|
||||||
print(self.insp + message)
|
print(self.insp + message)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -1718,7 +1723,7 @@ class LoadingSurvex:
|
|||||||
if oldflags["skiplegs"] != self.flagsstar["skiplegs"]:
|
if oldflags["skiplegs"] != self.flagsstar["skiplegs"]:
|
||||||
print(f" # POP 'any' flag now:'{self.flagsstar['skiplegs']}' was:{oldflags['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"""
|
"""Interprets a survex comamnd where * is the first character on the line, e.g. *begin"""
|
||||||
nonlocal survexblock
|
nonlocal survexblock
|
||||||
nonlocal blkid
|
nonlocal blkid
|
||||||
@@ -1837,7 +1842,7 @@ class LoadingSurvex:
|
|||||||
elif self.rx_date.match(cmd):
|
elif self.rx_date.match(cmd):
|
||||||
self.LoadSurvexDate(survexblock, args)
|
self.LoadSurvexDate(survexblock, args)
|
||||||
elif self.rx_fix.match(cmd):
|
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):
|
elif self.rx_units.match(cmd):
|
||||||
self.LoadSurvexUnits(survexblock, args)
|
self.LoadSurvexUnits(survexblock, args)
|
||||||
elif self.rx_team.match(cmd):
|
elif self.rx_team.match(cmd):
|
||||||
@@ -1863,6 +1868,7 @@ class LoadingSurvex:
|
|||||||
self.lineno += 1
|
self.lineno += 1
|
||||||
sline, comment = self.rx_comment.match(svxline).groups()
|
sline, comment = self.rx_comment.match(svxline).groups()
|
||||||
if comment:
|
if comment:
|
||||||
|
# ; at beginning of line
|
||||||
# this catches the ;|*include NEWFILE and ;|*edulcni ENDOFFILE lines too
|
# this catches the ;|*include NEWFILE and ;|*edulcni ENDOFFILE lines too
|
||||||
self.LoadSurvexComment(survexblock, comment)
|
self.LoadSurvexComment(survexblock, comment)
|
||||||
else:
|
else:
|
||||||
@@ -1885,7 +1891,7 @@ class LoadingSurvex:
|
|||||||
star = self.rx_star.match(sline)
|
star = self.rx_star.match(sline)
|
||||||
if star:
|
if star:
|
||||||
# yes we are reading a *command
|
# 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.
|
else: # not a *cmd so we are reading data OR a ";" rx_comment failed. We hope.
|
||||||
self.LoadSurvexLeg(survexblock, sline, comment, svxline)
|
self.LoadSurvexLeg(survexblock, sline, comment, svxline)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user