Skip to content

Commit

Permalink
chore: Add check so we know if the upload was successful
Browse files Browse the repository at this point in the history
  • Loading branch information
dpriskorn committed Aug 7, 2024
1 parent ed7be7c commit 1c8634e
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/models/trail_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,16 @@ def enrich_wikidata(self):
console.print(self.item.get_json())
console.input("Press enter to upload or ctrl+c to quit")
if self.summary:
self.item.write(summary=self.summary)
console.print(
f"Upload done, see {self.item.get_entity_url()} "
f"and https://hiking.waymarkedtrails.org/"
f"#route?id={self.questionary_return.osm_id}"
)
item = self.item.write(summary=self.summary)
if self.__verify_successful_upload__(item):
console.print(
f"Upload done, see {self.item.get_entity_url()} "
f"and https://hiking.waymarkedtrails.org/"
f"#route?id={self.questionary_return.osm_id}"
)
exit()
else:
raise Exception("Upload failed")
else:
raise SummaryError()
else:
Expand Down Expand Up @@ -583,3 +587,10 @@ def try_matching_again(self):
).ask()
if result:
self.questionary_return = self.__ask_question__()

def __verify_successful_upload__(self, item: ItemEntity) -> bool:
found = False
for claim in item.claims:
if claim.mainsnak.property_number == Property.OSM_RELATION_ID.value:
found = True
return found

0 comments on commit 1c8634e

Please sign in to comment.