def _get_iban_spec(country_code: str) -> dict: try: spec = registry.get("iban") assert isinstance(spec, dict) return spec[country_code] except KeyError: raise exceptions.InvalidCountryCode( f"Unknown country-code '{country_code}'")
def from_bank_code(cls, country_code: str, bank_code: str) -> BIC: """Create a new BIC object from country-code and domestic bank-code. Examples: >>> bic = BIC.from_bank_code('DE', '20070000') >>> bic.country_code 'DE' >>> bic.bank_code 'DEUT' >>> bic.location_code 'HH' >>> BIC.from_bank_code('DE', '01010101') Traceback (most recent call last): ... InvalidBankCode: Unknown bank code '01010101' for country 'DE' Args: country_code (str): ISO 3166 alpha2 country-code. bank_code (str): Country specific bank-code. Returns: BIC: a BIC object generated from the given country code and bank code. Raises: InvalidBankCode: If the given bank code wasn't found in the registry Note: This currently only works for selected countries. Amongst them * Austria * Belgium * Croatia * Czech Republic * Finland * France * Germany * Great Britan * Latvia * Lithuania * Netherlands * Poland * Slovenia * Spain * Switzerland """ try: spec = registry.get("bank_code") assert isinstance(spec, dict) return cls(spec[(country_code, bank_code)]["bic"]) except KeyError: raise exceptions.InvalidBankCode( f"Unknown bank code {bank_code!r} for country {country_code!r}" )
def from_bank_code(cls, country_code, bank_code): """Create a new BIC object from country-code and domestic bank-code. Examples: >>> bic = BIC.from_bank_code('DE', '20070000') >>> bic.country_code 'DE' >>> bic.bank_code 'DEUT' >>> bic.location_code 'HH' >>> BIC.from_bank_code('DE', '01010101') Traceback (most recent call last): ... ValueError: Invalid bank code '01010101' for country 'DE' Args: country_code (str): ISO 3166 alpha2 country-code. bank_code (str): Country specific bank-code. Returns: BIC: a BIC object generated from the given country code and bank code. Raises: ValueError: If the given bank code wasn't found in the registry Note: This currently only works for selected countries. Amongst them * Austria * Belgium * Croatia * Czech Republic * Germany * Great Britan * Finland * France * Latvia * Poland * Slovenia * Spain * Switzerland """ try: return cls( registry.get("bank_code")[(country_code, bank_code)]["bic"]) except KeyError: raise ValueError("Invalid bank code {!r} for country {!r}".format( bank_code, country_code))
def from_bank_code(cls, country_code, bank_code): """Create a new BIC object from country- and bank-code. Args: country_code (str): ISO 3166 alpha2 country-code. bank_code (str): Country specific bank-code. Note: This currently only works for German bank-codes. """ try: return cls(registry.get('bank_code')[(country_code, bank_code)]['bic']) except KeyError: pass
def from_bank_code(cls, country_code, bank_code): """Create a new BIC object from country-code and domestic bank-code. Examples: >>> bic = BIC.from_bank_code('DE', '20070000') >>> bic.country_code 'DE' >>> bic.bank_code 'DEUT' >>> bic.location_code 'HH' >>> BIC.from_bank_code('DE', '01010101') Traceback (most recent call last): ... ValueError: Invalid bank code '01010101' for country 'DE' Args: country_code (str): ISO 3166 alpha2 country-code. bank_code (str): Country specific bank-code. Returns: BIC: a BIC object generated from the given country code and bank code. Raises: ValueError: If the given bank code wasn't found in the registry Note: This currently only works for German bank-codes. """ try: return cls( registry.get('bank_code')[(country_code, bank_code)]['bic']) except KeyError: raise ValueError("Invalid bank code {!r} for country {!r}".format( bank_code, country_code))
def from_bank_code(cls, country_code, bank_code): """Create a new BIC object from country- and bank-code. Examples: >>> bic = BIC.from_bank_code('DE', '20070000') >>> bic.country_code 'DE' >>> bic.bank_code 'DEUT' >>> bic.location_code 'HH' >>> BIC.from_bank_code('DE', '01010101') Traceback (most recent call last): ... ValueError: Invalid bank code '01010101' for country 'DE' Args: country_code (str): ISO 3166 alpha2 country-code. bank_code (str): Country specific bank-code. Returns: BIC: a BIC object generated from the given country code and bank code. Raises: ValueError: If the given bank code wasn't found in the registry Note: This currently only works for German bank-codes. """ try: return cls(registry.get('bank_code')[(country_code, bank_code)]['bic']) except KeyError: raise ValueError("Invalid bank code {!r} for country {!r}".format(bank_code, country_code))
def _get_iban_spec(country_code): try: return registry.get('iban')[country_code] except KeyError: raise ValueError("Unknown country-code '{}'".format(country_code))
def _get_iban_spec(country_code): try: return registry.get("iban")[country_code] except KeyError: raise exceptions.InvalidCountryCode( f"Unknown country-code '{country_code}'")
def exists(self): """bool: Indicates if the BIC is available in Schwifty's registry.""" return bool(registry.get('bic').get(self.compact))
def bank_short_name(self): """str or None: The short name of the bank associated with the BIC.""" entry = registry.get('bic').get(self.compact) if entry: return entry.get('short_name')
def test_validate_bics(): for bic in (bank["bic"] for bank in registry.get("bank") if bank["bic"]): BIC(bic, allow_invalid=False)
def exists(self) -> bool: """bool: Indicates if the BIC is available in Schwifty's registry.""" spec = registry.get("bic") assert isinstance(spec, dict) return bool(spec.get(self.compact))
def _lookup_values(self, key: str) -> List: spec = registry.get("bic") assert isinstance(spec, dict) entries = spec.get(self.compact, []) return sorted({entry[key] for entry in entries})
def _get_iban_spec(country_code): try: return registry.get('iban')[country_code] except KeyError: raise ValueError('Unknown country-code %s' % country_code)
def __get_spec(self) -> str: return registry.get('iban')[self.country_code]
def country_bank_code(self): """str or None: The country specific bank-code associated with the BIC.""" entry = registry.get('bic').get(self.compact) if entry: return entry.get('bank_code')
def _lookup_values(self, key): entries = registry.get('bic').get(self.compact, []) return sorted({entry[key] for entry in entries})