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):
|
def __init__(self):
|
||||||
pass
|
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):
|
def LoadSurvexDate(self, survexblock, line):
|
||||||
# we should make this a date range for everything
|
# we should make this a date range for everything
|
||||||
if len(line) == 10:
|
if len(line) == 10:
|
||||||
@ -140,8 +173,6 @@ class LoadSurvex():
|
|||||||
assert self.rx_linelen.match(lclino) and lclino != "-", ls
|
assert self.rx_linelen.match(lclino) and lclino != "-", ls
|
||||||
survexleg.compass = float(lcompass)
|
survexleg.compass = float(lcompass)
|
||||||
survexleg.clino = float(lclino)
|
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.
|
# delete the object so that django autosaving doesn't save it.
|
||||||
survexleg = None
|
survexleg = None
|
||||||
|
|
||||||
@ -152,7 +183,6 @@ class LoadSurvex():
|
|||||||
self.survexlegsalllength += float(ls[itape])
|
self.survexlegsalllength += float(ls[itape])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print("! Length not added")
|
print("! Length not added")
|
||||||
# No need to save as we are measuring lengths only on parsing now.
|
|
||||||
|
|
||||||
|
|
||||||
def LoadSurvexLinePassage(self, survexblock, stardata, sline, comment):
|
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.
|
crashes on memory-constrained machines. Begin-end blocks may also be nested.
|
||||||
"""
|
"""
|
||||||
iblankbegins = 0
|
iblankbegins = 0
|
||||||
text = [ ]
|
|
||||||
stardata = self.stardatadefault
|
stardata = self.stardatadefault
|
||||||
teammembers = [ ]
|
|
||||||
insp =self.insp
|
insp =self.insp
|
||||||
blocklegs = self.survexlegsnumber
|
blocklegs = self.survexlegsnumber
|
||||||
|
|
||||||
@ -282,9 +310,9 @@ class LoadSurvex():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# detect the star ref command
|
# detect the star ref command
|
||||||
mstar = self.rx_starref.match(sline)
|
rstar = self.rx_starref.match(sline)
|
||||||
if mstar:
|
if rstar:
|
||||||
self.LoadSurvexRef(survexblock, mstar)
|
self.LoadSurvexRef(survexblock, rstar)
|
||||||
|
|
||||||
# detect the star command
|
# detect the star command
|
||||||
mstar = self.rx_star.match(sline)
|
mstar = self.rx_star.match(sline)
|
||||||
@ -295,7 +323,7 @@ class LoadSurvex():
|
|||||||
elif stardata["type"] == "passage":
|
elif stardata["type"] == "passage":
|
||||||
pass
|
pass
|
||||||
#self.LoadSurvexLinePassage(survexblock, stardata, sline, comment)
|
#self.LoadSurvexLinePassage(survexblock, stardata, sline, comment)
|
||||||
#Missing "station" in stardata.
|
#Missing "station" in stardata.
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# detect the star command
|
# detect the star command
|
||||||
@ -382,34 +410,10 @@ class LoadSurvex():
|
|||||||
survexblock.legsall = legsinblock
|
survexblock.legsall = legsinblock
|
||||||
survexblock.save()
|
survexblock.save()
|
||||||
return
|
return
|
||||||
|
elif cmd == "flags":
|
||||||
elif re.match("date$(?i)", cmd):
|
# Here we could set on/off 'splay', 'not splay', 'surface', 'not surface', or 'duplicate'
|
||||||
self.LoadSurvexDate(survexblock, line)
|
# but this data is only used for sense-checking not to actually calculate anything important
|
||||||
|
|
||||||
elif re.match("team$(?i)", cmd):
|
|
||||||
pass
|
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":
|
elif cmd == "data":
|
||||||
ls = line.lower().split()
|
ls = line.lower().split()
|
||||||
stardata = { "type":ls[0] }
|
stardata = { "type":ls[0] }
|
||||||
@ -422,33 +426,14 @@ class LoadSurvex():
|
|||||||
stardata = self.stardatadefault
|
stardata = self.stardatadefault
|
||||||
else:
|
else:
|
||||||
assert ls[0] == "passage", line
|
assert ls[0] == "passage", line
|
||||||
|
|
||||||
elif cmd == "equate":
|
|
||||||
#LoadSurvexEquate(survexblock, line)
|
|
||||||
pass
|
|
||||||
|
|
||||||
elif cmd == "set" and re.match("names(?i)", line):
|
elif cmd == "set" and re.match("names(?i)", line):
|
||||||
pass
|
pass
|
||||||
elif cmd == "flags":
|
elif re.match("date$(?i)", cmd):
|
||||||
# Here we could set on/off 'splay', 'not splay', 'surface', 'not surface', or 'duplicate'
|
self.LoadSurvexDate(survexblock, line)
|
||||||
# but this data is only used for sense-checking not to actually calculate anything important
|
elif re.match("team$(?i)", cmd):
|
||||||
pass
|
self.LoadSurvexTeam(survexblock, line)
|
||||||
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
|
|
||||||
else:
|
else:
|
||||||
if cmd not in ["include", "data", "flags", "title", "set", "ref"]:
|
self.LoadSurvexIgnore(survexblock, line, cmd)
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
def FindAndLoadAllSurvex(survexblockroot, survexfileroot):
|
def FindAndLoadAllSurvex(survexblockroot, survexfileroot):
|
||||||
@ -479,14 +464,12 @@ def FindAndLoadAllSurvex(survexblockroot, survexfileroot):
|
|||||||
def LoadAllSurvexBlocks():
|
def LoadAllSurvexBlocks():
|
||||||
|
|
||||||
print(' - Flushing All Survex Blocks...')
|
print(' - Flushing All Survex Blocks...')
|
||||||
|
|
||||||
models_survex.SurvexBlock.objects.all().delete()
|
models_survex.SurvexBlock.objects.all().delete()
|
||||||
models_survex.SurvexFile.objects.all().delete()
|
models_survex.SurvexFile.objects.all().delete()
|
||||||
models_survex.SurvexDirectory.objects.all().delete()
|
models_survex.SurvexDirectory.objects.all().delete()
|
||||||
models_survex.SurvexPersonRole.objects.all().delete()
|
models_survex.SurvexPersonRole.objects.all().delete()
|
||||||
models_survex.SurvexStation.objects.all().delete()
|
models_survex.SurvexStation.objects.all().delete()
|
||||||
|
print(" - survex Data Issues flushed")
|
||||||
print(" - Data flushed")
|
|
||||||
models.DataIssue.objects.filter(parser='survex').delete()
|
models.DataIssue.objects.filter(parser='survex').delete()
|
||||||
|
|
||||||
survexfileroot = models_survex.SurvexFile(path=settings.SURVEX_TOPNAME, cave=None)
|
survexfileroot = models_survex.SurvexFile(path=settings.SURVEX_TOPNAME, cave=None)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user