forked from expo/troggle
working and refactored
This commit is contained in:
parent
467baec7da
commit
899ba13df4
@ -282,7 +282,7 @@ class LoadingSurvex():
|
|||||||
print(insp+message)
|
print(insp+message)
|
||||||
models.DataIssue.objects.create(parser='survex', message=message)
|
models.DataIssue.objects.create(parser='survex', message=message)
|
||||||
|
|
||||||
def LoadSurvexDataCmd(survexblock,args):
|
def LoadSurvexDataCmd(self,survexblock,args):
|
||||||
ls = args.lower().split()
|
ls = args.lower().split()
|
||||||
stardata = { "type":ls[0] }
|
stardata = { "type":ls[0] }
|
||||||
for i in range(0, len(ls)):
|
for i in range(0, len(ls)):
|
||||||
@ -306,7 +306,6 @@ class LoadingSurvex():
|
|||||||
print(' - Attempting cave match for %s' % path)
|
print(' - Attempting cave match for %s' % path)
|
||||||
if path_match:
|
if path_match:
|
||||||
pos_cave = '%s-%s' % (path_match.group(1), path_match.group(2))
|
pos_cave = '%s-%s' % (path_match.group(1), path_match.group(2))
|
||||||
# print(insp+pos_cave)
|
|
||||||
cave = models_caves.getCaveByReference(pos_cave)
|
cave = models_caves.getCaveByReference(pos_cave)
|
||||||
if cave:
|
if cave:
|
||||||
survexfile.cave = cave
|
survexfile.cave = cave
|
||||||
@ -343,7 +342,8 @@ class LoadingSurvex():
|
|||||||
# ignore all comments except ;ref and ;QM and ;*include (for collated survex file)
|
# ignore all comments except ;ref and ;QM and ;*include (for collated survex file)
|
||||||
refline = self.rx_ref.match(comment)
|
refline = self.rx_ref.match(comment)
|
||||||
if refline:
|
if refline:
|
||||||
comment = comment.replace("ref","").strip()
|
#comment = comment.replace("ref","").strip()
|
||||||
|
comment = re.sub('(?i)\s*ref[.;]?',"",comment.strip())
|
||||||
self.LoadSurvexRef(survexblock, comment)
|
self.LoadSurvexRef(survexblock, comment)
|
||||||
|
|
||||||
qmline = self.rx_qm.match(comment)
|
qmline = self.rx_qm.match(comment)
|
||||||
@ -408,18 +408,12 @@ class LoadingSurvex():
|
|||||||
cmd, args = mstar.groups()
|
cmd, args = mstar.groups()
|
||||||
cmd = cmd.lower()
|
cmd = cmd.lower()
|
||||||
if re.match("include$(?i)", cmd):
|
if re.match("include$(?i)", cmd):
|
||||||
includepath = os.path.normpath(os.path.join(os.path.split(survexfile.path)[0], re.sub(r"\.svx$", "", args)))
|
cave = self.IdentifyCave(args)
|
||||||
print((insp+' - INCLUDE-go path found, including - ' + includepath))
|
if cave:
|
||||||
# Try to find the cave in the DB. if not, use the string as before
|
|
||||||
path_match = re.search(r"caves-(\d\d\d\d)/(\d+|\d\d\d\d-?\w+-\d+)/", includepath)
|
|
||||||
if path_match:
|
|
||||||
pos_cave = '%s-%s' % (path_match.group(1), path_match.group(2))
|
|
||||||
print((insp+' - Match in DB (i) for cave {}.'.format(pos_cave)))
|
|
||||||
cave = models_caves.getCaveByReference(pos_cave)
|
|
||||||
if cave:
|
|
||||||
survexfile.cave = cave
|
survexfile.cave = cave
|
||||||
else:
|
|
||||||
print((insp+' - NO Match in DB (i) for a cave for {}'.format(includepath)))
|
includepath = os.path.normpath(os.path.join(os.path.split(survexfile.path)[0], re.sub(r"\.svx$", "", args)))
|
||||||
|
print((insp+' - INCLUDE-go path found, including - ' + args))
|
||||||
|
|
||||||
includesurvexfile = models_survex.SurvexFile(path=includepath)
|
includesurvexfile = models_survex.SurvexFile(path=includepath)
|
||||||
includesurvexfile.save()
|
includesurvexfile.save()
|
||||||
@ -494,17 +488,7 @@ class LoadingSurvex():
|
|||||||
elif cmd == "flags":
|
elif cmd == "flags":
|
||||||
self.LoadSurvexFlags(args, cmd)
|
self.LoadSurvexFlags(args, cmd)
|
||||||
elif cmd == "data":
|
elif cmd == "data":
|
||||||
ls = args.lower().split()
|
self.LoadSurvexDataCmd(survexblock, args)
|
||||||
stardata = { "type":ls[0] }
|
|
||||||
for i in range(0, len(ls)):
|
|
||||||
stardata[self.stardataparamconvert.get(ls[i], ls[i])] = i - 1
|
|
||||||
self.stardata = stardata
|
|
||||||
if ls[0] in ["normal", "cartesian", "nosurvey"]:
|
|
||||||
assert (("from" in stardata and "to" in stardata) or "station" in stardata), args
|
|
||||||
elif ls[0] == "default":
|
|
||||||
stardata = self.stardatadefault
|
|
||||||
else:
|
|
||||||
assert ls[0] == "passage", args
|
|
||||||
elif cmd == "set" and re.match("names(?i)", args):
|
elif cmd == "set" and re.match("names(?i)", args):
|
||||||
pass
|
pass
|
||||||
elif re.match("date$(?i)", cmd):
|
elif re.match("date$(?i)", cmd):
|
||||||
|
Loading…
Reference in New Issue
Block a user