Coverage for value_object_pattern/usables/money/utils/__init__.py: 81.82%
11 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-11-21 14:31 +0000
« prev ^ index » next coverage.py v7.15.4, created at 2026-11-21 14:31 +0000
1from functools import lru_cache 1abcdefghij
2from importlib.resources import files 1abcdefghij
5@lru_cache(maxsize=1) 1abcdefghij
6def get_iban_lengths() -> dict[str, int]: 1abcdefghij
7 """
8 Get IBAN lengths by country code.
10 Returns:
11 dict[str, int]: A ISO 3166-1 alpha-2 country code to with the IBAN length corresponds.
13 References:
14 IBAN Structure: https://www.iban.com/structure
15 """
16 lines = ( 1abcdefghij
17 files('value_object_pattern.usables.money.utils')
18 .joinpath('iban_lengths.txt')
19 .read_text(encoding='utf-8')
20 .splitlines()
21 )
22 filtered_lines = tuple(line for line in lines if not line.startswith('#') and (_line := line.strip().upper())) 1abcdefghij
24 return {line.split(', ')[0]: int(line.split(', ')[1]) for line in filtered_lines} 1abcdefghij
27@lru_cache(maxsize=1) 1abcdefghij
28def get_iso4217_alpha3_codes() -> tuple[str, ...]: 1abcdefghij
29 """
30 Get current ISO 4217 alphabetic currency and fund codes.
32 Returns:
33 tuple[str, ...]: Current three-letter codes in uppercase.
35 References:
36 ISO 4217: https://www.iso.org/iso-4217-currency-codes.html
37 SIX List One: https://www.six-group.com/dam/download/financial-information/data-center/iso-currrency/lists/list-one.xml
38 """
39 lines = (
40 files('value_object_pattern.usables.money.utils')
41 .joinpath('iso4217_alpha3_codes.txt')
42 .read_text(encoding='utf-8')
43 .splitlines()
44 )
46 return tuple(line for line in lines if not line.startswith('#') and (_line := line.strip().upper()))