summaryrefslogtreecommitdiffstats
path: root/parsers
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
commit484f8f76cc1c3b44ab7b4b343cdc7ed3f80ed835 (patch)
tree36bb4748f5a989e6f384c77dfc07c8c048782060 /parsers
parent70a743f88bd1639bbf3b3fc38f8562f6f5b7133c (diff)
downloadtroggle-484f8f76cc1c3b44ab7b4b343cdc7ed3f80ed835.tar.gz
troggle-484f8f76cc1c3b44ab7b4b343cdc7ed3f80ed835.tar.bz2
troggle-484f8f76cc1c3b44ab7b4b343cdc7ed3f80ed835.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')
-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)