@danhachuel/thunderbolt 0.7.50 → 0.7.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/social_networks_ui.py +42 -3
- package/package.json +1 -1
|
@@ -60,6 +60,37 @@ def _country_key(value: Any) -> str:
|
|
|
60
60
|
return "".join(char for char in normalized if not unicodedata.combining(char)).casefold()
|
|
61
61
|
|
|
62
62
|
|
|
63
|
+
COUNTRY_CODE_NAMES = {
|
|
64
|
+
"BR": "Brasil",
|
|
65
|
+
"CH": "Suíça",
|
|
66
|
+
"ES": "Espanha",
|
|
67
|
+
"RS": "Sérvia",
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
COUNTRY_NAME_CODES = {name: code for code, name in COUNTRY_CODE_NAMES.items()}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _country_flag(value: Any) -> str:
|
|
75
|
+
"""Render a two-letter country code as a Unicode regional-indicator flag."""
|
|
76
|
+
clean_value = _clean(value).upper()
|
|
77
|
+
if len(clean_value) != 2 or not clean_value.isascii() or not clean_value.isalpha():
|
|
78
|
+
return ""
|
|
79
|
+
return "".join(chr(0x1F1E6 + ord(char) - ord("A")) for char in clean_value)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _country_display(value: Any) -> str:
|
|
83
|
+
clean_value = _clean(value)
|
|
84
|
+
if not clean_value:
|
|
85
|
+
return "Não definido"
|
|
86
|
+
code = clean_value.upper()
|
|
87
|
+
flag = _country_flag(code)
|
|
88
|
+
if flag:
|
|
89
|
+
return f"{flag} {COUNTRY_CODE_NAMES.get(code, code)}"
|
|
90
|
+
mapped_code = COUNTRY_NAME_CODES.get(clean_value)
|
|
91
|
+
return f"{_country_flag(mapped_code)} {clean_value}" if mapped_code else clean_value
|
|
92
|
+
|
|
93
|
+
|
|
63
94
|
COUNTRY_ALIASES = {
|
|
64
95
|
"brazil": "Brasil",
|
|
65
96
|
"brasil": "Brasil",
|
|
@@ -75,6 +106,12 @@ def _normalise_country(value: Any) -> str:
|
|
|
75
106
|
clean_value = _clean(value)
|
|
76
107
|
if not clean_value:
|
|
77
108
|
return ""
|
|
109
|
+
code = clean_value.upper()
|
|
110
|
+
if code in COUNTRY_CODE_NAMES:
|
|
111
|
+
return COUNTRY_CODE_NAMES[code]
|
|
112
|
+
if len(code) == 2 and code.isascii() and code.isalpha():
|
|
113
|
+
# Keep unknown legacy ISO codes usable and renderable rather than dropping them.
|
|
114
|
+
return code
|
|
78
115
|
if clean_value in COUNTRY_OPTIONS:
|
|
79
116
|
return clean_value
|
|
80
117
|
key = _country_key(clean_value)
|
|
@@ -108,7 +145,7 @@ def _country_index(value: Any) -> int:
|
|
|
108
145
|
|
|
109
146
|
|
|
110
147
|
def _country_label(value: str) -> str:
|
|
111
|
-
return value
|
|
148
|
+
return _country_display(value)
|
|
112
149
|
|
|
113
150
|
|
|
114
151
|
def _instagram_posts_key(profile_id: str) -> str:
|
|
@@ -469,7 +506,8 @@ def _render_instagram_card(profile: dict[str, Any], characters: list[dict[str, A
|
|
|
469
506
|
st.write(f"**{_clean(profile.get('name')) or 'Sem nome'}**")
|
|
470
507
|
st.caption(f"{_clean(profile.get('handle')) or _clean(profile.get('url')) or 'sem handler'}")
|
|
471
508
|
_render_instagram_bio(_profile_bio(profile))
|
|
472
|
-
|
|
509
|
+
country = _profile_country(profile)
|
|
510
|
+
st.caption(f"{_country_display(country) if country else 'País não definido'} · {_clean(profile.get('language')) or 'Idioma não definido'}")
|
|
473
511
|
with header_cols[2]:
|
|
474
512
|
st.metric("posts", _metric(_profile_metric(profile, "post_count", "posts", "media_count")))
|
|
475
513
|
with header_cols[3]:
|
|
@@ -550,7 +588,8 @@ def _render_instagram_card(profile: dict[str, Any], characters: list[dict[str, A
|
|
|
550
588
|
with block_cols[1]:
|
|
551
589
|
st.markdown(f"**handler**\n\n{_clean(profile.get('handle')) or '—'}")
|
|
552
590
|
with block_cols[2]:
|
|
553
|
-
|
|
591
|
+
country = _profile_country(profile)
|
|
592
|
+
st.markdown(f"**País**\n\n{_country_display(country) if country else '—'}")
|
|
554
593
|
with block_cols[3]:
|
|
555
594
|
st.markdown(f"**Idioma**\n\n{_clean(profile.get('language')) or '—'}")
|
|
556
595
|
|
package/package.json
CHANGED