From d71e31417b1fce145dd75661d33f2c01f83cdf57 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Thu, 9 Apr 2020 02:40:32 +0100 Subject: [PATCH] scanned image files importing --- databaseReset.py | 4 ++-- parsers/survex.py | 1 + parsers/surveys.py | 19 +++++++++++++++---- templates/survexscansfolder.html | 6 +++--- templates/survexscansfolders.html | 4 ++-- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/databaseReset.py b/databaseReset.py index 3fba913..b81a640 100644 --- a/databaseReset.py +++ b/databaseReset.py @@ -182,10 +182,10 @@ def usage(): people - read in the people from folk.csv QMs - read in the QM files resetend - scans - read in the scanned surveynotes + scans - NOT the scanned surveynotes ?! survex - read in the survex files survexpos - surveys + surveys - read in the scanned surveynotes tunnel - read in the Tunnel files """) diff --git a/parsers/survex.py b/parsers/survex.py index 14bd035..1a6118c 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -149,6 +149,7 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines): survexblock.survexscansfolder = survexscansfolders[0] #survexblock.refscandir = "%s/%s%%23%s" % (mref.group(1), mref.group(1), mref.group(2)) survexblock.save() + print('Wallet *ref - %s' % refscan) continue # This whole section should be moved if we can have *QM become a proper survex command diff --git a/parsers/surveys.py b/parsers/surveys.py index d88aab3..be8a368 100644 --- a/parsers/surveys.py +++ b/parsers/surveys.py @@ -99,19 +99,30 @@ def parseSurveyScans(expedition, logfile=None): #scanList = listdir(expedition.year, surveyFolder) scanList=os.listdir(os.path.join(yearPath,surveyFolder)) except AttributeError: - print("Folder: " + surveyFolder + " ignored\r") + print("Ignoring file in year folder: " + surveyFolder + "\r") continue for scan in scanList: + # Why does this insist on renaming all the scanned image files? + # It produces duplicates names and all images have type .jpg in the scanObj. + # It seems to rely on end users being particularly diligent in filenames which is NGtH try: - scanChopped=re.match(r'(?i).*(notes|elev|plan|elevation|extend)(\d*)\.(png|jpg|jpeg)',scan).groups() + #scanChopped=re.match(r'(?i).*(notes|elev|plan|extend|elevation)-?(\d*)\.(png|jpg|jpeg|pdf)',scan).groups() + scanChopped=re.match(r'(?i)([a-z_-]*\d?[a-z_-]*)(\d*)\.(png|jpg|jpeg|pdf|top|dxf|svg|tdr|th2|xml|txt)',scan).groups() scanType,scanNumber,scanFormat=scanChopped except AttributeError: - print("File: " + scan + " ignored\r") + print("Ignored (bad name format): " + surveyFolder + '/' + scan + "\r") continue - if scanType == 'elev' or scanType == 'extend': + scanTest = scanType + scanType = 'notes' + match = re.search(r'(?i)(elev|extend)',scanTest) + if match: scanType = 'elevation' + match = re.search(r'(?i)(plan)',scanTest) + if match: + scanType = 'plan' + if scanNumber=='': scanNumber=1 diff --git a/templates/survexscansfolder.html b/templates/survexscansfolder.html index 339f639..f31044f 100644 --- a/templates/survexscansfolder.html +++ b/templates/survexscansfolder.html @@ -2,11 +2,11 @@ {% load wiki_markup %} {% load survex_markup %} -{% block title %}Survex Scans Folder{% endblock %} +{% block title %}Survey Scans Folder{% endblock %} {% block content %} -

Survex Scans in: {{survexscansfolder.walletname}}

+

Survey Scans in: {{survexscansfolder.walletname}}

{% for survexscansingle in survexscansfolder.survexscansingle_set.all %} @@ -20,7 +20,7 @@ {% endfor %}
-

Surveys referring to this wallet

+

Survex surveys referring to this wallet

{% for survexblock in survexscansfolder.survexblock_set.all %} diff --git a/templates/survexscansfolders.html b/templates/survexscansfolders.html index 187f3f0..6250897 100644 --- a/templates/survexscansfolders.html +++ b/templates/survexscansfolders.html @@ -2,11 +2,11 @@ {% load wiki_markup %} {% load survex_markup %} -{% block title %}All Survex scans folders{% endblock %} +{% block title %}All Survey scans folders{% endblock %} {% block content %} -

All Survex scans folders

+

All Survey scans folders

{% for survexscansfolder in survexscansfolders %}
Scans folderFilesSurvex blocks