2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-16 22:47:03 +00:00

remove redundant code

This commit is contained in:
2025-07-20 12:46:27 +02:00
parent 24079ab5fe
commit 5770a9b2e7

View File

@@ -199,6 +199,32 @@ def validate_entrance_stations(ent=None):
poslineregex = re.compile(r"^\(\s*([+-]?\d*\.\d*),\s*([+-]?\d*\.\d*),\s*([+-]?\d*\.\d*)\s*\)\s*([^\s]+)$")
# This regular expression matches a specific format:
# A tuple of three floating-point numbers, followed by a non-space string.
# Pattern breakdown:
# ^ : Start of string
# \( : Literal opening parenthesis
# \s* : Optional whitespace
# ([+-]?\d*\.\d*) : First float (with optional sign)
# ,\s* : Comma and optional whitespace
# ([+-]?\d*\.\d*) : Second float
# ,\s* : Comma and optional whitespace
# ([+-]?\d*\.\d*) : Third float
# \s*\) : Optional whitespace and closing parenthesis
# \s* : Optional whitespace after the tuple
# ([^\s]+) : Captures a non-space string (e.g. identifier, label)
# $ : End of string
# Example matches:
# "(1.23, -4.56, +7.89)SomeTextHere"
# "( 0.0 , 3.14 , 2.71 )ExtraStuff"
# Capturing groups returned:
# group(1): First float
# group(2): Second float
# group(3): Third float
# group(4): Trailing text (no spaces)
def LoadPositions():
"""First load the survex stations for entrances and fixed points (about 600) into the database.
@@ -215,65 +241,65 @@ def LoadPositions():
SurvexStation.objects.all().delete()
def runcavern3d(msg=None):
if msg:
print(" - ", msg)
outputdir = Path(str(f"{topdata}.svx")).parent
file3d = Path(f"{topdata}.3d")
try:
sp = subprocess.run(
[settings.CAVERN, "--log", f"--output={outputdir}", f"{topdata}.svx"],
capture_output=True,
check=False,
text=True,
) # check=False means exception not raised
if sp.returncode != 0:
message = f" ! Error: cavern: creating {file3d} in runcavern3()"
stash_data_issue(parser="positions", message=message)
print(message)
# def runcavern3d(msg=None):
# if msg:
# print(" - ", msg)
# outputdir = Path(str(f"{topdata}.svx")).parent
# file3d = Path(f"{topdata}.3d")
# try:
# sp = subprocess.run(
# [settings.CAVERN, "--log", f"--output={outputdir}", f"{topdata}.svx"],
# capture_output=True,
# check=False,
# text=True,
# ) # check=False means exception not raised
# if sp.returncode != 0:
# message = f" ! Error: cavern: creating {file3d} in runcavern3()"
# stash_data_issue(parser="positions", message=message)
# print(message)
# find the errors in the .log file
sp = subprocess.run(
["grep", "error:", f"{topdata}.log"], capture_output=True, check=False, text=True
) # check=False means exception not raised
message = f" ! Error: cavern: {sp.stdout} creating {file3d} "
stash_data_issue(parser="positions", message=message)
print(message)
# # find the errors in the .log file
# sp = subprocess.run(
# ["grep", "error:", f"{topdata}.log"], capture_output=True, check=False, text=True
# ) # check=False means exception not raised
# message = f" ! Error: cavern: {sp.stdout} creating {file3d} "
# stash_data_issue(parser="positions", message=message)
# print(message)
except:
message = f" ! CalledProcessError 'cavern' in runcavern3() at {topdata}."
stash_data_issue(parser="positions", message=message)
print(message)
# except:
# message = f" ! CalledProcessError 'cavern' in runcavern3() at {topdata}."
# stash_data_issue(parser="positions", message=message)
# print(message)
if file3d.is_file():
message = f" ! CalledProcessError. File permissions {file3d.stat().st_mode} on {str(file3d)}"
stash_data_issue(parser="positions", message=message)
print(message)
# if file3d.is_file():
# message = f" ! CalledProcessError. File permissions {file3d.stat().st_mode} on {str(file3d)}"
# stash_data_issue(parser="positions", message=message)
# print(message)
if file3d.is_file(): # might be an old one though, if previous step failed
try:
sp = subprocess.run(
[settings.SURVEXPORT, "--pos", f"{file3d}"],
cwd=settings.SURVEX_DATA,
capture_output=True,
check=False,
text=True,
)
if sp.returncode != 0:
print(
f" ! Error: survexport creating {topdata}.pos in runcavern3().\n\n"
+ str(sp.stdout)
+ "\n\nreturn code: "
+ str(sp.returncode)
)
except:
message = f" ! CalledProcessError 'survexport' in runcavern3() at {file3d}."
stash_data_issue(parser="positions", message=message)
print(message)
else:
message = f" ! Failed to find {file3d} so aborting generation of new .pos, using old one if present"
stash_data_issue(parser="positions", message=message)
print(message)
# if file3d.is_file(): # might be an old one though, if previous step failed
# try:
# sp = subprocess.run(
# [settings.SURVEXPORT, "--pos", f"{file3d}"],
# cwd=settings.SURVEX_DATA,
# capture_output=True,
# check=False,
# text=True,
# )
# if sp.returncode != 0:
# print(
# f" ! Error: survexport creating {topdata}.pos in runcavern3().\n\n"
# + str(sp.stdout)
# + "\n\nreturn code: "
# + str(sp.returncode)
# )
# except:
# message = f" ! CalledProcessError 'survexport' in runcavern3() at {file3d}."
# stash_data_issue(parser="positions", message=message)
# print(message)
# else:
# message = f" ! Failed to find {file3d} so aborting generation of new .pos, using old one if present"
# stash_data_issue(parser="positions", message=message)
# print(message)
topdata = Path(settings.SURVEX_DATA, settings.SURVEX_TOPNAME)
print(f" - Generating a list of Pos from {topdata}.3d and then loading...")