diff options
Diffstat (limited to 'parsers/survex.py')
-rw-r--r-- | parsers/survex.py | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/parsers/survex.py b/parsers/survex.py index 38cae62..907b183 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -33,27 +33,27 @@ def LoadSurvexLineLeg(survexblock, stardata, sline, comment, cave): try: survexleg.tape = float(ls[stardata["tape"]]) except ValueError: - print("! Tape misread in", survexblock.survexfile.path) - print(" Stardata:", stardata) - print(" Line:", ls) + print(("! Tape misread in", survexblock.survexfile.path)) + print((" Stardata:", stardata)) + print((" Line:", ls)) message = ' ! Value Error: Tape misread in line %s in %s' % (ls, survexblock.survexfile.path) models.DataIssue.objects.create(parser='survex', message=message) survexleg.tape = 1000 try: lclino = ls[stardata["clino"]] except: - print("! Clino misread in", survexblock.survexfile.path) - print(" Stardata:", stardata) - print(" Line:", ls) + print(("! Clino misread in", survexblock.survexfile.path)) + print((" Stardata:", stardata)) + print((" Line:", ls)) message = ' ! Value Error: Clino misread in line %s in %s' % (ls, survexblock.survexfile.path) models.DataIssue.objects.create(parser='survex', message=message) lclino = error try: lcompass = ls[stardata["compass"]] except: - print("! Compass misread in", survexblock.survexfile.path) - print(" Stardata:", stardata) - print(" Line:", ls) + print(("! Compass misread in", survexblock.survexfile.path)) + print((" Stardata:", stardata)) + print((" Line:", ls)) message = ' ! Value Error: Compass misread in line %s in %s' % (ls, survexblock.survexfile.path) models.DataIssue.objects.create(parser='survex', message=message) lcompass = error @@ -67,9 +67,9 @@ def LoadSurvexLineLeg(survexblock, stardata, sline, comment, cave): try: survexleg.compass = float(lcompass) except ValueError: - print("! Compass misread in", survexblock.survexfile.path) - print(" Stardata:", stardata) - print(" Line:", ls) + print(("! Compass misread in", survexblock.survexfile.path)) + print((" Stardata:", stardata)) + print((" Line:", ls)) message = ' ! Value Error: line %s in %s' % (ls, survexblock.survexfile.path) models.DataIssue.objects.create(parser='survex', message=message) survexleg.compass = 1000 @@ -143,7 +143,7 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines): global insp # uncomment to print out all files during parsing - print(insp+" - Reading file: " + survexblock.survexfile.path + " <> " + survexfile.path) + print((insp+" - Reading file: " + survexblock.survexfile.path + " <> " + survexfile.path)) stamp = datetime.now() lineno = 0 @@ -196,7 +196,7 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines): # print(insp+' - Wallet ; ref - %s - found in survexscansfolders' % refscan) else: message = ' ! Wallet ; ref - %s - NOT found in survexscansfolders %s-%s-%s' % (refscan,yr,letterx,wallet) - print(insp+message) + print((insp+message)) models.DataIssue.objects.create(parser='survex', message=message) # This whole section should be moved if we can have *QM become a proper survex command @@ -268,7 +268,7 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines): # print(insp+' - Wallet *REF - %s - found in survexscansfolders' % refscan) else: message = ' ! Wallet *REF - %s - NOT found in survexscansfolders %s-%s-%s' % (refscan,yr,letterx,wallet) - print(insp+message) + print((insp+message)) models.DataIssue.objects.create(parser='survex', message=message) continue @@ -293,7 +293,7 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines): cmd = cmd.lower() if re.match("include$(?i)", cmd): includepath = os.path.join(os.path.split(survexfile.path)[0], re.sub(r"\.svx$", "", line)) - print(insp+' - Include path found including - ' + includepath) + print((insp+' - Include 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: @@ -303,7 +303,7 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines): if cave: survexfile.cave = cave else: - print(insp+' - No match in DB (i) for %s, so loading..' % includepath) + print((insp+' - No match in DB (i) for %s, so loading..' % includepath)) includesurvexfile = models.SurvexFile(path=includepath) includesurvexfile.save() includesurvexfile.SetDirectory() @@ -326,10 +326,10 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines): if cave: survexfile.cave = cave else: - print(insp+' - No match (b) for %s' % newsvxpath) + print((insp+' - No match (b) for %s' % newsvxpath)) name = line.lower() - print(insp+' - Begin found for: ' + name) + print((insp+' - Begin found for: ' + name)) # print(insp+'Block cave: ' + str(survexfile.cave)) survexblockdown = models.SurvexBlock(name=name, begin_char=fin.tell(), parent=survexblock, survexpath=survexblock.survexpath+"."+name, cave=survexfile.cave, survexfile=survexfile, totalleglength=0.0) survexblockdown.save() @@ -420,7 +420,7 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines): if cmd not in ["sd", "include", "units", "entrance", "data", "flags", "title", "export", "instrument", "calibrate", "set", "infer", "alias", "cs", "declination", "case"]: message = "! Bad svx command in line:%s %s %s %s" % (cmd, line, survexblock, survexblock.survexfile.path) - print(insp+message) + print((insp+message)) models.DataIssue.objects.create(parser='survex', message=message) endstamp = datetime.now() @@ -482,7 +482,7 @@ def LoadPos(): If we don't have it in the database, print an error message and discard it. """ topdata = settings.SURVEX_DATA + settings.SURVEX_TOPNAME - print(' - Generating a list of Pos from %s.svx and then loading...' % (topdata)) + print((' - Generating a list of Pos from %s.svx and then loading...' % (topdata))) # Be careful with the cache file. # If LoadPos has been run before, @@ -498,39 +498,39 @@ def LoadPos(): updtsvx = os.path.getmtime(topdata + ".svx") updtcache = os.path.getmtime(cachefile) age = updtcache - updtsvx - print(' svx: %s cache: %s not-found cache is fresher by: %s' % (updtsvx, updtcache, str(timedelta(seconds=age) ))) + print((' svx: %s cache: %s not-found cache is fresher by: %s' % (updtsvx, updtcache, str(timedelta(seconds=age) )))) now = time.time() if now - updtcache > 3*24*60*60: - print " cache is more than 3 days old. Deleting." + print(" cache is more than 3 days old. Deleting.") os.remove(cachefile) elif age < 0 : - print " cache is stale. Deleting." + print(" cache is stale. Deleting.") os.remove(cachefile) else: - print " cache is fresh. Reading..." + print(" cache is fresh. Reading...") try: with open(cachefile, "r") as f: for line in f: l = line.rstrip() if l in notfoundbefore: notfoundbefore[l] +=1 # should not be duplicates - print " DUPLICATE ", line, notfoundbefore[l] + print(" DUPLICATE ", line, notfoundbefore[l]) else: notfoundbefore[l] =1 except: - print " FAILURE READ opening cache file %s" % (cachefile) + print(" FAILURE READ opening cache file %s" % (cachefile)) raise notfoundnow =[] found = 0 skip = {} - print "\n" # extra line because cavern overwrites the text buffer somehow + print("\n") # extra line because cavern overwrites the text buffer somehow # cavern defaults to using same cwd as supplied input file call([settings.CAVERN, "--output=%s.3d" % (topdata), "%s.svx" % (topdata)]) call([settings.THREEDTOPOS, '%s.3d' % (topdata)], cwd = settings.SURVEX_DATA) - print " - This next bit takes a while. Matching ~32,000 survey positions. Be patient..." + print(" - This next bit takes a while. Matching ~32,000 survey positions. Be patient...") posfile = open("%s.pos" % (topdata)) posfile.readline() #Drop header @@ -550,7 +550,7 @@ def LoadPos(): found += 1 except: notfoundnow.append(name) - print " - %s stations not found in lookup of SurvexStation.objects. %s found. %s skipped." % (len(notfoundnow),found, len(skip)) + print(" - %s stations not found in lookup of SurvexStation.objects. %s found. %s skipped." % (len(notfoundnow),found, len(skip))) if found > 10: # i.e. a previous cave import has been done try: @@ -560,8 +560,8 @@ def LoadPos(): f.write("%s\n" % i) for j in skip: f.write("%s\n" % j) # NB skip not notfoundbefore - print(' Not-found cache file written: %s entries' % c) + print((' Not-found cache file written: %s entries' % c)) except: - print " FAILURE WRITE opening cache file %s" % (cachefile) + print(" FAILURE WRITE opening cache file %s" % (cachefile)) raise |