diff options
author | cyfraeviolae <cyfraeviolae> | 2024-04-03 03:10:44 -0400 |
---|---|---|
committer | cyfraeviolae <cyfraeviolae> | 2024-04-03 03:10:44 -0400 |
commit | 6d7ba58f880be618ade07f8ea080fe8c4bf8a896 (patch) | |
tree | b1c931051ffcebd2bd9d61d98d6233ffa289bbce /venv/lib/python3.11/site-packages/faker/providers/company/fr_CH | |
parent | 4f884c9abc32990b4061a1bb6997b4b37e58ea0b (diff) |
venv
Diffstat (limited to 'venv/lib/python3.11/site-packages/faker/providers/company/fr_CH')
2 files changed, 40 insertions, 0 deletions
diff --git a/venv/lib/python3.11/site-packages/faker/providers/company/fr_CH/__init__.py b/venv/lib/python3.11/site-packages/faker/providers/company/fr_CH/__init__.py new file mode 100644 index 0000000..35d3a8f --- /dev/null +++ b/venv/lib/python3.11/site-packages/faker/providers/company/fr_CH/__init__.py @@ -0,0 +1,40 @@ +from typing import List + +from ..fr_FR import Provider as CompanyProvider + + +class Provider(CompanyProvider): + company_suffixes = ("SA", "Sàrl.") + + def ide(self) -> str: + """ + Generates a IDE number (9 digits). + http://www.bfs.admin.ch/bfs/portal/fr/index/themen/00/05/blank/03/02.html + """ + + def _checksum(digits: List[int]) -> int: + factors = (5, 4, 3, 2, 7, 6, 5, 4) + sum_ = 0 + for i in range(len(digits)): + sum_ += digits[i] * factors[i] + return sum_ % 11 + + while True: + # create an array of first 8 elements initialized randomly + digits = self.generator.random.sample(range(10), 8) + # sum those 8 digits according to (part of) the "modulo 11" + sum_ = _checksum(digits) + # determine the last digit to make it qualify the test + control_number = 11 - sum_ + if control_number != 10: + digits.append(control_number) + break + + digits = "".join([str(digit) for digit in digits]) + # finally return our random but valid BSN + return "CHE-" + digits[0:3] + "." + digits[3:6] + "." + digits[6:9] + + uid = ide + # uid: german name for ide + idi = ide + # idi: italian name for ide diff --git a/venv/lib/python3.11/site-packages/faker/providers/company/fr_CH/__pycache__/__init__.cpython-311.pyc b/venv/lib/python3.11/site-packages/faker/providers/company/fr_CH/__pycache__/__init__.cpython-311.pyc Binary files differnew file mode 100644 index 0000000..fd5c1c3 --- /dev/null +++ b/venv/lib/python3.11/site-packages/faker/providers/company/fr_CH/__pycache__/__init__.cpython-311.pyc |