Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support matching after unable to decide #22

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/models/enrich_hiking_trails.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __lookup_in_waymarked_trails__(trail_item: TrailItem) -> None:
f"Try looking at {trail_item.waymarked_hiking_trails_search_url} "
f"and see if any fit with {trail_item.item.get_entity_url()}"
)
# TODO help the user match again
trail_item.try_matching_again()
else:
trail_item.osm_id_source = OsmIdSource.QUESTIONNAIRE
trail_item.enrich_wikidata()
Expand Down
17 changes: 14 additions & 3 deletions src/models/trail_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from urllib.parse import quote

import pydash
import questionary
import requests
from dateutil.parser import parse # type: ignore
from dateutil.tz import tzutc # type: ignore
Expand Down Expand Up @@ -197,9 +198,8 @@ def __prepare_choices__(self):
)

def __ask_question__(self) -> QuestionaryReturn:
"""This presents a choice and returns"""
# present the result to the user to choose from
import questionary

if not self.item:
raise NoItemError()
return_ = questionary.select(
Expand Down Expand Up @@ -245,7 +245,6 @@ def fetch_and_lookup_from_waymarked_trails_and_present_choice_to_user(self):
self.__get_item_details__()
self.__lookup_label_on_waymarked_trails_and_ask_user_to_choose_a_match__()

# @validate_arguments()
def enrich_wikidata(self):
"""We enrich Wikidata based on the choice of the user"""
if self.osm_id_source == OsmIdSource.QUESTIONNAIRE:
Expand Down Expand Up @@ -522,3 +521,15 @@ def __remove_not_found_in_osm_claim__(self):
self.item.claims.remove(Property.OSM_RELATION_ID.value)
except KeyError:
logger.debug("No NOT_FOUND_IN found on this item to remove")

def try_matching_again(self):
if self.questionary_return.could_not_decide is True:
result = questionary.select(
"Do you want to match again after manually ",
choices=[
Choice(title="Yes", value=True),
Choice(title="No", value=False),
],
).ask()
if result:
self.questionary_return = self.__ask_question__()