def IsCatCode(r): global catcodes cat = record.CleanFolder(r.location()) if not cat: return False for geocat in catcodes: if cat.startswith(geocat): return True return False
def codeRecord(self, r): cat = record.CleanFolder(r.location()) if not cat: return None for geocat, lat_lon in self._catmap.iteritems(): if cat.startswith(geocat): return coders.locatable.fromLatLon(lat_lon[0], lat_lon[1], source='Folder: ' + geocat) return None
def printRecordsText(located_recs): for r, coder, locatable in located_recs: date = record.CleanDate(r.date()) title = record.CleanTitle(r.title()) folder = r.location() if folder: folder = record.CleanFolder(folder) if locatable: loc = (str(locatable.getLatLon()) or '') + '\t' + str(locatable) else: loc = 'n/a\tn/a' print '\t'.join([ r.photo_id(), date, folder, title, r.preferred_url, coder or 'failed', loc ])
def printRecordsText(located_recs): for r, coder, location_data in located_recs: date = record.CleanDate(r.date()) title = record.CleanTitle(r.title()) folder = r.location() if folder: folder = record.CleanFolder(folder) if location_data: lat = location_data['lat'] lon = location_data['lon'] loc = (str((lat, lon)) or '') + '\t' + location_data['address'] else: loc = 'n/a\tn/a' print '\t'.join([ r.photo_id(), date, folder, title, r.preferred_url, coder or 'failed', loc ])
#!/usr/bin/python import sys sys.path += (sys.path[0] + '/..') import csv import record rs = record.AllRecords() csv_writer = csv.writer(open('entries.csv', 'wb')) csv_writer.writerow(['photo_id', 'date', 'folder', 'title', 'library_url']) for r in rs: date = record.CleanDate(r.date()) title = record.CleanTitle(r.title()) folder = record.CleanFolder(r.location()) csv_writer.writerow([r.photo_id(), date, folder, title, r.preferred_url])
# Delete non-helpful "descriptions" desc = r.description() if re.match(r'^1 photographic print *: *color\.?$', desc) or \ re.match(r'^1 photographic print *: *b&w\.?$', desc): desc = '' # remove [] and trailing period from dates. date = record.CleanDate(r.date()) # remove [graphic] from titles title = record.CleanTitle(r.title()) # remove leading 'Folder: ', trailing period & convert various forms of # dashes to a single form of slashes. folder = r.location() if folder: folder = record.CleanFolder(folder) q = { 'seq_id': str(i), 'photo_id': r.photo_id(), 'title': title, 'date': date, 'folder': folder, 'description': desc, 'note': (r.note() or ''), 'library_url': r.preferred_url, 'image': open(f.CacheFile(r.photo_url), 'rb') } opener.open(upload_url, q) # To clear the data store, run: