diff options
Diffstat (limited to 'parsers/surveys.py')
-rw-r--r-- | parsers/surveys.py | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/parsers/surveys.py b/parsers/surveys.py index c50fd56..950e216 100644 --- a/parsers/surveys.py +++ b/parsers/surveys.py @@ -31,59 +31,6 @@ def get_or_create_placeholder(year): placeholder_logbook_entry, newly_created = save_carefully(LogbookEntry, lookupAttribs, nonLookupAttribs) return placeholder_logbook_entry -# obsolete surveys.csv does not exist. -# def readSurveysFromCSV(): - # try: # could probably combine these two - # surveytab = open(os.path.join(settings.SURVEY_SCANS, "Surveys.csv")) - # except IOError: - # import io, urllib.request, urllib.parse, urllib.error - # surveytab = io.StringIO(urllib.request.urlopen(settings.SURVEY_SCANS + "/Surveys.csv").read()) - # dialect=csv.Sniffer().sniff(surveytab.read()) - # surveytab.seek(0,0) - # surveyreader = csv.reader(surveytab,dialect=dialect) - # headers = next(surveyreader) - # header = dict(list(zip(headers, list(range(len(headers)))))) #set up a dictionary where the indexes are header names and the values are column numbers - - # # test if the expeditions have been added yet - # if Expedition.objects.count()==0: - # print("There are no expeditions in the database. Please run the logbook parser.") - # sys.exit() - - - # logging.info("Deleting all scanned images") - # ScannedImage.objects.all().delete() - - - # logging.info("Deleting all survey objects") - # Survey.objects.all().delete() - - - # logging.info("Beginning to import surveys from "+str(os.path.join(settings.SURVEYS, "Surveys.csv"))+"\n"+"-"*60+"\n") - - # for survey in surveyreader: - # #I hate this, but some surveys have a letter eg 2000#34a. The next line deals with that. - # walletNumberLetter = re.match(r'(?P<number>\d*)(?P<letter>[a-zA-Z]*)',survey[header['Survey Number']]) - # # print(walletNumberLetter.groups()) - # year=survey[header['Year']] - - - # surveyobj = Survey( - # expedition = Expedition.objects.filter(year=year)[0], - # wallet_number = walletNumberLetter.group('number'), - # logbook_entry = get_or_create_placeholder(year), - # comments = survey[header['Comments']], - # location = survey[header['Location']] - # ) - # surveyobj.wallet_letter = walletNumberLetter.group('letter') - # if survey[header['Finished']]=='Yes': - # #try and find the sketch_scan - # pass - # surveyobj.save() - - - # logging.info("added survey " + survey[header['Year']] + "#" + surveyobj.wallet_number + "\r") - -# dead def listdir(*directories): try: return os.listdir(os.path.join(settings.SURVEYS, *directories)) @@ -160,19 +107,6 @@ def listdir(*directories): # print((" ! No folder found for " + expedition.year + " at:- " + yearPath)) # dead -# def parseSurveys(logfile=None): - # try: - # readSurveysFromCSV() - # except (IOError, OSError): - # print(" ! Survey CSV not found..") - # pass - - # print(" - Loading scans by expedition year") - # for expedition in Expedition.objects.filter(year__gte=2000): #expos since 2000, because paths and filenames were nonstandard before then - # print("%s" % expedition, end=' ') - # parseSurveyScans(expedition) - -# 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) |