diff options
Diffstat (limited to 'parsers/survex.py')
-rw-r--r-- | parsers/survex.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/parsers/survex.py b/parsers/survex.py index 508ab26..aebcd31 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -25,6 +25,8 @@ rx_line_length = re.compile(r"[\d\-+.]+$") survexlegsalllength = 0.0 survexlegsnumber = 0 survexblockroot = None +ROOTBLOCK = "rootblock" + def LoadSurvexLineLeg(survexblock, stardata, sline, comment, cave): global survexlegsalllength @@ -460,7 +462,7 @@ def LoadAllSurvexBlocks(): #Load all # this is the first so id=1 - survexblockroot = models_survex.SurvexBlock(name="rootblock", survexpath="", cave=None, survexfile=survexfile, + survexblockroot = models_survex.SurvexBlock(name=ROOTBLOCK, survexpath="", cave=None, survexfile=survexfile, legsall=0, legssplay=0, legssurfc=0, totalleglength=0.0) survexblockroot.save() fin = survexfile.OpenFile() @@ -556,7 +558,16 @@ def LoadPos(): posfile = open("%s.pos" % (topdata)) posfile.readline() #Drop header - survexblockroot = models_survex.SurvexBlock.objects.get(id=1) + try: + survexblockroot = models_survex.SurvexBlock.objects.get(name=ROOTBLOCK) + except: + try: + survexblockroot = models_survex.SurvexBlock.objects.get(id=1) + except: + message = ' ! FAILED to find root SurvexBlock' + print(message) + models.DataIssue.objects.create(parser='survex', message=message) + raise for line in posfile.readlines(): r = poslineregex.match(line) if r: |