summaryrefslogtreecommitdiffstats
path: root/parsers
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2024-07-18 23:42:59 +0200
committerPhilip Sargent <philip.sargent@gmail.com>2024-07-18 23:42:59 +0200
commitc27a4f0ddcb02e8b339dac438e6d021e23c7105d (patch)
treeef4aaf79056b3291970de82fbba96c92149756f8 /parsers
parent5740a6b0d6ab584d405b258d36a17ea72a1d81ce (diff)
downloadtroggle-c27a4f0ddcb02e8b339dac438e6d021e23c7105d.tar.gz
troggle-c27a4f0ddcb02e8b339dac438e6d021e23c7105d.tar.bz2
troggle-c27a4f0ddcb02e8b339dac438e6d021e23c7105d.zip
FIxed new survex file in editor crashed I think
Diffstat (limited to 'parsers')
-rw-r--r--parsers/survex.py37
1 files changed, 11 insertions, 26 deletions
diff --git a/parsers/survex.py b/parsers/survex.py
index 20d3f79..28a2467 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -853,6 +853,12 @@ class LoadingSurvex:
REPLACE ALL THIS by reading the .log output of cavern for the file.
But we need the lengths per Block, not by File. dump3d will do lengths per block.
"""
+
+ # catch bug when saving a new single survex file
+ if 'survexfile' not in locals():
+ survexfile = survexblock.survexfile
+ print(f"LoadSurvexLeg() UNSET 'survexfile' variable, setting to {survexblock.survexfile}")
+
invalid_clino = 180.0
invalid_compass = 720.0
invalid_tape = 0.0
@@ -886,7 +892,7 @@ class LoadingSurvex:
# NORMAL, so there should be 5 fields
# from the content, this is clearly reading fixedpts/gps/gps00raw.svx, but not reporting it by that name
if len(ls) < 5:
- print("! Fewer than 5 fields in NORMAL in ", survexblock.survexfile.path, survexfile, survexfile.parent)
+ print("! Fewer than 5 fields in NORMAL in ", survexblock.survexfile.path, survexfile, survexfile.primary)
print(" datastar NORMAL:", self.datastar)
print(f" Line (split): {ls}, comment: {comment}")
print(f" Line: {sline}\nsvxline: {svxline}")
@@ -2481,6 +2487,7 @@ def parse_one_file(fpath): # --------------------------------------in progress--
This creates its own LoadingSurvex() class instance called svx_load
"""
+ debugprint = True
def find_cave_from_path(svxpath):
""" Seems simple enough.. but needs refactoring with Class method IdentifyCave()
This will normally be called from MakeRoot only when creating a new survex file
@@ -2530,31 +2537,7 @@ def parse_one_file(fpath): # --------------------------------------in progress--
print(f" - Making/finding a new dummy root survexfile for this import: {svxpath}")
print(f" - new fileroot {type(dummyroot)} for {svxpath} with cave {cave}\n - {dummyroot.primary=} {dummyroot.path=} {dummyroot.cave=} ")
return dummyroot
- """ for f in IGNOREFILES:
- if svxid.lower().startswith(f):
- return False
- for i in IGNOREPREFIX:
- if cavepath.lower().startswith(i) or cavepath[11:].lower().startswith(i):
- # message = (f" - {cavepath} is an <IGNOREPREFIX> (while looking at '{svxid}.svx' )")
- # print(message, file=sys.stderr)
- return False
-
- cave = create_new_cave(cavepath, svxid, f"Cave mentioned only in a survex file {svxid=}") # uses the pending code
- self.caveslist[cavepath.lower()] = cave
- return cave
- else:
- path_match = rx_svxcollection.search(svxid)
- if path_match:
- # message = f" ! Recognised survex file in area {path_match.group(1)} which is not a cave at {svxid=}"
- # stash_data_issue(parser="survex", message=message, url=None, sb=(svxid))
- # print(message, file=sys.stderr)
- return False
- else: # probably a top level file immediately in the loser directory. No worries.
- message = f" ! Warning: no cave identifiable for '{svxid}.svx' {cavepath=} "
- print("\n" + message)
- stash_data_issue(parser="survex", message=message, url="{svxid}.svx", sb=(svxid))
- return False
- """
+
def parse_new_svx(fpath, svx_load, svxfileroot=None):
@@ -2589,10 +2572,12 @@ def parse_one_file(fpath): # --------------------------------------in progress--
print(f" - block_dummy now '{block_dummy}' {type(block_dummy)} id={block_dummy.id} f:{block_dummy.survexfile}\n -- {block_dummy.name=}")
# ----------------------------------------------------------------
+ svx_load.LoadSurvexFile(fpath) # otherwise only called for *include files
svx_load.LinearLoad(block_dummy, svxfileroot.path, fname)
# ----------------------------------------------------------------
# Now we don't need or want the dummy any more
+
block_dummy.delete()
global svx_load