We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b3a42a1 commit ca80cc4Copy full SHA for ca80cc4
stdnum/fr/siren.py
@@ -34,6 +34,8 @@
34
InvalidChecksum: ...
35
>>> to_tva('443 121 975')
36
'46 443 121 975'
37
+>>> format('404833048')
38
+'404 833 048'
39
"""
40
41
from __future__ import annotations
@@ -83,3 +85,9 @@ def to_tva(number: str) -> str:
83
85
int(compact(number) + '12') % 97,
84
86
' ' if ' ' in number else '',
87
number)
88
+
89
90
+def format(number: str, separator: str = ' ') -> str:
91
+ """Reformat the number to the standard presentation format."""
92
+ number = compact(number)
93
+ return separator.join((number[:3], number[3:6], number[6:]))
0 commit comments