generated from dopt-python/py311
added list of countries
This commit is contained in:
@@ -2,10 +2,90 @@
|
||||
import dataclasses as dc
|
||||
import enum
|
||||
import re
|
||||
from collections.abc import Sequence
|
||||
|
||||
import babel
|
||||
from PySide6.QtCore import QDate, Qt
|
||||
|
||||
|
||||
# %%
|
||||
@dc.dataclass(slots=True)
|
||||
class CountryList:
|
||||
iso_to_country: dict[str, str]
|
||||
for_dropdown: Sequence[tuple[str, str]]
|
||||
|
||||
|
||||
def get_country_list_german() -> CountryList:
|
||||
locale = babel.Locale("de", "DE")
|
||||
countries: list[tuple[str, str]] = []
|
||||
iso_to_country: dict[str, str] = {}
|
||||
|
||||
for iso_code, country_name in locale.territories.items():
|
||||
if len(iso_code) == 2 and not iso_code.isdigit():
|
||||
countries.append((country_name, iso_code))
|
||||
iso_to_country[iso_code] = country_name
|
||||
|
||||
countries.sort(key=lambda x: x[0])
|
||||
|
||||
return CountryList(
|
||||
iso_to_country=iso_to_country,
|
||||
for_dropdown=tuple(countries),
|
||||
)
|
||||
|
||||
|
||||
# %%
|
||||
laender_liste
|
||||
|
||||
# %%
|
||||
DYNAMIC_LIST_KEY_PATTERN = r"-\[(\d+)\]"
|
||||
key = "Schulbildung-[12].7b8da0f7-7a0e-4f71-878a-85616099e849"
|
||||
|
||||
matches = re.search(DYNAMIC_LIST_KEY_PATTERN, key)
|
||||
|
||||
# %%
|
||||
matches
|
||||
|
||||
# %%
|
||||
matches.group(1)
|
||||
|
||||
|
||||
# %%
|
||||
class COUNTRY(enum.IntEnum):
|
||||
DE = 1
|
||||
FR = 2
|
||||
CM = 3
|
||||
|
||||
|
||||
class COUNTRY2(enum.Enum):
|
||||
DE = 1
|
||||
FR = 2
|
||||
CM = 3
|
||||
|
||||
|
||||
def give_value(t):
|
||||
print(f"Wert ist: {t}")
|
||||
|
||||
|
||||
give_value(COUNTRY.DE)
|
||||
give_value(COUNTRY2.DE)
|
||||
|
||||
# %%
|
||||
COUNTRY(10)
|
||||
# %%
|
||||
COUNTRY.DE
|
||||
# %%
|
||||
t_str = "asd.yxcxc.dfgjj.aasdsdsdsd.sdsdsdsd"
|
||||
splitted = t_str.split(".")
|
||||
part, rest = splitted[0], splitted[1:]
|
||||
|
||||
part
|
||||
|
||||
# %%
|
||||
".".join([part] + rest)
|
||||
|
||||
# %%
|
||||
|
||||
|
||||
class FormFieldType(enum.StrEnum):
|
||||
TEXT = enum.auto()
|
||||
LONGTEXT = enum.auto()
|
||||
@@ -28,29 +108,6 @@ class FormField:
|
||||
self.label += "*"
|
||||
|
||||
|
||||
# %%
|
||||
DYNAMIC_LIST_KEY_PATTERN = r"-\[(\d+)\]"
|
||||
key = "Schulbildung-[12].7b8da0f7-7a0e-4f71-878a-85616099e849"
|
||||
|
||||
matches = re.search(DYNAMIC_LIST_KEY_PATTERN, key)
|
||||
|
||||
# %%
|
||||
matches
|
||||
|
||||
# %%
|
||||
matches.group(1)
|
||||
|
||||
# %%
|
||||
t_str = "asd.yxcxc.dfgjj.aasdsdsdsd.sdsdsdsd"
|
||||
splitted = t_str.split(".")
|
||||
part, rest = splitted[0], splitted[1:]
|
||||
|
||||
part
|
||||
|
||||
# %%
|
||||
".".join([part] + rest)
|
||||
|
||||
|
||||
# %%
|
||||
FormField("name", "Projektbeschreibung", FormFieldType.LONGTEXT, required=True)
|
||||
# %%
|
||||
|
||||
Reference in New Issue
Block a user