forked from expo/troggle
refactor team and ignore sections
This commit is contained in:
parent
3645c98685
commit
664c18ebbe
@ -68,6 +68,39 @@ class LoadSurvex():
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def LoadSurvexIgnore(self, survexblock, line, cmd):
|
||||
if cmd == "title":
|
||||
pass # unused in troggle today - but will become text list on SurvexBlock
|
||||
elif cmd == "require":
|
||||
pass # should we check survex version available for processing?
|
||||
elif cmd in ["equate", "fix", "alias", "calibrate", "cs","entrance", "export", "case",
|
||||
"declination", "infer","instrument", "sd", "units"]:
|
||||
pass # we ignore all these, which is fine.
|
||||
else:
|
||||
if cmd in ["include", "data", "flags", "title", "set", "ref"]:
|
||||
message = "! Unparsed [*{}]: '{}' {}".format(cmd, line, survexblock.survexfile.path)
|
||||
print((self.insp+message))
|
||||
models.DataIssue.objects.create(parser='survex', message=message)
|
||||
else:
|
||||
message = "! Bad svx command: [*{}] {} ({}) {}".format(cmd, line, survexblock, survexblock.survexfile.path)
|
||||
print((self.insp+message))
|
||||
models.DataIssue.objects.create(parser='survex', message=message)
|
||||
|
||||
def LoadSurvexTeam(self, survexblock, line):
|
||||
teammembers = [ ]
|
||||
mteammember = self.rx_team.match(line)
|
||||
if mteammember:
|
||||
for tm in self.rx_person.split(mteammember.group(2)):
|
||||
if tm:
|
||||
personexpedition = survexblock.expedition and GetPersonExpeditionNameLookup(survexblock.expedition).get(tm.lower())
|
||||
if (personexpedition, tm) not in teammembers:
|
||||
teammembers.append((personexpedition, tm))
|
||||
personrole = models_survex.SurvexPersonRole(survexblock=survexblock, nrole=mteammember.group(1).lower(), personexpedition=personexpedition, personname=tm)
|
||||
personrole.expeditionday = survexblock.expeditionday
|
||||
if personexpedition:
|
||||
personrole.person=personexpedition.person
|
||||
personrole.save()
|
||||
|
||||
def LoadSurvexDate(self, survexblock, line):
|
||||
# we should make this a date range for everything
|
||||
if len(line) == 10:
|
||||
@ -140,8 +173,6 @@ class LoadSurvex():
|
||||
assert self.rx_linelen.match(lclino) and lclino != "-", ls
|
||||
survexleg.compass = float(lcompass)
|
||||
survexleg.clino = float(lclino)
|
||||
|
||||
# No need to save as we are measuring lengths only on parsing now.
|
||||
# delete the object so that django autosaving doesn't save it.
|
||||
survexleg = None
|
||||
|
||||
@ -152,7 +183,6 @@ class LoadSurvex():
|
||||
self.survexlegsalllength += float(ls[itape])
|
||||
except ValueError:
|
||||
print("! Length not added")
|
||||
# No need to save as we are measuring lengths only on parsing now.
|
||||
|
||||
|
||||
def LoadSurvexLinePassage(self, survexblock, stardata, sline, comment):
|
||||
@ -239,9 +269,7 @@ class LoadSurvex():
|
||||
crashes on memory-constrained machines. Begin-end blocks may also be nested.
|
||||
"""
|
||||
iblankbegins = 0
|
||||
text = [ ]
|
||||
stardata = self.stardatadefault
|
||||
teammembers = [ ]
|
||||
insp =self.insp
|
||||
blocklegs = self.survexlegsnumber
|
||||
|
||||
@ -282,9 +310,9 @@ class LoadSurvex():
|
||||
continue
|
||||
|
||||
# detect the star ref command
|
||||
mstar = self.rx_starref.match(sline)
|
||||
if mstar:
|
||||
self.LoadSurvexRef(survexblock, mstar)
|
||||
rstar = self.rx_starref.match(sline)
|
||||
if rstar:
|
||||
self.LoadSurvexRef(survexblock, rstar)
|
||||
|
||||
# detect the star command
|
||||
mstar = self.rx_star.match(sline)
|
||||
@ -295,7 +323,7 @@ class LoadSurvex():
|
||||
elif stardata["type"] == "passage":
|
||||
pass
|
||||
#self.LoadSurvexLinePassage(survexblock, stardata, sline, comment)
|
||||
#Missing "station" in stardata.
|
||||
#Missing "station" in stardata.
|
||||
continue
|
||||
|
||||
# detect the star command
|
||||
@ -382,34 +410,10 @@ class LoadSurvex():
|
||||
survexblock.legsall = legsinblock
|
||||
survexblock.save()
|
||||
return
|
||||
|
||||
elif re.match("date$(?i)", cmd):
|
||||
self.LoadSurvexDate(survexblock, line)
|
||||
|
||||
elif re.match("team$(?i)", cmd):
|
||||
elif cmd == "flags":
|
||||
# Here we could set on/off 'splay', 'not splay', 'surface', 'not surface', or 'duplicate'
|
||||
# but this data is only used for sense-checking not to actually calculate anything important
|
||||
pass
|
||||
# print(insp+' - Team found: ')
|
||||
mteammember = self.rx_team.match(line)
|
||||
if mteammember:
|
||||
for tm in self.rx_person.split(mteammember.group(2)):
|
||||
if tm:
|
||||
personexpedition = survexblock.expedition and GetPersonExpeditionNameLookup(survexblock.expedition).get(tm.lower())
|
||||
if (personexpedition, tm) not in teammembers:
|
||||
teammembers.append((personexpedition, tm))
|
||||
personrole = models_survex.SurvexPersonRole(survexblock=survexblock, nrole=mteammember.group(1).lower(), personexpedition=personexpedition, personname=tm)
|
||||
personrole.expeditionday = survexblock.expeditionday
|
||||
if personexpedition:
|
||||
personrole.person=personexpedition.person
|
||||
personrole.save()
|
||||
|
||||
elif cmd == "title":
|
||||
# unused in troggle today - but will become text list on SurvexBlock
|
||||
pass
|
||||
|
||||
elif cmd == "require":
|
||||
# should we check survex version available for processing?
|
||||
pass
|
||||
|
||||
elif cmd == "data":
|
||||
ls = line.lower().split()
|
||||
stardata = { "type":ls[0] }
|
||||
@ -422,33 +426,14 @@ class LoadSurvex():
|
||||
stardata = self.stardatadefault
|
||||
else:
|
||||
assert ls[0] == "passage", line
|
||||
|
||||
elif cmd == "equate":
|
||||
#LoadSurvexEquate(survexblock, line)
|
||||
pass
|
||||
|
||||
elif cmd == "set" and re.match("names(?i)", line):
|
||||
pass
|
||||
elif cmd == "flags":
|
||||
# Here we could set on/off 'splay', 'not splay', 'surface', 'not surface', or 'duplicate'
|
||||
# but this data is only used for sense-checking not to actually calculate anything important
|
||||
pass
|
||||
elif cmd == "fix":
|
||||
# troggle does not use survex stations except for entrances which are loaded elsewhere
|
||||
pass
|
||||
elif cmd in ["alias", "calibrate", "cs","entrance", "export", "case",
|
||||
"declination", "infer","instrument", "sd", "units"]:
|
||||
# we ignore all these, which is fine.
|
||||
pass
|
||||
elif re.match("date$(?i)", cmd):
|
||||
self.LoadSurvexDate(survexblock, line)
|
||||
elif re.match("team$(?i)", cmd):
|
||||
self.LoadSurvexTeam(survexblock, line)
|
||||
else:
|
||||
if cmd not in ["include", "data", "flags", "title", "set", "ref"]:
|
||||
message = "! Bad svx command: [*{}] {} ({}) {}".format(cmd, line, survexblock, survexblock.survexfile.path)
|
||||
print((insp+message))
|
||||
models.DataIssue.objects.create(parser='survex', message=message)
|
||||
else:
|
||||
message = "! Unparsed [*{}]: '{}' {}".format(cmd, line, survexblock.survexfile.path)
|
||||
print((insp+message))
|
||||
models.DataIssue.objects.create(parser='survex', message=message)
|
||||
self.LoadSurvexIgnore(survexblock, line, cmd)
|
||||
|
||||
|
||||
def FindAndLoadAllSurvex(survexblockroot, survexfileroot):
|
||||
@ -479,14 +464,12 @@ def FindAndLoadAllSurvex(survexblockroot, survexfileroot):
|
||||
def LoadAllSurvexBlocks():
|
||||
|
||||
print(' - Flushing All Survex Blocks...')
|
||||
|
||||
models_survex.SurvexBlock.objects.all().delete()
|
||||
models_survex.SurvexFile.objects.all().delete()
|
||||
models_survex.SurvexDirectory.objects.all().delete()
|
||||
models_survex.SurvexPersonRole.objects.all().delete()
|
||||
models_survex.SurvexStation.objects.all().delete()
|
||||
|
||||
print(" - Data flushed")
|
||||
print(" - survex Data Issues flushed")
|
||||
models.DataIssue.objects.filter(parser='survex').delete()
|
||||
|
||||
survexfileroot = models_survex.SurvexFile(path=settings.SURVEX_TOPNAME, cave=None)
|
||||
|
Loading…
Reference in New Issue
Block a user