summaryrefslogtreecommitdiffstats
path: root/parsers/surveys.py
diff options
context:
space:
mode:
authorexpo <expo@expobox.potato.hut>2012-08-08 11:29:15 +0200
committerexpo <expo@expobox.potato.hut>2012-08-08 11:29:15 +0200
commitdd66ad835ae89aa4e3fd7f30f50e97b39145d640 (patch)
treeda5e0515450e9af79a596deadd857ab3daa917e0 /parsers/surveys.py
parenta29fd964bdbae84c397af2f5e1211b12ebf01558 (diff)
downloadtroggle-dd66ad835ae89aa4e3fd7f30f50e97b39145d640.tar.gz
troggle-dd66ad835ae89aa4e3fd7f30f50e97b39145d640.tar.bz2
troggle-dd66ad835ae89aa4e3fd7f30f50e97b39145d640.zip
Fixed directory names for the survey scans such that surveys could be found. It did not seem possible to simply change the localsettings.py file to get it to work.
Diffstat (limited to 'parsers/surveys.py')
-rw-r--r--parsers/surveys.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/parsers/surveys.py b/parsers/surveys.py
index 733cdfa..fc5b865 100644
--- a/parsers/surveys.py
+++ b/parsers/surveys.py
@@ -87,15 +87,15 @@ def listdir(*directories):
return [folder.rstrip(r"/") for folder in folders]
# add survey scans
-def parseSurveyScans(year, logfile=None):
-# yearFileList = listdir(year.year)
- yearPath=os.path.join(settings.SURVEY_SCANS, year.year)
+def parseSurveyScans(expedition, logfile=None):
+# yearFileList = listdir(expedition.year)
+ yearPath=os.path.join(settings.SURVEY_SCANS, "surveyscans", expedition.year)
yearFileList=os.listdir(yearPath)
print yearFileList
for surveyFolder in yearFileList:
try:
surveyNumber=re.match(r'\d\d\d\d#0*(\d+)',surveyFolder).groups()
-# scanList = listdir(year.year, surveyFolder)
+# scanList = listdir(expedition.year, surveyFolder)
scanList=os.listdir(os.path.join(yearPath,surveyFolder))
except AttributeError:
print surveyFolder + " ignored",
@@ -117,13 +117,13 @@ def parseSurveyScans(year, logfile=None):
if type(surveyNumber)==types.TupleType:
surveyNumber=surveyNumber[0]
try:
- placeholder=get_or_create_placeholder(year=int(year.year))
- survey=Survey.objects.get_or_create(wallet_number=surveyNumber, expedition=year, defaults={'logbook_entry':placeholder})[0]
+ placeholder=get_or_create_placeholder(year=int(expedition.year))
+ survey=Survey.objects.get_or_create(wallet_number=surveyNumber, expedition=expedition, defaults={'logbook_entry':placeholder})[0]
except Survey.MultipleObjectsReturned:
- survey=Survey.objects.filter(wallet_number=surveyNumber, expedition=year)[0]
- file=os.path.join(year.year, surveyFolder, scan)
+ survey=Survey.objects.filter(wallet_number=surveyNumber, expedition=expedition)[0]
+ file_=os.path.join(yearPath, surveyFolder, scan)
scanObj = ScannedImage(
- file=file,
+ file=file_,
contents=scanType,
number_in_wallet=scanNumber,
survey=survey,
@@ -131,16 +131,16 @@ def parseSurveyScans(year, logfile=None):
)
#print "Added scanned image at " + str(scanObj)
if scanFormat=="png":
- if isInterlacedPNG(os.path.join(settings.SURVEY_SCANS,file)):
- print file + " is an interlaced PNG. No can do."
+ if isInterlacedPNG(os.path.join(settings.SURVEY_SCANS, "surveyscans", file_)):
+ print file_+ " is an interlaced PNG. No can do."
continue
scanObj.save()
# dead
def parseSurveys(logfile=None):
readSurveysFromCSV()
- for year in Expedition.objects.filter(year__gte=2000): #expos since 2000, because paths and filenames were nonstandard before then
- parseSurveyScans(year)
+ for expedition in Expedition.objects.filter(year__gte=2000): #expos since 2000, because paths and filenames were nonstandard before then
+ parseSurveyScans(expedition)
# dead
def isInterlacedPNG(filePath): #We need to check for interlaced PNGs because the thumbnail engine can't handle them (uses PIL)