Esempio n. 1
0
    bban = property(partial(Base._get_component, start=4),
                    doc="str: The BBAN part of the IBAN.")
    country_code = property(partial(Base._get_component, start=0, end=2),
                            doc="str: ISO 3166 alpha-2 country code.")
    checksum_digits = property(partial(Base._get_component, start=2, end=4),
                               doc="str: Two digit checksum of the IBAN.")
    bank_code = property(partial(_get_code, code_type="bank_code"),
                         doc="str: The country specific bank-code.")
    branch_code = property(
        partial(_get_code, code_type="branch_code"),
        doc="str or None: The branch-code of the bank if available.",
    )
    account_code = property(partial(_get_code, code_type="account_code"),
                            doc="str: The customer specific account-code")


def add_bban_regex(country, spec):
    bban_spec = spec["bban_spec"]
    spec_re = r"(\d+)(!)?([{}])".format("".join(_spec_to_re.keys()))

    def convert(match):
        quantifier = ("{%s}" if match.group(2) else "{1,%s}") % match.group(1)
        return _spec_to_re[match.group(3)] + quantifier

    spec["regex"] = re.compile("^{}$".format(
        re.sub(spec_re, convert, bban_spec)))
    return spec


registry.manipulate("iban", add_bban_regex)
Esempio n. 2
0
    bban = property(partial(Base._get_component, start=4),
                    doc="str: The BBAN part of the IBAN.")
    country_code = property(partial(Base._get_component, start=0, end=2),
                            doc="str: ISO 3166 alpha-2 country code.")
    checksum_digits = property(partial(Base._get_component, start=2, end=4),
                               doc="str: Two digit checksum of the IBAN.")
    bank_code = property(partial(_get_code, code_type='bank_code'),
                         doc="str: The country specific bank-code.")
    branch_code = property(
        partial(_get_code, code_type='branch_code'),
        doc="str or None: The branch-code of the bank if available.")
    account_code = property(partial(_get_code, code_type='account_code'),
                            doc="str: The customer specific account-code")


def add_bban_regex(country, spec):
    bban_spec = spec['bban_spec']
    spec_re = r'(\d+)(!)?([{}])'.format(''.join(_spec_to_re.keys()))

    def convert(match):
        quantifier = ('{%s}' if match.group(2) else '{1,%s}') % match.group(1)
        return _spec_to_re[match.group(3)] + quantifier

    spec['regex'] = re.compile('^{}$'.format(
        re.sub(spec_re, convert, bban_spec)))
    return spec


registry.manipulate('iban', add_bban_regex)
Esempio n. 3
0
    def _get_code(self, code_type):
        start, end = self.spec['positions'][code_type]
        return self.bban[start:end]

    bban = property(partial(Base._get_component, start=4),
                    doc="str: The BBAN part of the IBAN.")
    country_code = property(partial(Base._get_component, start=0, end=2),
                            doc="str: ISO 3166 alpha-2 country code.")
    checksum_digits = property(partial(Base._get_component, start=2, end=4),
                               doc="str: Two digit checksum of the IBAN.")
    bank_code = property(partial(_get_code, code_type='bank_code'),
                         doc="str: The country specific bank-code.")
    branch_code = property(partial(_get_code, code_type='branch_code'),
                           doc="str or None: The branch-code of the bank if available.")
    account_code = property(partial(_get_code, code_type='account_code'),
                            doc="str: The customer specific account-code")


def add_bban_regex(country, spec):
    bban_spec = spec['bban_spec']
    spec_re = r'(\d+)(!)?([{}])'.format(''.join(_spec_to_re.keys()))

    def convert(match):
        quantifier = ('{%s}' if match.group(2) else '{1,%s}') % match.group(1)
        return _spec_to_re[match.group(3)] + quantifier
    spec['regex'] = re.compile('^{}$'.format(re.sub(spec_re, convert, bban_spec)))
    return spec


registry.manipulate('iban', add_bban_regex)