Bebop/bebop/links.py
dece 0b79bd9e9e command_line: move input validation there
This absolutely un-atomic commit also introduces the Links class to hold
methods regarding link lookups on top of the standard dict class.
2021-03-13 20:38:56 +01:00

14 lines
370 B
Python

"""Links manager."""
class Links(dict):
def disambiguate(self, digits: str, max_digits: int):
"""Return the list of possible candidates for those digits."""
if len(digits) == max_digits:
return [int(digits)]
return [
link_id for link_id, url in self.items()
if str(link_id).startswith(digits)
]