From ffae0bc2ce40e168ccfb3f6853b2e718a83b9ad0 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Mon, 14 Nov 2016 10:20:43 +0100 Subject: [PATCH] Replace banknumber with python-stdnum Since version 1.5 python-stdnum is capable of validating spanish account numbers, so we should use the more generic library. --- CHANGELOG | 2 ++ retrofix/fields.py | 7 ++++--- setup.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 033a62c..0befa73 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Replace banknumber with python-stdnum + Version 0.22 - 2016-09-06 * Manage None values on fields diff --git a/retrofix/fields.py b/retrofix/fields.py index aa59152..94bb58d 100644 --- a/retrofix/fields.py +++ b/retrofix/fields.py @@ -29,7 +29,8 @@ except ImportError: from decimal import Decimal import re from datetime import datetime -import banknumber + +from stdnum.es.ccc import is_valid from .formatting import format_string, format_number from .exception import RetrofixException @@ -108,7 +109,7 @@ class Account(Char): def set_from_file(self, value): account = value.strip() - if account and not banknumber.check_code('ES', account): + if account and not is_valid(account): raise RetrofixException('Invalid bank account "%s" in field "%s"' % (value, self._name)) return super(Account, self).set_from_file(value) @@ -117,7 +118,7 @@ class Account(Char): account = value if account: account = account.strip() - if account and not banknumber.check_code('ES', account): + if account and not is_valid(account): raise RetrofixException('Invalid bank account "%s" in field "%s"' % (value, self._name)) return super(Account, self).set(value) diff --git a/setup.py b/setup.py index 2c22b69..6bd1c1d 100644 --- a/setup.py +++ b/setup.py @@ -56,7 +56,7 @@ setup(name=PACKAGE, ], license=LICENSE, install_requires=[ - 'banknumber >= 1.0', + 'python-stdnum >= 1.5', ], extras_require={}, zip_safe=False,