Skip to content

Commit

Permalink
feat: docs and entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
amasotti committed Jan 14, 2024
1 parent fa90f6d commit 6894f92
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions bot/wikivoyage/scripts/citylist_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
from bot.wikivoyage import WikivoyageBot


def run_citylist_wikidata_check():
def run_citylist_wikidata_check(lang="it", total=1):
"""
Run the citylist wikidata check - this will add wikidata ids to citylist items
if the wikidata id is not already present and can be found with certainty (multiple wikidata items
for the same city name are not allowed)
:return: None
"""
wikivoyage_bot = WikivoyageBot(lang="it")
wikivoyage_bot = WikivoyageBot(lang=lang)

# Example usage of listing a category
articles = wikivoyage_bot.listify_category("Itemlist con errori di compilazione", 1)
articles = wikivoyage_bot.listify_category("Itemlist con errori di compilazione", total)

# Read the text of the article
for article in articles:
Expand Down
17 changes: 8 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@


def main(args):
# Docs
if args.list_scripts:
list_scripts()
exit(0)

# Run the script
if args.script == "citylist.checker":
run_citylist_wikidata_check()
if args.script == "citylist-checker":
run_citylist_wikidata_check(args.lang, int(args.total))
else:
raise ValueError(f"Unknown script: {args.script}")

Expand All @@ -22,9 +17,13 @@ def list_scripts():

if __name__ == "__main__":
parser = argparse.ArgumentParser(
description='Run the wikivoyage Nastoshka bot')
description='Run the wikivoyage Nastoshka bot',
usage='main.py -s <script> [-l <lang> -t <total>]\navailable scripts:\n'+
'\tcitylist-checker : Check the citylist for wikidata ids'
)
parser.add_argument('-s', '--script', help='Run a specific script', required=False)
parser.add_argument('-l', '--list-scripts', help='List available scripts', action='store_true')
parser.add_argument('-l', '--lang', help='The language to use', required=False, default='it')
parser.add_argument('-t', '--total', help='The total number of articles to check', required=False, default=1)
args = parser.parse_args()

main(args)

0 comments on commit 6894f92

Please sign in to comment.