lists.arthurdejong.org
RSS feed

python-stdnum branch master updated. 1.17-52-g8e76cd2

[Date Prev][Date Next] [Thread Prev][Thread Next]

python-stdnum branch master updated. 1.17-52-g8e76cd2



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  8e76cd289c5278e03dd502a37d5cb7506f3c3d0e (commit)
      from  45f098b3664a11ef51cd66a11773bab923b02c91 (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=8e76cd289c5278e03dd502a37d5cb7506f3c3d0e

commit 8e76cd289c5278e03dd502a37d5cb7506f3c3d0e
Author: Leandro Regueiro <leandro.regueiro@gmail.com>
Date:   Sun Oct 23 11:43:10 2022 +0200

    Pad with zeroes in a more readable manner
    
    Closes https://github.com/arthurdejong/python-stdnum/pull/340

diff --git a/stdnum/cr/cpf.py b/stdnum/cr/cpf.py
index 105a0e1..1d09887 100644
--- a/stdnum/cr/cpf.py
+++ b/stdnum/cr/cpf.py
@@ -67,9 +67,9 @@ def compact(number):
     parts = number.split('-')
     if len(parts) == 3:
         # Pad each group with zeroes
-        parts[0] = '0' * (2 - len(parts[0])) + parts[0]
-        parts[1] = '0' * (4 - len(parts[1])) + parts[1]
-        parts[2] = '0' * (4 - len(parts[2])) + parts[2]
+        parts[0] = parts[0].zfill(2)
+        parts[1] = parts[1].zfill(4)
+        parts[2] = parts[2].zfill(4)
     number = ''.join(parts)
     if len(number) == 9:
         number = '0' + number  # Add leading zero

-----------------------------------------------------------------------

Summary of changes:
 stdnum/cr/cpf.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
python-stdnum