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/internet/zh_CN | |
parent | 4f884c9abc32990b4061a1bb6997b4b37e58ea0b (diff) |
venv
Diffstat (limited to 'venv/lib/python3.11/site-packages/faker/providers/internet/zh_CN')
2 files changed, 103 insertions, 0 deletions
diff --git a/venv/lib/python3.11/site-packages/faker/providers/internet/zh_CN/__init__.py b/venv/lib/python3.11/site-packages/faker/providers/internet/zh_CN/__init__.py new file mode 100644 index 0000000..6db322e --- /dev/null +++ b/venv/lib/python3.11/site-packages/faker/providers/internet/zh_CN/__init__.py @@ -0,0 +1,103 @@ +from collections import OrderedDict + +from faker.utils.decorators import slugify + +from .. import Provider as InternetProvider + + +class Provider(InternetProvider): + user_name_formats = ( + "{{last_romanized_name}}.{{first_romanized_name}}", + "{{first_romanized_name}}.{{last_romanized_name}}", + "{{first_romanized_name}}##", + "?{{last_romanized_name}}", + ) + + tlds = OrderedDict( + ( + ("cn", 0.8), + ("net", 0.1), + ("com", 0.05), + ("org", 0.05), + ) + ) + + second_level_domains = ( + "ac", + "com", + "edu", + "gov", + "mil", + "net", + "org", + "ah", + "bj", + "cq", + "fj", + "gd", + "gs", + "gz", + "gx", + "ha", + "hb", + "he", + "hi", + "hk", + "hl", + "hn", + "jl", + "js", + "jx", + "ln", + "mo", + "nm", + "nx", + "qh", + "sc", + "sd", + "sh", + "sn", + "sx", + "tj", + "xj", + "xz", + "yn", + "zj", + ) + + domain_formats = ( + "##", + "??", + "{{first_romanized_name}}", + "{{last_romanized_name}}", + "{{first_romanized_name}}{{last_romanized_name}}", + "{{last_romanized_name}}{{last_romanized_name}}", + "{{first_romanized_name}}{{first_romanized_name}}", + ) + + @slugify + def domain_word(self) -> str: + pattern: str = self.random_element(self.domain_formats) + if "#" in pattern or "?" in pattern: + return self.bothify(pattern) + else: + return self.generator.parse(pattern) + + def domain_name(self, levels: int = 1) -> str: + if levels < 1: + raise ValueError("levels must be greater than or equal to 1") + if levels == 1: + domain_word = self.domain_word() + # Avoids he.cn as seen in issue #687 + while domain_word in self.second_level_domains: + domain_word = self.domain_word() + return domain_word + "." + self.tld() + elif levels == 2: + my_tld = self.tld() + if my_tld == "cn": + my_second_level: str = self.random_element(self.second_level_domains) + else: + my_second_level = self.domain_word() + return self.domain_word() + "." + my_second_level + "." + my_tld + else: + return self.domain_word() + "." + self.domain_name(levels - 1) diff --git a/venv/lib/python3.11/site-packages/faker/providers/internet/zh_CN/__pycache__/__init__.cpython-311.pyc b/venv/lib/python3.11/site-packages/faker/providers/internet/zh_CN/__pycache__/__init__.cpython-311.pyc Binary files differnew file mode 100644 index 0000000..35c4f32 --- /dev/null +++ b/venv/lib/python3.11/site-packages/faker/providers/internet/zh_CN/__pycache__/__init__.cpython-311.pyc |