summaryrefslogtreecommitdiffstats
path: root/parsers/survex.py
diff options
context:
space:
mode:
Diffstat (limited to 'parsers/survex.py')
-rw-r--r--parsers/survex.py34
1 files changed, 9 insertions, 25 deletions
diff --git a/parsers/survex.py b/parsers/survex.py
index 25b5f13..7ac8a5e 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -282,7 +282,7 @@ class LoadingSurvex():
print(insp+message)
models.DataIssue.objects.create(parser='survex', message=message)
- def LoadSurvexDataCmd(survexblock,args):
+ def LoadSurvexDataCmd(self,survexblock,args):
ls = args.lower().split()
stardata = { "type":ls[0] }
for i in range(0, len(ls)):
@@ -306,7 +306,6 @@ class LoadingSurvex():
print(' - Attempting cave match for %s' % path)
if path_match:
pos_cave = '%s-%s' % (path_match.group(1), path_match.group(2))
- # print(insp+pos_cave)
cave = models_caves.getCaveByReference(pos_cave)
if cave:
survexfile.cave = cave
@@ -343,7 +342,8 @@ class LoadingSurvex():
# ignore all comments except ;ref and ;QM and ;*include (for collated survex file)
refline = self.rx_ref.match(comment)
if refline:
- comment = comment.replace("ref","").strip()
+ #comment = comment.replace("ref","").strip()
+ comment = re.sub('(?i)\s*ref[.;]?',"",comment.strip())
self.LoadSurvexRef(survexblock, comment)
qmline = self.rx_qm.match(comment)
@@ -408,18 +408,12 @@ class LoadingSurvex():
cmd, args = mstar.groups()
cmd = cmd.lower()
if re.match("include$(?i)", cmd):
- 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 - ' + includepath))
- # 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:
+ cave = self.IdentifyCave(args)
+ if 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.save()
@@ -494,17 +488,7 @@ class LoadingSurvex():
elif cmd == "flags":
self.LoadSurvexFlags(args, cmd)
elif cmd == "data":
- ls = args.lower().split()
- 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
+ self.LoadSurvexDataCmd(survexblock, args)
elif cmd == "set" and re.match("names(?i)", args):
pass
elif re.match("date$(?i)", cmd):