Beispiel #1
0
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}'")
Beispiel #2
0
    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}"
            )
Beispiel #3
0
    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))
Beispiel #4
0
    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
Beispiel #5
0
    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))
Beispiel #6
0
    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))
Beispiel #7
0
def _get_iban_spec(country_code):
    try:
        return registry.get('iban')[country_code]
    except KeyError:
        raise ValueError("Unknown country-code '{}'".format(country_code))
Beispiel #8
0
def _get_iban_spec(country_code):
    try:
        return registry.get("iban")[country_code]
    except KeyError:
        raise exceptions.InvalidCountryCode(
            f"Unknown country-code '{country_code}'")
Beispiel #9
0
 def exists(self):
     """bool: Indicates if the BIC is available in Schwifty's registry."""
     return bool(registry.get('bic').get(self.compact))
Beispiel #10
0
 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')
Beispiel #11
0
def test_validate_bics():
    for bic in (bank["bic"] for bank in registry.get("bank") if bank["bic"]):
        BIC(bic, allow_invalid=False)
Beispiel #12
0
 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))
Beispiel #13
0
 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})
Beispiel #14
0
def _get_iban_spec(country_code):
    try:
        return registry.get('iban')[country_code]
    except KeyError:
        raise ValueError('Unknown country-code %s' % country_code)
Beispiel #15
0
 def __get_spec(self) -> str:
     return registry.get('iban')[self.country_code]
Beispiel #16
0
 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')
Beispiel #17
0
 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')
Beispiel #18
0
 def _lookup_values(self, key):
     entries = registry.get('bic').get(self.compact, [])
     return sorted({entry[key] for entry in entries})
Beispiel #19
0
 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')
Beispiel #20
0
 def exists(self):
     """bool: Indicates if the BIC is available in Schwifty's registry."""
     return bool(registry.get('bic').get(self.compact))
Beispiel #21
0
def _get_iban_spec(country_code):
    try:
        return registry.get('iban')[country_code]
    except KeyError:
        raise ValueError("Unknown country-code '{}'".format(country_code))