-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: synchronized functions that return generators are fixed
- Loading branch information
Showing
6 changed files
with
103 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
from mightstone.app import Mightstone | ||
from mightstone.ass import aiterator_to_list | ||
|
||
scryfall = Mightstone().scryfall | ||
found = aiterator_to_list(scryfall.search_async("boseiju")) | ||
m = Mightstone() | ||
found = list(m.scryfall.search("boseiju")) | ||
|
||
print(f"Found {len(found)} instances of Boseiju") | ||
print("boseiju matches:") | ||
for card in found: | ||
print(f" - {card}") | ||
|
||
print(f"Found {len(found)} instances of Boseiju") | ||
|
||
print(list([x.name for x in m.scryfall.search("thalia")])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
This example demonstrate the behavior of Mightstone in a synchronous context | ||
random() method is an alias for random_async() using asgiref’s async_to_sync feature | ||
search() method is an alias for search_async() using asgiref’s async_to_sync feature | ||
""" | ||
|
||
from mightstone import Mightstone | ||
from mightstone.services.scryfall import Card | ||
|
||
mightstone = Mightstone() | ||
card = mightstone.scryfall.random() | ||
|
||
print(f"The random card is {card.name} ({card.id})") | ||
|
||
brushwaggs: list[Card] = mightstone.scryfall.search("brushwagg") | ||
|
||
for i, brushwagg in enumerate(brushwaggs): | ||
print(f"Brushwagg {i} is {brushwagg.name} from {brushwagg.set_code}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.