2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

FIxed new survex file in editor crashed I think

This commit is contained in:
Philip Sargent 2024-07-18 23:42:59 +02:00
parent 5740a6b0d6
commit c27a4f0ddc

View File

@ -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