python-stdnum branch master updated. 1.12-2-g388bac9
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
python-stdnum branch master updated. 1.12-2-g388bac9
- From: Commits of the python-stdnum project <python-stdnum-commits [at] lists.arthurdejong.org>
- To: python-stdnum-commits [at] lists.arthurdejong.org
- Reply-to: python-stdnum-users [at] lists.arthurdejong.org, python-stdnum-commits [at] lists.arthurdejong.org
- Subject: python-stdnum branch master updated. 1.12-2-g388bac9
- Date: Sat, 9 Nov 2019 15:23:33 +0100 (CET)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-stdnum".
The branch, master has been updated
via 388bac9d3df5e40d7d7f8bb112f114d05f10b7b5 (commit)
from a45d4f705e7f59ee3e6314491c47199d0d5aa581 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://arthurdejong.org/git/python-stdnum/commit/?id=388bac9d3df5e40d7d7f8bb112f114d05f10b7b5
commit 388bac9d3df5e40d7d7f8bb112f114d05f10b7b5
Author: Kurt Keller <Kurt@pinboard.jp>
Date: Mon Nov 4 23:01:20 2019 +0100
Add format to iso11649
Closes https://github.com/arthurdejong/python-stdnum/pull/171
diff --git a/stdnum/iso11649.py b/stdnum/iso11649.py
index f176852..d0b784f 100644
--- a/stdnum/iso11649.py
+++ b/stdnum/iso11649.py
@@ -41,6 +41,8 @@ True
Traceback (most recent call last):
...
InvalidChecksum: ...
+>>> format('RF18539007547034')
+'RF18 5390 0754 7034'
"""
from stdnum.exceptions import *
@@ -73,3 +75,14 @@ def is_valid(number):
return bool(validate(number))
except ValidationError:
return False
+
+
+def format(number):
+ """Format the number provided for output.
+
+ Blocks of 4 characters, the last block can be less than 4 characters. See
+ https://www.paymentstandards.ch/dam/downloads/ig-qr-bill-en.pdf chapter
+ 3.6.2.
+ """
+ number = compact(number)
+ return ' '.join(number[i:i + 4] for i in range(0, len(number), 4))
-----------------------------------------------------------------------
Summary of changes:
stdnum/iso11649.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
hooks/post-receive
--
python-stdnum
- python-stdnum branch master updated. 1.12-2-g388bac9,
Commits of the python-stdnum project