summaryrefslogtreecommitdiffstats
path: root/parsers
diff options
context:
space:
mode:
Diffstat (limited to 'parsers')
-rw-r--r--parsers/QMs.py2
-rw-r--r--parsers/survex.py2
-rw-r--r--parsers/surveys.py81
3 files changed, 5 insertions, 80 deletions
diff --git a/parsers/QMs.py b/parsers/QMs.py
index 78a5257..025438e 100644
--- a/parsers/QMs.py
+++ b/parsers/QMs.py
@@ -1,7 +1,7 @@
import csv
import os
import re
-from datetime import *
+#from datetime import *
from django.conf import settings
diff --git a/parsers/survex.py b/parsers/survex.py
index aebcd31..f236ec8 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -123,7 +123,7 @@ def LoadSurvexEquate(survexblock, sline):
def LoadSurvexLinePassage(survexblock, stardata, sline, comment):
- # do not import *data passage.. data which is LRUD not tape/compass/clino
+ # do not import this: *data passage.. data which is LRUD not tape/compass/clino
pass
# This interprets the survex "*data normal" command which sets out the order of the fields in the data, e.g.
diff --git a/parsers/surveys.py b/parsers/surveys.py
index 02ec90c..baa8725 100644
--- a/parsers/surveys.py
+++ b/parsers/surveys.py
@@ -15,9 +15,9 @@ from utils import save_carefully
from functools import reduce
import settings
-from troggle.core.models import *
-from troggle.core.models_caves import *
-from troggle.core.models_survex import *
+#from troggle.core.models import *
+#from troggle.core.models_caves import *
+#from troggle.core.models_survex import *
def get_or_create_placeholder(year):
""" All surveys must be related to a logbookentry. We don't have a way to
@@ -40,81 +40,6 @@ def listdir(*directories):
folders = urllib.request.urlopen(url.replace("#", "%23")).readlines()
return [folder.rstrip(r"/") for folder in folders]
-# add survey scans
-# def parseSurveyScans(expedition, logfile=None):
-# # yearFileList = listdir(expedition.year)
- # try:
- # yearPath=os.path.join(settings.SURVEY_SCANS, "surveyscans", expedition.year)
- # yearFileList=os.listdir(yearPath)
- # print(yearFileList)
- # for surveyFolder in yearFileList:
- # try:
- # surveyNumber=re.match(rb'\d\d\d\d#(X?)0*(\d+)',surveyFolder).groups()
- # #scanList = listdir(expedition.year, surveyFolder)
- # scanList=os.listdir(os.path.join(yearPath,surveyFolder))
- # except AttributeError:
- # 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(rb'(?i).*(notes|elev|plan|extend|elevation)-?(\d*)\.(png|jpg|jpeg|pdf)',scan).groups()
- # scanChopped=re.match(rb'(?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(("Ignored (bad name format): " + surveyFolder + '/' + scan + "\r"))
- # continue
- # scanTest = scanType
- # scanType = 'notes'
- # match = re.search(rb'(?i)(elev|extend)',scanTest)
- # if match:
- # scanType = 'elevation'
-
- # match = re.search(rb'(?i)(plan)',scanTest)
- # if match:
- # scanType = 'plan'
-
- # if scanNumber=='':
- # scanNumber=1
-
- # if isinstance(surveyNumber, tuple):
- # surveyLetter=surveyNumber[0]
- # surveyNumber=surveyNumber[1]
- # try:
- # placeholder=get_or_create_placeholder(year=int(expedition.year))
- # survey=Survey.objects.get_or_create(wallet_number=surveyNumber, wallet_letter=surveyLetter, expedition=expedition, defaults={'logbook_entry':placeholder})[0]
- # except Survey.MultipleObjectsReturned:
- # survey=Survey.objects.filter(wallet_number=surveyNumber, wallet_letter=surveyLetter, expedition=expedition)[0]
- # file_=os.path.join(yearPath, surveyFolder, scan)
- # scanObj = ScannedImage(
- # file=file_,
- # contents=scanType,
- # number_in_wallet=scanNumber,
- # survey=survey,
- # new_since_parsing=False,
- # )
- # print(("Added scanned image at " + str(scanObj)))
- # #if scanFormat=="png":
- # #if isInterlacedPNG(os.path.join(settings.SURVEY_SCANS, "surveyscans", file_)):
- # # print file_+ " is an interlaced PNG. No can do."
- # #continue
- # scanObj.save()
- # except (IOError, OSError):
- # yearPath=os.path.join(settings.SURVEY_SCANS, "surveyscans", expedition.year)
- # print((" ! No folder found for " + expedition.year + " at:- " + yearPath))
-
-# dead
-# def isInterlacedPNG(filePath): #We need to check for interlaced PNGs because the thumbnail engine can't handle them (uses PIL)
- # file=Image.open(filePath)
- # print(filePath)
- # if 'interlace' in file.info:
- # return file.info['interlace']
- # else:
- # return False
-
# handles url or file, so we can refer to a set of scans on another server
def GetListDir(sdir):