From a278b7dc72a8d4e7b3a57576fb160cc30965981b Mon Sep 17 00:00:00 2001 From: Date: Wed, 28 Feb 2018 22:30:14 -0500 Subject: [PATCH] Added a few more example usages. --- examples/card_autocorrect.py | 20 ++++++++++++++++++++ examples/lookup_set_code.py | 14 ++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 examples/card_autocorrect.py create mode 100644 examples/lookup_set_code.py diff --git a/examples/card_autocorrect.py b/examples/card_autocorrect.py new file mode 100644 index 0000000..de72849 --- /dev/null +++ b/examples/card_autocorrect.py @@ -0,0 +1,20 @@ +import scrython +import time + +query = input("Name a card: ") + +auto = "" + +try: + time.sleep(0.05) + card = scrython.cards.Named(exact=query) +except Exception: + time.sleep(0.05) + auto = scrython.cards.Autocomplete(q=query, query=query) + +if auto: + print("Did you mean?") + for item in auto.data(): + print(item) +else: + print(card.name()) diff --git a/examples/lookup_set_code.py b/examples/lookup_set_code.py new file mode 100644 index 0000000..ad815c3 --- /dev/null +++ b/examples/lookup_set_code.py @@ -0,0 +1,14 @@ +import scrython +import time + +query = input("Type the name of the set: ") + +time.sleep(0.05) +sets = scrython.sets.Sets() + +for i in range(sets.data_length()): + if sets.set_name(i) == query: + print("Set code:", sets.set_code(i).upper()) + break + else: + continue