summaryrefslogtreecommitdiffstats
path: root/core/views/caves.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2022-11-23 10:48:39 +0000
committerPhilip Sargent <philip.sargent@klebos.com>2022-11-23 10:48:39 +0000
commitb06d1dae4222cdb6e50fef629967bc76625b52e9 (patch)
tree5526634dc2d0c3097e27f611da23fcafd5197f32 /core/views/caves.py
parent45a640dfe9aa5da411992668273e525ee6150b4b (diff)
downloadtroggle-b06d1dae4222cdb6e50fef629967bc76625b52e9.tar.gz
troggle-b06d1dae4222cdb6e50fef629967bc76625b52e9.tar.bz2
troggle-b06d1dae4222cdb6e50fef629967bc76625b52e9.zip
Convert.format() to f-strings with flynt
Diffstat (limited to 'core/views/caves.py')
-rw-r--r--core/views/caves.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/core/views/caves.py b/core/views/caves.py
index fe85949..7706315 100644
--- a/core/views/caves.py
+++ b/core/views/caves.py
@@ -155,7 +155,7 @@ def file3d(request, cave, cave_id):
#print(" - - Regeneration ABORT\n - - from '{}'".format(survexpath))
pass
try:
- completed_process = subprocess.run([settings.CAVERN, "--log", "--output={}".format(settings.SURVEX_DATA), "{}".format(survexpath)])
+ completed_process = subprocess.run([settings.CAVERN, "--log", f"--output={settings.SURVEX_DATA}", f"{survexpath}"])
except OSError as ex:
# propagate this to caller.
raise OSError(completed_process.stdout) from ex
@@ -164,7 +164,7 @@ def file3d(request, cave, cave_id):
op3dlog = Path(op3d.with_suffix('.log'))
if not op3d.is_file():
- print(" - - Regeneration FAILED\n - - from '{}'\n - - to '{}'".format(survexpath, op3d))
+ print(f" - - Regeneration FAILED\n - - from '{survexpath}'\n - - to '{op3d}'")
print(" - - Regeneration stdout: ", completed_process.stdout)
print(" - - Regeneration cavern log output: ", op3dlog.read_text())
@@ -172,10 +172,10 @@ def file3d(request, cave, cave_id):
def return3d(threedpath):
if threedpath.is_file():
response = HttpResponse(content=open(threedpath, 'rb'), content_type='application/3d')
- response['Content-Disposition'] = 'attachment; filename={}'.format(threedpath.name)
+ response['Content-Disposition'] = f'attachment; filename={threedpath.name}'
return response
else:
- message = '<h1>Path provided does not correspond to any actual 3d file.</h1><p>path: "{}"'.format(threedpath)
+ message = f'<h1>Path provided does not correspond to any actual 3d file.</h1><p>path: "{threedpath}"'
#print(message)
return HttpResponseNotFound(message)
@@ -205,10 +205,10 @@ def file3d(request, cave, cave_id):
# Get here if cave.survex_file was set but did not correspond to a valid svx file
if survexpath.is_file():
# a file, but invalid format
- message='<h1>File is not valid .svx format.</h1><p>Could not generate 3d file from "{}"'.format(survexpath)
+ message=f'<h1>File is not valid .svx format.</h1><p>Could not generate 3d file from "{survexpath}"'
else:
# we could try to guess that 'caves-1623/' is missing,... nah.
- message = '<h1>Path provided does not correspond to any actual file.</h1><p>path: "{}"'.format(survexpath)
+ message = f'<h1>Path provided does not correspond to any actual file.</h1><p>path: "{survexpath}"'
return HttpResponseNotFound(message)
@@ -325,9 +325,9 @@ def edit_cave(request, path = "", slug=None):
if a.kat_area():
myArea = a.kat_area()
if form.cleaned_data["kataster_number"]:
- myslug = "%s-%s" % (myArea, form.cleaned_data["kataster_number"])
+ myslug = f"{myArea}-{form.cleaned_data['kataster_number']}"
else:
- myslug = "%s-%s" % (myArea, form.cleaned_data["unofficial_number"])
+ myslug = f"{myArea}-{form.cleaned_data['unofficial_number']}"
else:
myslug = slug
# Converting a PENDING cave to a real cave by saving this form
@@ -345,7 +345,7 @@ def edit_cave(request, path = "", slug=None):
try:
cave_file = cave.file_output()
print(cave_file)
- write_and_commit([cave_file], "Online edit of %s" % cave)
+ write_and_commit([cave_file], f"Online edit of {cave}")
# leave other exceptions unhandled so that they bubble up to user interface
except PermissionError:
message = f'CANNOT save this file.\nPERMISSIONS incorrectly set on server for this file {cave.filename}. Ask a nerd to fix this.'
@@ -414,7 +414,7 @@ def edit_entrance(request, path = "", caveslug=None, slug=None):
es.save()
entrance_file = entrance.file_output()
cave_file = cave.file_output()
- write_and_commit([entrance_file, cave_file], "Online edit of %s%s" % (cave, entletter))
+ write_and_commit([entrance_file, cave_file], f"Online edit of {cave}{entletter}")
entrance.save()
if slug is None:
entrance_letter.save()