diff options
Diffstat (limited to 'parsers')
-rw-r--r-- | parsers/QMs.py | 6 | ||||
-rw-r--r-- | parsers/logbooks.py | 12 | ||||
-rw-r--r-- | parsers/people.py | 19 |
3 files changed, 19 insertions, 18 deletions
diff --git a/parsers/QMs.py b/parsers/QMs.py index 56c97e4..9691ce7 100644 --- a/parsers/QMs.py +++ b/parsers/QMs.py @@ -173,7 +173,7 @@ def parse_KH_QMs(kh, inputFile, ticked): resolution_station_name = station_name.replace("<a href=\"","<a href=\"/1623/161/") else: nearest_station_name = station_name.replace("<a href=\"","<a href=\"/1623/161/") - lookupAttribs = { + coUniqueAttribs = { #'found_by':placeholder, "blockname": "", "expoyear": year, @@ -181,7 +181,7 @@ def parse_KH_QMs(kh, inputFile, ticked): "cave": kh, "grade": res["grade"], } - nonLookupAttribs = { + otherAttribs = { "ticked": ticked, "page_ref": "", "completion_description": completion, @@ -190,7 +190,7 @@ def parse_KH_QMs(kh, inputFile, ticked): "location_description": res["location_description"].replace("<a href=\"","<a href=\"/1623/161/"), } # Create new. We know it doesn't exist as we deleted evrything when we started. - instance = QM.objects.create(**nonLookupAttribs, **lookupAttribs) + instance = QM.objects.create(**otherAttribs, **coUniqueAttribs) nqms += 1 else: if dataline.startswith("<dt><a href"): diff --git a/parsers/logbooks.py b/parsers/logbooks.py index 50324a1..90c13aa 100644 --- a/parsers/logbooks.py +++ b/parsers/logbooks.py @@ -262,7 +262,7 @@ def store_entry_into_database(date, place, tripcave, title, text, trippersons, a # if guests: # print(f" {date} - {guests}") - nonLookupAttribs = { + otherAttribs = { "place": place, "other_people": other_people, # *Ol's Mum, foreigners.. "text": text, @@ -270,20 +270,20 @@ def store_entry_into_database(date, place, tripcave, title, text, trippersons, a "time_underground": logtime_underground, "cave_slug": str(tripcave), } - lookupAttribs = {"slug": tid, "date": date, "title": title} + coUniqueAttribs = {"slug": tid, "date": date, "title": title} if LogbookEntry.objects.filter(slug=tid).exists(): # oops. Our code should already have ensured this is unique. message = " ! - DUPLICATE SLUG for logbook entry " + tripdate + " - " + slug DataIssue.objects.create(parser="logbooks", message=message) slug = slug + "_" + unique_slug(text,2) - lbo = LogbookEntry.objects.create(**nonLookupAttribs, **lookupAttribs) + lbo = LogbookEntry.objects.create(**otherAttribs, **coUniqueAttribs) pt_list = [] for tripperson, nickname_used, time_underground in trippersons: - lookupAttribs = {"personexpedition": tripperson, "nickname_used": nickname_used, "logbook_entry": lbo} # lbo is primary key - nonLookupAttribs = {"time_underground": time_underground, "is_logbook_entry_author": (tripperson == author)} - pt_list.append(PersonLogEntry(**nonLookupAttribs, **lookupAttribs)) + coUniqueAttribs = {"personexpedition": tripperson, "nickname_used": nickname_used, "logbook_entry": lbo} # lbo is primary key + otherAttribs = {"time_underground": time_underground, "is_logbook_entry_author": (tripperson == author)} + pt_list.append(PersonLogEntry(**otherAttribs, **coUniqueAttribs)) PersonLogEntry.objects.bulk_create(pt_list) def parser_date(tripdate, year): diff --git a/parsers/people.py b/parsers/people.py index ef6984b..4799ebf 100644 --- a/parsers/people.py +++ b/parsers/people.py @@ -78,15 +78,16 @@ def load_people_expos(): if nexpos <= 0: print(" - Creating expeditions") for year in years: - lookupAttribs = {"year": year} - nonLookupAttribs = {"name": f"CUCC expo {year}"} - e = Expedition.objects.create(**nonLookupAttribs, **lookupAttribs) + coUniqueAttribs = {"year": year} + otherAttribs = {"name": f"CUCC expo {year}"} + e = Expedition.objects.create(**otherAttribs, **coUniqueAttribs) print(" - Loading personexpeditions") for personline in personreader: name = personline[header["Name"]] name = re.sub(r"<.*?>", "", name) + slug = slugify(name) firstname = "" nick = "" @@ -111,9 +112,9 @@ def load_people_expos(): else: vfho = True - lookupAttribs = {"first_name": firstname, "last_name": (lastname or "")} - nonLookupAttribs = {"is_vfho": vfho, "fullname": fullname, "nickname": nick} - person = Person.objects.create(**nonLookupAttribs, **lookupAttribs) + coUniqueAttribs = {"first_name": firstname, "last_name": (lastname or "")} + otherAttribs = {"is_vfho": vfho, "fullname": fullname, "nickname": nick} + person = Person.objects.create(**otherAttribs, **coUniqueAttribs) parse_blurb(personline=personline, header=header, person=person) @@ -121,9 +122,9 @@ def load_people_expos(): for year, attended in list(zip(headers, personline))[5:]: expedition = Expedition.objects.get(year=year) if attended == "1" or attended == "-1": - lookupAttribs = {"person": person, "expedition": expedition} - nonLookupAttribs = {"is_guest": (personline[header["Guest"]] == "1")} - pe = PersonExpedition.objects.create(**nonLookupAttribs, **lookupAttribs) + coUniqueAttribs = {"person": person, "expedition": expedition} + otherAttribs = {"is_guest": (personline[header["Guest"]] == "1")} + pe = PersonExpedition.objects.create(**otherAttribs, **coUniqueAttribs) print("", flush=True) |