Spaces:
Running
Running
Alejandro Cremades
commited on
Commit
•
81025f5
1
Parent(s):
ea3872d
Do not show the slash between names when only one name is available
Browse files- Middle_School_Card_Search.py +20 -5
Middle_School_Card_Search.py
CHANGED
@@ -9,16 +9,28 @@ def compose_scryfall_url(x: str) -> str:
|
|
9 |
|
10 |
|
11 |
def row_to_link(x: pd.DataFrame) -> None:
|
12 |
-
|
|
|
|
|
|
|
13 |
|
14 |
|
15 |
-
def is_legal(cardname: str) ->
|
16 |
english_match = mslist_df[mslist_df["name"].str.lower() == cardname.lower()]
|
|
|
17 |
if english_match.shape[0] > 0:
|
18 |
-
|
|
|
19 |
japanese_match = mslist_df[mslist_df["name_ja"] == cardname]
|
20 |
if japanese_match.shape[0] > 0:
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
return None
|
23 |
|
24 |
|
@@ -53,8 +65,11 @@ results_ja_df = mslist_df[
|
|
53 |
results_df = results_en_df.merge(results_ja_df, how="outer")
|
54 |
if name_input:
|
55 |
if exact_match is not None:
|
|
|
|
|
|
|
56 |
st.write(
|
57 |
-
f"✅ [{
|
58 |
)
|
59 |
st.write(results_df.shape[0], f'cards found by "{name_input}"')
|
60 |
if results_df.shape[0] > number_shown_results:
|
|
|
9 |
|
10 |
|
11 |
def row_to_link(x: pd.DataFrame) -> None:
|
12 |
+
cardname = x["name"]
|
13 |
+
if x.name_ja is not "":
|
14 |
+
cardname = f"{cardname} / {x.name_ja}"
|
15 |
+
st.markdown(f"- [{cardname}]({x.link})")
|
16 |
|
17 |
|
18 |
+
def is_legal(cardname: str) -> list:
|
19 |
english_match = mslist_df[mslist_df["name"].str.lower() == cardname.lower()]
|
20 |
+
cardname_en_list = None
|
21 |
if english_match.shape[0] > 0:
|
22 |
+
cardname_en_list = english_match["name"].to_list()
|
23 |
+
cardname_ja_list = english_match["name_ja"].to_list()
|
24 |
japanese_match = mslist_df[mslist_df["name_ja"] == cardname]
|
25 |
if japanese_match.shape[0] > 0:
|
26 |
+
cardname_en_list = japanese_match["name"].to_list()
|
27 |
+
cardname_ja_list = japanese_match["name_ja"].to_list()
|
28 |
+
if cardname_en_list is not None and len(cardname_en_list) > 0:
|
29 |
+
return [
|
30 |
+
cardname_en_list[0] or None,
|
31 |
+
cardname_ja_list[0] or None,
|
32 |
+
]
|
33 |
+
|
34 |
return None
|
35 |
|
36 |
|
|
|
65 |
results_df = results_en_df.merge(results_ja_df, how="outer")
|
66 |
if name_input:
|
67 |
if exact_match is not None:
|
68 |
+
cardname = exact_match[0]
|
69 |
+
if exact_match[1] is not None:
|
70 |
+
cardname = f"{cardname} / {exact_match[1]}"
|
71 |
st.write(
|
72 |
+
f"✅ [{cardname}]({compose_scryfall_url(exact_match[0])}) is an exact match"
|
73 |
)
|
74 |
st.write(results_df.shape[0], f'cards found by "{name_input}"')
|
75 |
if results_df.shape[0] > number_shown_results:
|