From 3813b21dcf5fbec27f5a5d05deca5d302d4e1637 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Mon, 18 Apr 2022 22:48:49 +0300 Subject: [PATCH] regularising _URL and _ROOT idiom --- core/TESTS/tests_logins.py | 2 +- core/views/statistics.py | 8 ++++---- core/views/uploads.py | 2 +- deprecations.txt | 2 ++ parsers/scans.py | 4 ++-- urls.py | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/core/TESTS/tests_logins.py b/core/TESTS/tests_logins.py index 5998881..513e69d 100644 --- a/core/TESTS/tests_logins.py +++ b/core/TESTS/tests_logins.py @@ -105,7 +105,7 @@ class PostTests(TestCase): self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'") # Does not use the filename Django actually uses, assumes it is unchanged. Potential bug. - remove_file = pathlib.Path(settings.SURVEY_SCANS) / '2020' / '2020#00'/ 'test_upload_file.txt' + remove_file = pathlib.Path(settings.SCANS_ROOT) / '2020' / '2020#00'/ 'test_upload_file.txt' remove_file.unlink() def test_photo_upload(self): diff --git a/core/views/statistics.py b/core/views/statistics.py index bd1d065..02cbd43 100644 --- a/core/views/statistics.py +++ b/core/views/statistics.py @@ -49,9 +49,9 @@ def pathsreport(request): "ROOT_URLCONF" : str( settings.ROOT_URLCONF), "STATIC_URL" : str( settings.STATIC_URL), "SURVEX_DATA" : str( settings.SURVEX_DATA), - "SURVEY_SCANS" : str( settings.SURVEY_SCANS), + "SCANS_ROOT" : str( settings.SCANS_ROOT), # "SURVEYS" : str( settings.SURVEYS), - "SURVEYS_URL" : str( settings.SURVEYS_URL), + "SCANS_URL" : str( settings.SCANS_URL), "SURVEXPORT" : str( settings.SURVEXPORT), "DRAWINGS_DATA" : str( settings.DRAWINGS_DATA), "URL_ROOT" : str( settings.URL_ROOT) @@ -86,9 +86,9 @@ def pathsreport(request): "ROOT_URLCONF" : type(settings.ROOT_URLCONF), "STATIC_URL" : type(settings.STATIC_URL), "SURVEX_DATA" : type(settings.SURVEX_DATA), - "SURVEY_SCANS" : type(settings.SURVEY_SCANS), + "SCANS_ROOT" : type(settings.SCANS_ROOT), # "SURVEYS" : type(settings.SURVEYS), - "SURVEYS_URL" : type(settings.SURVEYS_URL), + "SCANS_URL" : type(settings.SCANS_URL), "SURVEXPORT" : type(settings.SURVEXPORT), "DRAWINGS_DATA" : type(settings.DRAWINGS_DATA), "URL_ROOT" : type(settings.URL_ROOT) diff --git a/core/views/uploads.py b/core/views/uploads.py index 255b2b6..1d0a510 100644 --- a/core/views/uploads.py +++ b/core/views/uploads.py @@ -141,7 +141,7 @@ def scanupload(request, path=None): wurl = f"/scanupload/{wallet}".replace('#', ':') wallet = wallet.replace(':','#') - dirpath = Path(settings.SURVEY_SCANS, year, wallet) + dirpath = Path(settings.SCANS_ROOT, year, wallet) contents_path = dirpath / contentsjson walletdata = dirpath / contentsjson diff --git a/deprecations.txt b/deprecations.txt index e69de29..a8f4ed8 100644 --- a/deprecations.txt +++ b/deprecations.txt @@ -0,0 +1,2 @@ +/mnt/d/EXPO/troggle/core/views/uploads.py:120: DeprecationWarning: invalid escape sequence \d + if not re.match('(19|20)\d\d[:#]\d\d', wallet): diff --git a/parsers/scans.py b/parsers/scans.py index 7868c70..d2fcbf7 100644 --- a/parsers/scans.py +++ b/parsers/scans.py @@ -111,7 +111,7 @@ def load_all_scans(): DataIssue.objects.filter(parser='scans').delete() # first do the smkhs (large kh survey scans) directory - manywallets_smkhs = Wallet(fpath=os.path.join(settings.SURVEY_SCANS, "../surveys/smkhs"), walletname="smkhs") + manywallets_smkhs = Wallet(fpath=os.path.join(settings.SCANS_ROOT, "../surveys/smkhs"), walletname="smkhs") print("smkhs", end=' ') if os.path.isdir(manywallets_smkhs.fpath): manywallets_smkhs.save() @@ -120,7 +120,7 @@ def load_all_scans(): # iterate into the surveyscans directory print(' - ', end=' ') - for f, ff, fisdir in GetListDir(settings.SURVEY_SCANS): + for f, ff, fisdir in GetListDir(settings.SCANS_ROOT): if not fisdir: continue diff --git a/urls.py b/urls.py index eac48ba..3a8c0cf 100644 --- a/urls.py +++ b/urls.py @@ -163,7 +163,7 @@ trogglepatterns = [ path('survexfile/', survex.survexcavesingle, name="survexcavessingle"), -# The survey scans in the wallets +# The survey scans in the wallets. This short-cuts SCANS_URL which is not actually used anywhere! path('survey_scans/', allwallets, name="allwallets"), path('survey_scans//', scanupload, name="singlewallet"), # replaced singlewallet() path('survey_scans//', scansingle, name="scansingle"),