forked from expo/troggle
compiling more regexes
This commit is contained in:
parent
0d9d307490
commit
03fa5f5548
@ -201,8 +201,12 @@ class LoadingSurvex:
|
||||
# python regex flags (?i) means case-insentitive, (?s) means . matches newline too
|
||||
# see https://docs.python.org/3/library/re.html
|
||||
rx_begin = re.compile(r"(?i)begin")
|
||||
rx_begin2 = re.compile("(?i)begin$")
|
||||
|
||||
rx_end = re.compile(r"(?i)end$")
|
||||
rx_end2 = re.compile("(?i)end$")
|
||||
rx_title = re.compile(r"(?i)title$")
|
||||
rx_title2 = re.compile("(?i)title$")
|
||||
rx_ref = re.compile(r"(?i)ref$")
|
||||
rx_data = re.compile(r"(?i)data$")
|
||||
rx_flags = re.compile(r"(?i)flags$")
|
||||
@ -263,7 +267,7 @@ class LoadingSurvex:
|
||||
unitsstack = []
|
||||
legsnumberstack = []
|
||||
slengthstack = []
|
||||
personexpedstack = []
|
||||
teamexpedstack = []
|
||||
stackbegin = []
|
||||
flagsstack = []
|
||||
datastack = []
|
||||
@ -293,7 +297,7 @@ class LoadingSurvex:
|
||||
currentsurvexfile = None
|
||||
currentcave = None
|
||||
caverndate = None
|
||||
currentpersonexped = []
|
||||
currentteamexped = []
|
||||
pending = []
|
||||
|
||||
def __init__(self):
|
||||
@ -362,7 +366,7 @@ class LoadingSurvex:
|
||||
personexpedition = GetPersonExpeditionNameLookup(expo).get(tm.lower())
|
||||
if personexpedition:
|
||||
put_person_on_trip(survexblock, personexpedition, tm)
|
||||
self.currentpersonexped.append(personexpedition) # used in push/pop block code
|
||||
self.currentteamexped.append(personexpedition) # used in push/pop block code
|
||||
elif known_foreigner(tm): # note, not using .lower()
|
||||
message = f"- *team {expo.year} '{tm}' known foreigner on *team {survexblock.survexfile.path} ({survexblock}) in '{line}'"
|
||||
print(self.insp + message)
|
||||
@ -519,7 +523,7 @@ class LoadingSurvex:
|
||||
pe = GetPersonExpeditionNameLookup(expo).get(tm.lower())
|
||||
if pe:
|
||||
put_person_on_trip(survexblock, pe, tm)
|
||||
self.currentpersonexped.append(pe)
|
||||
self.currentteamexped.append(pe)
|
||||
else:
|
||||
message = f"! *team {year} '{tm}' FAIL personexpedition lookup on *date {survexblock.survexfile.path} ({survexblock}) "
|
||||
print(self.insp + message)
|
||||
@ -546,7 +550,7 @@ class LoadingSurvex:
|
||||
pr.personexpedition = pe
|
||||
pr.person = pr.personexpedition.person
|
||||
pr.save()
|
||||
self.currentpersonexped.append(pe) # used in push/pop block code
|
||||
self.currentteamexped.append(pe) # used in push/pop block code
|
||||
elif known_foreigner(pr.personname): # note, not using .lower()
|
||||
message = f"- *team {expo.year} '{pr.personname}' known foreigner on *date {survexblock.survexfile.path} ({survexblock}) in '{line}'"
|
||||
print(self.insp + message)
|
||||
@ -1411,13 +1415,13 @@ class LoadingSurvex:
|
||||
self.unitsstack.append((self.units, self.unitsfactor))
|
||||
self.legsnumberstack.append(self.legsnumber)
|
||||
self.slengthstack.append(self.slength)
|
||||
self.personexpedstack.append(self.currentpersonexped) # just one person?!
|
||||
self.teamexpedstack.append(self.currentteamexped) # just one person?!
|
||||
pushblock()
|
||||
# PUSH state ++++++++++++++
|
||||
self.legsnumber = 0
|
||||
self.slength = 0.0
|
||||
self.units = "metres"
|
||||
self.currentpersonexped = []
|
||||
self.currentteamexped = []
|
||||
printbegin()
|
||||
newsurvexblock = SurvexBlock(
|
||||
name=blkid,
|
||||
@ -1456,7 +1460,7 @@ class LoadingSurvex:
|
||||
raise
|
||||
# POP state ++++++++++++++
|
||||
popblock()
|
||||
self.currentpersonexped = self.personexpedstack.pop() # just one person?!
|
||||
self.currentteamexped = self.teamexpedstack.pop() # just one person?!
|
||||
self.legsnumber = self.legsnumberstack.pop()
|
||||
self.units, self.unitsfactor = self.unitsstack.pop()
|
||||
self.slength = self.slengthstack.pop()
|
||||
@ -1617,7 +1621,8 @@ class LoadingSurvex:
|
||||
print(message)
|
||||
print(message, file=sys.stderr)
|
||||
stash_data_issue(parser="survex", message=message, url=None, sb=(path))
|
||||
elif re.match("(?i)begin$", cmd):
|
||||
elif self.rx_begin2.match(cmd):
|
||||
#elif re.match("(?i)begin$", cmd):
|
||||
self.depthbegin += 1
|
||||
depth = " " * self.depthbegin
|
||||
if args:
|
||||
@ -1627,7 +1632,8 @@ class LoadingSurvex:
|
||||
self.stackbegin.append(pushargs.lower())
|
||||
flinear.write(f" {self.depthbegin:2} {depth} *begin {args}\n")
|
||||
pass
|
||||
elif re.match("(?i)end$", cmd):
|
||||
elif self.rx_end2.match(cmd):
|
||||
# elif re.match("(?i)end$", cmd):
|
||||
depth = " " * self.depthbegin
|
||||
flinear.write(f" {self.depthbegin:2} {depth} *end {args}\n")
|
||||
if not args:
|
||||
@ -1644,7 +1650,8 @@ class LoadingSurvex:
|
||||
|
||||
self.depthbegin -= 1
|
||||
pass
|
||||
elif re.match("(?i)title$", cmd):
|
||||
elif self.rx_title2.match(cmd):
|
||||
# elif re.match("(?i)title$", cmd):
|
||||
depth = " " * self.depthbegin
|
||||
flinear.write(f" {self.depthbegin:2} {depth} *title {args}\n")
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user