diff options
Diffstat (limited to 'parsers/caves.py')
-rw-r--r-- | parsers/caves.py | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/parsers/caves.py b/parsers/caves.py index 8a611ec..06b77c9 100644 --- a/parsers/caves.py +++ b/parsers/caves.py @@ -64,25 +64,38 @@ def dummy_entrance(k, slug, msg="DUMMY"): message = f" ! {k:11s} {msg}-{slug} {k} entrance create failure" DataIssue.objects.create(parser="entrances", message=message, url=f"{slug}") print(message) - raise + raise # caught and handled by calling routine. def set_dummy_entrance(id, slug, cave, msg="DUMMY"): """Called only when reading the cave and entrance html files - Entrance field either missing or holds a null string instead of a filename in a cave_data file.""" + + Called when the Entrance field in a cave_data file is either missing or + holds a null string instead of a filename. + + Previously, the lack of an entrance where an entrance was expected, caused troggle to crash in several places. + But it is more robust now, so this is not necessary... we hope. + + Also, Cave and Entrance editing now expects there to be a real file (since April 2023), so creating this + dummy is actually harmful. So this is commented out, pending removal after further experience. + + global variable entrances_xslug is simply a cache of references to Entrance objects + to speed things up when parsing a lot of caves and entrances. All DB actions are time-consuming + so + """ global entrances_xslug + message = f" - Note: Missing Entrance for entrance '{id}' on cave '{cave}'" + DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.url}") try: - #Note the below line, just creates a dastabase entry, sets the global variable entrances_xslug and not a file, this then breaks entrance editing by the website. I am not sure if we want entrances automagically created. Therefore I have commented it out. Perhaps entrances_xslug is being saved with the worng filename, breaking edit_caves. MJG - #entrance = dummy_entrance(id, slug, msg="DUMMY") - #entrances_xslug[slug] = entrance - #CaveAndEntrance.objects.update_or_create(cave=cave, entrance_letter="", entrance=entrance) - #message = f" - Note: Dummy Entrance successfully set for entrance {id} on cave {cave}" - message = f" - Note: Missing Entrance for entrance {id} on cave {cave}" - DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.url}") - # print(message) + # I am not sure if we want entrances automagically created. + # Therefore I have commented it out. MJG + + # entrance = dummy_entrance(id, slug, msg="DUMMY") + # entrances_xslug[slug] = entrance + # CaveAndEntrance.objects.update_or_create(cave=cave, entrance_letter="", entrance=entrance) + pass except: - # raise message = f' ! Entrance Dummy setting failure, slug:"{slug}" cave id :"{id}" ' DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.url}") print(message) |