summaryrefslogtreecommitdiff
path: root/venv/lib/python3.11/site-packages/faker/providers/company/fr_CH
diff options
context:
space:
mode:
Diffstat (limited to 'venv/lib/python3.11/site-packages/faker/providers/company/fr_CH')
-rw-r--r--venv/lib/python3.11/site-packages/faker/providers/company/fr_CH/__init__.py40
-rw-r--r--venv/lib/python3.11/site-packages/faker/providers/company/fr_CH/__pycache__/__init__.cpython-311.pycbin0 -> 2262 bytes
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
new 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
Binary files differ