Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/stdnum/util.py
Commit message (Collapse)AuthorAgeFilesLines
* Fix typos found by codespellDimitri Papadopoulos2021-08-101-1/+1
| | | | Closes https://github.com/arthurdejong/python-stdnum/pull/269
* Fix flake8 blind except Exception errorArthur de Jong2021-01-101-2/+2
|
* Support normalising quotesArthur de Jong2019-07-141-0/+9
| | | | See https://github.com/arthurdejong/python-stdnum/issues/150
* Convert various reasonable unicode digitsArthur de Jong2019-04-291-0/+40
| | | | | This converts many of the "reasonable" unicode digits that are just variations on ASCII 0-9 to their ASCII counterparts.
* Use an internal isdigits() function instead of str.isdigit()Arthur de Jong2019-04-291-1/+13
| | | | | | | | | | | The problem with the latter is that it will also accept all kinds of unicode digits that are not the ASCII 0-9 digits causing all kinds of problems in check digit calculations. Some of these unicode characters are also considered digits by int() but some are not (such as the SUPERSCRIPT TWO unicode character). Closes https://github.com/arthurdejong/python-stdnum/issues/96
* Make unicode conversion standardArthur de Jong2018-05-011-0/+10
| | | | | | A few modules use non-ASCII characters in numbers. This introduces a to_unicode() function in util so that it can be used by multiple modules.
* Allow configuring SOAP request timeoutArthur de Jong2018-02-061-11/+20
| | | | | | This adds a timeout parameter to all checks that use a SOAP web service to reduce the blocking time. The default timeout for all checks is 30 seconds.
* Try the non-caching zeep client on older versionsArthur de Jong2018-01-031-10/+16
| | | | | | | | This uses the "normal" Client class from zeep if CachingClient is not available (this is the case on older zeep versions). This also records (and documents) the dependencies for SOAP libraries in setup.py.
* Correctly quote regular expressionArthur de Jong2017-12-311-2/+2
| | | | Fixes a6ae1d0.
* Rename stdnum.iso9362 to stdnum.bicArthur de Jong2017-11-031-7/+11
| | | | | | The new name is more descriptive and easier to remember. This makes stdnum.iso9362 a compatibility module that can be imported with the old name but provides a deprecation warning.
* Support zeep as preferred SOAP libraryArthur de Jong2017-10-221-7/+12
| | | | | | This tries zeep, suds (suds-jurko) and falls back to using pysimplesoap for performing the SOAP requests. From those zeep seems to be the best supported implementation.
* Cache SOAP client in get_soap_client()Arthur de Jong2017-10-221-13/+20
| | | | | This caches the instantiated SOAP client classes in the util module instead of doing the caching in every module that performs requests.
* Handle unicode arguments in get_cc_module()David Arnold2017-10-141-6/+1
| | | | Closes https://github.com/arthurdejong/python-stdnum/issues/54
* Minor code improvements (mostly PEP8)Arthur de Jong2017-09-111-1/+1
|
* Ensure 100% branch coverageArthur de Jong2017-08-281-12/+3
| | | | | | | | | | | This ensures that the tests fail if 100% branch coverage is not achieved. It also adds some pragma statements for code that cannot be covered or is Python version dependent. Furthermore, the get_module_list() function was removed from stdnum.util and more tests were made from stdnum.util and stdnum.numdb. The functionality to call format() in a country-specific IBAN implementation was also dropped because it was not used.
* Introduce get_cc_module() utility functionArthur de Jong2016-09-101-13/+12
| | | | | | This changes the get_vat_module() function to a more generic get_cc_module() function so that it can also be used for other things like IBAN checking.
* Fix get_module_description()Arthur de Jong2016-05-281-1/+1
| | | | This fixes the initial implementation in 3f6d52a.
* Implement online TC Kimlik checkArthur de Jong2016-04-091-1/+19
| | | | | This refactors out the SOAP client function that was implemented for VIES to the stdnum.utils module.
* Code style improvementsArthur de Jong2015-10-111-12/+18
| | | | | | | Ensure that regular expressions are r'' strings, avoid too long lines and fix line wrapping. Also avoid catching toplevel Exception when possible and use binascii for hex to binary conversion which is available in both Python 2 and 3.
* Move finding VAT module to utilArthur de Jong2015-10-051-1/+20
| | | | | This moves the finding of a VAT module to the util module so that it can be more easily re-used for non-EU countries.
* Only catch ExceptionArthur de Jong2014-10-181-1/+1
|
* Add pragma: no cover for Python 3Arthur de Jong2013-12-311-1/+1
| | | | Some statements are not covered in Python 3 tests.
* Try to replace Unicode characters with ASCIIArthur de Jong2013-11-081-2/+76
| | | | | | | | | This changes the stdnum.util.clean() method that is used by all modules to replace alternative Unicode dashes, dots, etc. by their ASCII equivalent so the numbers will be automatically converted and validated. Inspiration for this change came from https://github.com/JNRowe/pyisbn/pull/6
* Use validate() in stdnum.utilArthur de Jong2013-06-081-1/+1
|
* Raise a proper exception if cleaning failsArthur de Jong2013-06-081-1/+6
|
* Revert generating stdnum docstring dynamicallyArthur de Jong2013-06-071-1/+1
| | | | | | | | | | | | | Generating the docstring dynamically results in all stdnum modules being imported for every import from any stdnum module which is a performance hit. So we switch back to a manually generated list, using: from stdnum.util import get_module_list print '\n'.join(get_module_list()) This also shortens a few short descriptions to attempt to fit things on one line.
* Use a cleaner way to get all stdnum modulesArthur de Jong2013-04-261-3/+6
| | | | This mechanism should work from Python 2.6 up to and including Python 3.3.
* generate part of the stdnum docstring based on ↵Arthur de Jong2012-09-221-0/+25
| | | | | | introspection of the modules git-svn-id: http://arthurdejong.org/svn/python-stdnum/python-stdnum@176 9dea7c4f-944c-4273-ac1a-574ede026edc
* ensure that the module docstrings are in a somewhat more ↵Arthur de Jong2012-02-261-1/+6
| | | | | | usable format git-svn-id: http://arthurdejong.org/svn/python-stdnum/python-stdnum@165 9dea7c4f-944c-4273-ac1a-574ede026edc
* use introspection to find number modules and test themArthur de Jong2012-02-191-0/+14
| | | | git-svn-id: http://arthurdejong.org/svn/python-stdnum/python-stdnum@150 9dea7c4f-944c-4273-ac1a-574ede026edc
* use the luhn module where possibleArthur de Jong2012-02-121-10/+0
| | | | git-svn-id: http://arthurdejong.org/svn/python-stdnum/python-stdnum@126 9dea7c4f-944c-4273-ac1a-574ede026edc
* implement a digitsum() function to find the sub of all ↵Arthur de Jong2012-02-111-6/+16
| | | | | | digits in a number git-svn-id: http://arthurdejong.org/svn/python-stdnum/python-stdnum@113 9dea7c4f-944c-4273-ac1a-574ede026edc
* implement a stdnum.util module for holding utility ↵Arthur de Jong2012-02-041-0/+29
functions (for now clean()) git-svn-id: http://arthurdejong.org/svn/python-stdnum/python-stdnum@100 9dea7c4f-944c-4273-ac1a-574ede026edc