diff --git a/.gitignore b/.gitignore index b6e4761..2f2544e 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,10 @@ dmypy.json # Pyre type checker .pyre/ + +# Pycharm +.idea/ + +# Other +Pipfile.lock +phone_gen/__version__.py \ No newline at end of file diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..daa3e79 --- /dev/null +++ b/Pipfile @@ -0,0 +1,20 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] +requests = "==2.23.0" +pytest = "==5.4.2" +pytest-cov = "==2.8.1" +phonenumbers = "==8.12.3" +black = "==19.10b0" +mypy = "==0.770" +flake8 = "==3.8.1" +pep8-naming = "==0.10.0" + +[packages] +phone-gen = {editable = true,path = "."} + +[requires] +python_version = "3.8" diff --git a/dev_tools/patterns_generator.py b/dev_tools/patterns_generator.py new file mode 100644 index 0000000..ca531df --- /dev/null +++ b/dev_tools/patterns_generator.py @@ -0,0 +1,80 @@ +import json +import xml.etree.ElementTree as ElementTree +from datetime import datetime +from pathlib import Path +from re import findall +from typing import Dict, Generator, Tuple + +import requests + +RESOURCE = 'https://raw.githubusercontent.com/google/libphonenumber/master/resources/PhoneNumberMetadata.xml' + +TEMPLATE = """# Auto-generated file {datetime} UTC +# Resource: https://github.com/google/libphonenumber {version} + +PATTERNS = {patterns} + +""" + + +class RegexCompiler: + + def __init__(self, pattern: str): + pattern = pattern.replace('\n', '').replace(' ', '').replace('?:', '') + pattern = pattern.replace(r'\d', r'[\d]').replace(',', ':') + self.pattern = '({})'.format(pattern) + + def _group(self, group: str) -> str: + groups = findall(r'\((.*)\)', group) + if groups: + for i in groups: + group.replace(group, self._group(i)) + return '|'.join('({})'.format(i) for i in group.split('|')) + + def compile(self) -> str: + return self.pattern.replace(self.pattern, self._group(self.pattern)) + + +class Parser: + + def __init__(self, source: str): + self.root = ElementTree.fromstring(source) + self.line_tag = 'fixedLine' + self.pattern_tag = 'nationalNumberPattern' + + def render(self) -> Generator[Tuple[str, Dict[str, str]], None, None]: + for territory in self.root.iter('territory'): + attrs = territory.attrib + code = attrs.get('id', '1') + if code.isdigit(): + continue + value = {'code': attrs.get('countryCode', '')} + for fixed_line in territory.iter(self.line_tag): + for national_number_pattern in fixed_line.iter(self.pattern_tag): + value['pattern'] = RegexCompiler(national_number_pattern.text).compile() + yield code, value + + +def get_latest() -> str: + response = requests.get('https://github.com/google/libphonenumber/releases/latest') + return response.url.split('/')[-1] + + +def main(): + response = requests.get(RESOURCE) + parser = Parser(response.text) + data = {code: value for code, value in parser.render()} + root_path = Path(__file__).absolute().parent.parent + file = root_path.joinpath('phone_gen', 'patterns.py') + version = get_latest() + with file.open('wb') as _file: + temp = TEMPLATE.format( + datetime=datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'), + patterns=json.dumps({'info': 'libphonenumber {}'.format(version), 'data': data}, indent=4), + version=version + ) + _file.write(temp.encode()) + + +if __name__ == '__main__': + main() diff --git a/phone_gen/__init__.py b/phone_gen/__init__.py new file mode 100644 index 0000000..069b47d --- /dev/null +++ b/phone_gen/__init__.py @@ -0,0 +1,8 @@ +from .generator import PhoneNumber + +try: + from .__version__ import version as __version__ +except ImportError: # pragma: no cover + __version__ = "unknown" + +__all__ = ["PhoneNumber", "__version__"] diff --git a/phone_gen/generator.py b/phone_gen/generator.py new file mode 100644 index 0000000..1c00284 --- /dev/null +++ b/phone_gen/generator.py @@ -0,0 +1,283 @@ +""" +Modified StringGenerator https://github.com/paul-wolf/strgen +""" +import random +import string +from abc import ABCMeta, abstractmethod +from typing import List, Optional, Tuple + +from .patterns import PATTERNS + +SYSTEM_RANDOM = random.SystemRandom() +RANDINT = SYSTEM_RANDOM.randint +CHOICE = SYSTEM_RANDOM.choice +SAMPLE = SYSTEM_RANDOM.sample +SHUFFLE = SYSTEM_RANDOM.shuffle + +BSLASH = "\\" +LBRACE = "{" +RBRACE = "}" +LSQB = "[" +RSQB = "]" +LPAR = "(" +RPAR = ")" +COLON = ":" +MINUS = "-" +VBAR = "|" + +META_TOKENS = ( + LSQB, + RSQB, + LBRACE, + RBRACE, + LPAR, + RPAR, + VBAR, +) # type: Tuple[str, ...] + + +class NumberGeneratorException(Exception): + """Base Exception""" + + +class NumberGeneratorSyntaxException(NumberGeneratorException): + """Syntax Exception""" + + +class StringNode(metaclass=ABCMeta): + """The abstract class for all nodes""" + + @abstractmethod + def render(self): + ... # pragma: no cover + + +class Sequence: + """Render a sequence of nodes from the template.""" + + def __init__(self, seq: List[StringNode]): + self.seq = seq + + def render(self) -> str: + return "".join(i.render() for i in self.seq) + + +class SequenceOR(Sequence): + def render(self): + return self.seq[RANDINT(0, len(self.seq) - 1)].render() + + +class Literal(StringNode): + def __init__(self, chars: str): + self.literal = chars + + def render(self) -> str: + return self.literal + + +class CharacterSet(StringNode): + def __init__(self, chars: str, start: int, cnt: int): + self.chars = chars + self.start = start + self.cnt = cnt + + def render(self) -> str: + cnt = RANDINT(self.start, self.cnt) if self.start > -1 else self.cnt + return "".join(self.chars[RANDINT(0, len(self.chars) - 1)] for _ in range(cnt)) + + +class NumberGenerator: + _code = {"d": string.digits} + + def __init__(self, pattern: str): + self._pattern = pattern + self._index = -1 + self._seq = self._get_sequence() + + def _current(self) -> Optional[str]: + return self._pattern[self._index] if self._index < len(self._pattern) else None + + def _next(self) -> Optional[str]: + self._index += 1 + return self._current() + + def _lookahead(self) -> Optional[str]: + return ( + self._pattern[self._index + 1] + if self._index + 1 < len(self._pattern) + else None + ) + + def _last(self) -> Optional[str]: + return None if self._index == 0 else self._pattern[self._index - 1] + + def _get_quantifier(self) -> Tuple[int, int]: + start = -1 + self._next() + digits = "0" + while True: + d = self._next() + if not d: + raise NumberGeneratorException( + "Unexpected end of input getting quantifier" + ) + if d in (COLON, MINUS): + start = int(digits) + digits = "0" + continue + if d == RBRACE: + if self._last() in (COLON, MINUS): + raise NumberGeneratorSyntaxException( + "Quantifier range must be closed" + ) + break # pragma: no cover + if d.isnumeric(): + digits += d + else: + raise NumberGeneratorSyntaxException("Non-digit in count") + return start, int(digits) + + @staticmethod + def _get_character_range(first: str, last: str) -> str: + chars = "" + # support z-a as a range + if not ord(first) < ord(last): + first, last = last, first + for c in range(ord(first), ord(last) + 1): + chars += chr(c) + return chars + + def _get_character_set(self) -> CharacterSet: + chars = "" + cnt = 1 + start = 0 + + while True: + char = self._next() + if self._lookahead() == MINUS and not char == BSLASH: + f = char + self._next() # skip hyphen + char = self._next() # get far range + if not char or (char in META_TOKENS): + raise NumberGeneratorSyntaxException( + "unexpected end of class range" + ) + chars += self._get_character_range(f, char) + elif char == BSLASH: + if self._lookahead() in META_TOKENS: + char = self._next() + chars += char + continue + elif self._lookahead() in self._code: + char = self._next() + chars += self._code[char] + elif char and char not in META_TOKENS: + chars += char + if char == RSQB: + if self._lookahead() == LBRACE: + start, cnt = self._get_quantifier() + else: + start = -1 + cnt = 1 + break + if char and char in META_TOKENS and not self._last() == BSLASH: + raise NumberGeneratorSyntaxException( + "Un-escaped character in class definition: {}".format(char) + ) + if not char: + break # pragma: no cover + return CharacterSet(chars, start, cnt) + + def _get_literal(self) -> Literal: + chars = "" + char = self._current() + while True: + if char and char == BSLASH: + char = self._next() + if char: + chars += char + continue + elif not char or (char in META_TOKENS): + break # pragma: no cover + else: + chars += char + if self._lookahead() and self._lookahead() in META_TOKENS: + break + char = self._next() + return Literal(chars) + + def _get_sequence(self, level: int = 0) -> Sequence: + seq = [] + op = "" + left_operand = None + sequence_closed = False + while True: + char = self._next() + if not char: + break + if char and char not in META_TOKENS: + seq.append(self._get_literal()) + elif char == LSQB and not self._last() == BSLASH: + seq.append(self._get_character_set()) + elif char == LPAR and not self._last() == BSLASH: + seq.append(self._get_sequence(level + 1)) + elif char == RPAR and not self._last() == BSLASH: + # end of this sequence + if level == 0: + # there should be no parens here + raise NumberGeneratorSyntaxException("Extra closing parenthesis") + sequence_closed = True + break + elif char == VBAR and not self._last() == BSLASH: + op = char + else: + if char in META_TOKENS and not self._last() == BSLASH: + raise NumberGeneratorSyntaxException( + "Un-escaped special character: {}".format(char) + ) + + if op and not left_operand: + if not seq: + raise NumberGeneratorSyntaxException( + "Operator: {} with no left operand".format(op) + ) + left_operand = seq.pop() + elif op and len(seq) >= 1 and left_operand: + right_operand = seq.pop() + + if op == VBAR: + seq.append(SequenceOR([left_operand, right_operand])) + op = "" + left_operand = None + # right_operand = None + + # check for syntax errors + if op: + raise NumberGeneratorSyntaxException( + "Operator: {} with no right operand".format(op) + ) + if level > 0 and not sequence_closed: + raise NumberGeneratorSyntaxException("Missing closing parenthesis") + return Sequence(seq) + + def render(self) -> str: + return self._seq.render() + + +class PhoneNumber: + def __init__(self, code: str): + self.country = PATTERNS['data'].get(code.upper(), {}) + if not self.country: + raise NumberGeneratorException("Not found country {}".format(code)) + self.generator = NumberGenerator(self.country["pattern"]) + + @property + def info(self) -> str: + return PATTERNS["info"] + + def get_code(self) -> str: + return self.country["code"] + + def get_number(self, full: bool = True) -> str: + number = self.generator.render() + return "+{}{}".format(self.country["code"], number) if full else number diff --git a/phone_gen/patterns.py b/phone_gen/patterns.py new file mode 100644 index 0000000..efe0059 --- /dev/null +++ b/phone_gen/patterns.py @@ -0,0 +1,769 @@ +# Auto-generated file 2020-05-18 00:57:29 UTC +# Resource: https://github.com/google/libphonenumber v8.12.3 + +PATTERNS = { + "info": "libphonenumber v8.12.3", + "data": { + "AC": {"code": "247", "pattern": "((6[2-467][\\d]{3}))"}, + "AD": {"code": "376", "pattern": "(([78][\\d]{5}))"}, + "AE": {"code": "971", "pattern": "(([2-4679][2-8][\\d]{6}))"}, + "AF": { + "code": "93", + "pattern": "((([25][0-8])|([34][0-4])|(6[0-5])[2-9][\\d]{6}))", + }, + "AG": {"code": "1", "pattern": "((268(4(6[0-38])|(84))|(56[0-2])[\\d]{4}))"}, + "AI": {"code": "1", "pattern": "((264(292)|(4(6[12])|(9[78]))[\\d]{4}))"}, + "AL": { + "code": "355", + "pattern": "((([2358][16-9][\\d][2-9])|(4410)[\\d]{4})|(([2358][2-5][2-9])|(4([2-57-9][2-9])|(6[\\d]))[\\d]{5}))", + }, + "AM": { + "code": "374", + "pattern": "((((1[0-25])|(47)[\\d])|(2(2[2-46])|(3[1-8])|(4[2-69])|(5[2-7])|(6[1-9])|(8[1-7]))|(3[12]2)[\\d]{5}))", + }, + "AO": { + "code": "244", + "pattern": "((2[\\d]([0134][25-9])|([25-9][\\d])[\\d]{5}))", + }, + "AR": { + "code": "54", + "pattern": "((3888[013-9][\\d]{5})|((29(54)|(66))|(3(777)|(865))[2-8][\\d]{5})|(3(7(1[15])|(81))|(8(21)|(4[16])|(69)|(9[12]))[46][\\d]{5})|((2(2(2[59])|(44)|(52))|(3(26)|(44))|(473)|(9([07]2)|(2[26])|(34)|(46)))|(3327)[45][\\d]{5})|((2(284)|(302)|(657)|(920))|(3(4(8[27])|(92))|(541)|(755)|(878))[2-7][\\d]{5})|((2((26)|(62)2)|(32[03])|(477)|(9(42)|(83)))|(3(329)|(4([47]6)|(62)|(89))|(564))[2-6][\\d]{5})|(((11[1-8])|(670)[\\d])|(2(2(0[45])|(1[2-6])|(3[3-6]))|(3([06]4)|(7[45]))|(494)|(6(04)|(1[2-7])|([36][45])|(4[3-6]))|(80[45])|(9([17][4-6])|([48][45])|(9[3-6])))|(3(364)|(4(1[2-7])|([235][4-6])|(84))|(5(1[2-8])|([38][4-6]))|(6(2[45])|(44))|(7[069][45])|(8([03][45])|([17][2-6])|([58][3-6])))[\\d]{6})|(2(2(21)|(4[23])|(6[145])|(7[1-4])|(8[356])|(9[267]))|(3(16)|(3[13-8])|(43)|(5[346-8])|(9[3-5]))|(475)|(6(2[46])|(4[78])|(5[1568]))|(9(03)|(2[1457-9])|(3[1356])|(4[08])|([56][23])|(82))4[\\d]{5})|((2(2(57)|(81))|(3(24)|(46)|(92))|(9(01)|(23)|(64)))|(3(4(42)|(71))|(5(25)|(37)|(4[347])|(71))|(7(18)|(5[17])))[3-6][\\d]{5})|((2(2(02)|(2[3467])|(4[156])|(5[45])|(6[6-8])|(91))|(3(1[47])|(25)|([45][25])|(96))|(47[48])|(625)|(932))|(3(38[2578])|(4(0[0-24-9])|(3[78])|(4[457])|(58)|(6[03-9])|(72)|(83)|(9[136-8]))|(5(2[124])|([368][23])|(4[2689])|(7[2-6]))|(7(16)|(2[15])|(3[145])|(4[13])|(5[468])|(7[2-5])|(8[26]))|(8(2[5-7])|(3[278])|(4[3-5])|(5[78])|(6[1-378])|([78]7)|(94)))[4-6][\\d]{5}))", + }, + "AS": { + "code": "1", + "pattern": "((6846(22)|(33)|(44)|(55)|(77)|(88)|(9[19])[\\d]{4}))", + }, + "AT": { + "code": "43", + "pattern": "((1(11[\\d])|([2-9][\\d]{3:11}))|((316)|(463)|((51)|(66)|(73)2)[\\d]{3:10})|((2(1[467])|(2[13-8])|(5[2357])|(6[1-46-8])|(7[1-8])|(8[124-7])|(9[1458]))|(3(1[1-578])|(3[23568])|(4[5-7])|(5[1378])|(6[1-38])|(8[3-68]))|(4(2[1-8])|(35)|(7[1368])|(8[2457]))|(5(2[1-8])|(3[357])|(4[147])|(5[12578])|(6[37]))|(6(13)|(2[1-47])|(4[135-8])|(5[468]))|(7(2[1-8])|(35)|(4[13478])|(5[68])|(6[16-8])|(7[1-6])|(9[45]))[\\d]{4:10}))", + }, + "AU": { + "code": "61", + "pattern": "((8(51(0(0[03-9])|([12479][\\d])|(3[2-9])|(5[0-8])|(6[1-9])|(8[0-7]))|(1([0235689][\\d])|(1[0-69])|(4[0-589])|(7[0-47-9]))|(2(0[0-7])|(3[2-4])|([4-6][\\d])))|(91([0-57-9][\\d])|(6[0135-9])[\\d])[\\d]{3})|((2([0-26-9][\\d])|(3[0-8])|(4[02-9])|(5[0135-9]))|(3([0-3589][\\d])|(4[0-578])|(6[1-9])|(7[0-35-9]))|(7([013-57-9][\\d])|(2[0-8]))|(8(6[0-8])|([78][\\d])|(9[02-9]))[\\d]{6}))", + }, + "AW": {"code": "297", "pattern": "((5(2[\\d])|(8[1-9])[\\d]{4}))"}, + "AX": {"code": "358", "pattern": "((18[1-8][\\d]{3:6}))"}, + "AZ": { + "code": "994", + "pattern": "(((222[0-79][\\d])|(365([0-46-9][\\d])|(5[0-35-9]))[\\d]{4})|(((1[28])|(46)[\\d])|(2([045]2)|(1[24])|(2[34])|(33)|(6[23]))[\\d]{6}))", + }, + "BA": { + "code": "387", + "pattern": "(((3([05-79][2-9])|(1[4579])|([23][24-9])|(4[2-4689])|(8[2457-9]))|(49[2-579])|(5(0[2-49])|([13][2-9])|([268][2-4679])|(4[4689])|(5[2-79])|(7[2-69])|(9[2-4689]))[\\d]{5}))", + }, + "BB": { + "code": "1", + "pattern": "((246(2(2[78])|(7[0-4]))|(4(1[024-6])|(2[\\d])|(3[2-9]))|(5(20)|([34][\\d])|(54)|(7[1-3]))|(6(2[\\d])|(38))|(7[35]7)|(9(1[89])|(63))[\\d]{4}))", + }, + "BD": { + "code": "880", + "pattern": "(((4(31[\\d][\\d])|(423))|(5222)[\\d]{3}([\\d]{2})?)|(8332[6-9][\\d][\\d])|((3(03[56])|(224))|(4(22[25])|(653))[\\d]{3:4})|((3(42[47])|(529)|(823))|(4(027)|(525)|(65(28)|(8)))|(562)|(6257)|(7(1(5[3-5])|(6[12])|(7[156])|(89))|(22[589]56)|(32)|(42675)|(52([25689](56)|(8))|([347]8))|(71(6[1267])|(75)|(89))|(92374))|(82(2[59])|(32)56)|(9(03[23]56)|(23(256)|(373))|(31)|(5(1)|(2[4589]56)))[\\d]{3})|((3(02[348])|(22[35])|(324)|(422))|(4(22[67])|(32[236-9])|(6(2[46])|(5[57]))|(953))|(5526)|(6(024)|(6655))|(81)[\\d]{4:5})|((2(7(1[0-267])|(2[0-289])|(3[0-29])|(4[01])|(5[1-3])|(6[013])|(7[0178])|(91))|(8(0[125])|(1[1-6])|(2[0157-9])|(3[1-69])|(41)|(6[1-35])|(7[1-5])|(8[1-8])|(9[0-6]))|(9(0[0-2])|(1[0-4])|(2[568])|(3[3-6])|(5[5-7])|(6[0136-9])|(7[0-7])|(8[014-9])))|(3(0(2[025-79])|(3[2-4]))|(181)|(22[12])|(32[2356])|(824))|(4(02[09])|(22[348])|(32[045])|(523)|(6(27)|(54)))|(666(22)|(53))|(7(22[57-9])|(42[56])|(82[35])8)|(8(0[124-9])|(2(181)|(2[02-4679]8))|(4[12])|([5-7]2))|(9([04]2)|(2(2)|(328))|(81))[\\d]{4})|((2[45][\\d][\\d])|(3(1(2[5-7])|([5-7]))|(425)|(822))|(4(033)|(1[\\d])|([257]1)|(332)|(4(2[246])|(5[25]))|(6(2[35])|(56)|(62))|(8(23)|(54))|(92[2-5]))|(5(02[03489])|(22[457])|(32[35-79])|(42[46])|(6([18])|(53))|(724)|(826))|(6(023)|(2(2[2-5])|(5[3-5])|(8))|(32[3478])|(42[34])|(52[47])|(6([18])|(6(2[34])|(5[24])))|([78]2[2-5])|(92[2-6]))|(7(02)|(21[\\d])|([3-589]1)|(6[12])|(72[24]))|(8(217)|(3[12])|([5-7]1))|(9[24]1)[\\d]{5})|(((3[2-8])|(5[2-57-9])|(6[03-589])1)|(4[4689][18])[\\d]{5})|([59]1[\\d]{5}))", + }, + "BE": { + "code": "32", + "pattern": "((80[2-8][\\d]{5})|((1[0-69])|([23][2-8])|(4[23])|(5[\\d])|(6[013-57-9])|(71)|(8[1-79])|(9[2-4])[\\d]{6}))", + }, + "BF": { + "code": "226", + "pattern": "((2(0(49)|(5[23])|(6[56])|(9[016-9]))|(4(4[569])|(5[4-6])|(6[56])|(7[0179]))|(5([34][\\d])|(50)|(6[5-7]))[\\d]{4}))", + }, + "BG": { + "code": "359", + "pattern": "((2[\\d]{5:7})|((43[1-6])|(70[1-9])[\\d]{4:5})|(([36][\\d])|(4[124-7])|([57][1-9])|(8[1-6])|(9[1-7])[\\d]{5:6}))", + }, + "BH": { + "code": "973", + "pattern": "(((1(3[1356])|(6[0156])|(7[\\d])[\\d])|(6(1[16][\\d])|(500)|(6(0[\\d])|(3[12])|(44)|(7[7-9])|(88))|(9[69][69]))|(7(1(11)|(78))|(7[\\d][\\d]))[\\d]{4}))", + }, + "BI": {"code": "257", "pattern": "((22[\\d]{6}))"}, + "BJ": {"code": "229", "pattern": "((2(02)|(1[037])|(2[45])|(3[68])[\\d]{5}))"}, + "BL": {"code": "590", "pattern": "((590(2[7-9])|(5[12])|(87)[\\d]{4}))"}, + "BM": { + "code": "1", + "pattern": "((441([46][\\d][\\d])|(5(4[\\d])|(60)|(89))[\\d]{4}))", + }, + "BN": { + "code": "673", + "pattern": "((22[0-7][\\d]{4})|((2[013-9])|([34][\\d])|(5[0-25-9])[\\d]{5}))", + }, + "BO": { + "code": "591", + "pattern": "(((2(2[\\d][\\d])|(5(11)|([258][\\d])|(9[67]))|(6(12)|(2[\\d])|(9[34]))|(8(2[34])|(39)|(62)))|(3(3[\\d][\\d])|(4(6[\\d])|(8[24]))|(8(25)|(42)|(5[257])|(86)|(9[25]))|(9([27][\\d])|(3[2-4])|(4[248])|(5[24])|(6[2-6])))|(4(4[\\d][\\d])|(6(11)|([24689][\\d])|(72)))[\\d]{4}))", + }, + "BQ": { + "code": "599", + "pattern": "(((318[023])|(41(6[023])|(70))|(7(1[578])|(2[05])|(50)[\\d])[\\d]{3}))", + }, + "BR": { + "code": "55", + "pattern": "((([14689][1-9])|(2[12478])|(3[1-578])|(5[13-5])|(7[13-579])[2-5][\\d]{7}))", + }, + "BS": { + "code": "1", + "pattern": "((242(3(02)|([236][1-9])|(4[0-24-9])|(5[0-68])|(7[347])|(8[0-4])|(9[2-467]))|(461)|(502)|(6(0[1-4])|(12)|(2[013])|([45]0)|(7[67])|(8[78])|(9[89]))|(7(02)|(88))[\\d]{4}))", + }, + "BT": { + "code": "975", + "pattern": "(((2[3-6])|([34][5-7])|(5[236])|(6[2-46])|(7[246])|(8[2-4])[\\d]{5}))", + }, + "BW": { + "code": "267", + "pattern": "(((2(4[0-48])|(6[0-24])|(9[0578]))|(3(1[0-35-9])|(55)|([69][\\d])|(7[013]))|(4(6[03])|(7[1267])|(9[0-5]))|(5(3[0389])|(4[0489])|(7[1-47])|(88)|(9[0-49]))|(6(2[1-35])|(5[149])|(8[067]))[\\d]{4}))", + }, + "BY": { + "code": "375", + "pattern": "(((1(5(1[1-5])|([24][\\d])|(6[2-4])|(9[1-7]))|(6([235][\\d])|(4[1-7]))|(7[\\d][\\d]))|(2(1([246][\\d])|(3[0-35-9])|(5[1-9]))|(2([235][\\d])|(4[0-8]))|(3([26][\\d])|(3[02-79])|(4[024-7])|(5[03-7])))[\\d]{5}))", + }, + "BZ": { + "code": "501", + "pattern": "(((236)|(732)[\\d]{4})|([2-578][02][\\d]{5}))", + }, + "CA": { + "code": "1", + "pattern": "(((2(04)|([23]6)|([48]9)|(50))|(3(06)|(43)|(6[57]))|(4(03)|(1[68])|(3[178])|(50))|(5(06)|(1[49])|(48)|(79)|(8[17]))|(6(04)|(13)|(39)|(47)|(72))|(7(0[59])|(78)|(8[02]))|(8([06]7)|(19)|(25)|(73))|(90[25])[2-9][\\d]{6}))", + }, + "CC": { + "code": "61", + "pattern": "((8(51(0(02)|(31)|(60)|(89))|(118))|(91(0(1[0-2])|(29))|(1([28]2)|(50)|(79))|(2(10)|(64))|(3([06]8)|(22))|(4[29]8)|(62[\\d])|(70[23])|(959))[\\d]{3}))", + }, + "CD": {"code": "243", "pattern": "((12[\\d]{7})|([1-6][\\d]{6}))"}, + "CF": {"code": "236", "pattern": "((2[12][\\d]{6}))"}, + "CG": {"code": "242", "pattern": "((222[1-589][\\d]{5}))"}, + "CH": { + "code": "41", + "pattern": "(((2[12467])|(3[1-4])|(4[134])|(5[256])|(6[12])|([7-9]1)[\\d]{7}))", + }, + "CI": { + "code": "225", + "pattern": "(((2(0[023])|(1[02357])|([23][045])|(4[03-5]))|(3(0[06])|(1[069])|([2-4][07])|(5[09])|(6[08]))[\\d]{5}))", + }, + "CK": {"code": "682", "pattern": "(((2[\\d])|(3[13-7])|(4[1-5])[\\d]{3}))"}, + "CL": { + "code": "56", + "pattern": "((2(1982[0-6])|(3314[05-9])[\\d]{3})|((2(1(160)|(962))|(3(2[\\d][\\d])|(3(0[\\d])|(1[0-35-9])|(2[1-9])|(3[0-2])|(40))))|(80[1-9][\\d][\\d])|(9(3([0-57-9][\\d][\\d])|(6(0[02-9])|([1-9][\\d])))|(6([0-8][\\d][\\d])|(9([02-79][\\d])|(1[05-9])))|(7[1-9][\\d][\\d])|(9([03-9][\\d][\\d])|(1([0235-9][\\d])|(4[0-24-9]))|(2([0-79][\\d])|(8[0-46-9]))))[\\d]{4})|((22)|(3[2-5])|([47][1-35])|(5[1-3578])|(6[13-57])|(8[1-9])|(9[2458])[\\d]{7}))", + }, + "CM": {"code": "237", "pattern": "((2(22)|(33)[\\d]{6}))"}, + "CN": { + "code": "86", + "pattern": "(((10([02-79][\\d][\\d])|([18](0[1-9])|([1-9][\\d])))|(21([18](0[1-9])|([1-9][\\d]))|([2-79][\\d][\\d]))[\\d]{5})|((43[35])|(754)[\\d]{7:8})|(8(078[\\d]{7})|(51[\\d]{7:8}))|((10)|((2)|(85)1)|(43[35])|(754)(100[\\d][\\d])|(95[\\d]{3:4}))|((2[02-57-9])|(3(11)|(7[179]))|(4([15]1)|(3[12]))|(5(1[\\d])|(2[37])|(3[12])|(51)|(7[13-79])|(9[15]))|(7([39]1)|(5[57])|(6[09]))|(8(71)|(98))([02-8][\\d]{7})|(1(0(0[\\d][\\d]([\\d]{3})?)|([1-9][\\d]{5}))|([1-9][\\d]{6}))|(9([0-46-9][\\d]{6})|(5[\\d]{3}([\\d]([\\d]{2})?)?)))|((3(1[02-9])|(35)|(49)|(5[\\d])|(7[02-68])|(9[1-68]))|(4(1[02-9])|(2[179])|(3[46-9])|(5[2-9])|(6[47-9])|(7[\\d])|(8[23]))|(5(3[03-9])|(4[36])|(5[02-9])|(6[1-46])|(7[028])|(80)|(9[2-46-9]))|(6(3[1-5])|(6[0238])|(9[12]))|(7(01)|([17][\\d])|(2[248])|(3[04-9])|(4[3-6])|(5[0-3689])|(6[2368])|(9[02-9]))|(8(1[236-8])|(2[5-7])|(3[\\d])|(5[2-9])|(7[02-9])|(8[36-8])|(9[1-7]))|(9(0[1-3689])|(1[1-79])|([379][\\d])|(4[13])|(5[1-5]))([02-8][\\d]{6})|(1(0(0[\\d][\\d]([\\d]{2})?)|([1-9][\\d]{4}))|([1-9][\\d]{5}))|(9([0-46-9][\\d]{5})|(5[\\d]{3:5}))))", + }, + "CO": {"code": "57", "pattern": "(([124-8][2-9][\\d]{6}))"}, + "CR": { + "code": "506", + "pattern": "((210[7-9][\\d]{4})|(2([024-7][\\d])|(1[1-9])[\\d]{5}))", + }, + "CU": { + "code": "53", + "pattern": "(((3[23])|(48)[\\d]{4:6})|((31)|(4[36])|(8(0[25])|(78)[\\d])[\\d]{6})|((2[1-4])|(4[1257])|(7[\\d])[\\d]{5:6}))", + }, + "CV": { + "code": "238", + "pattern": "((2(2[1-7])|(3[0-8])|(4[12])|(5[1256])|(6[\\d])|(7[1-3])|(8[1-5])[\\d]{4}))", + }, + "CW": { + "code": "599", + "pattern": "((9(4(3[0-5])|(4[14])|(6[\\d]))|(50[\\d])|(7(2[014])|(3[02-9])|(4[4-9])|(6[357])|(77)|(8[7-9]))|(8(3[39])|([46][\\d])|(7[01])|(8[57-9]))[\\d]{4}))", + }, + "CX": { + "code": "61", + "pattern": "((8(51(0(01)|(30)|(59)|(88))|(1(17)|(46)|(75))|(235))|(91(00[6-9])|(1([28]1)|(49)|(78))|(2(09)|(63))|(3(12)|(26)|(75))|(4(56)|(97))|(64[\\d])|(7(0[01])|(1[0-2]))|(958))[\\d]{3}))", + }, + "CY": {"code": "357", "pattern": "((2[2-6][\\d]{6}))"}, + "CZ": { + "code": "420", + "pattern": "(((2[\\d])|(3[1257-9])|(4[16-9])|(5[13-9])[\\d]{7}))", + }, + "DE": { + "code": "49", + "pattern": "(((32)|(49[4-6][\\d])[\\d]{9})|(49[0-7][\\d]{3:9})|(([34]0)|([68]9)[\\d]{3:13})|((2(0[1-689])|([1-3569][\\d])|(4[0-8])|(7[1-7])|(8[0-7]))|(3([3569][\\d])|(4[0-79])|(7[1-7])|(8[1-8]))|(4(1[02-9])|([2-48][\\d])|(5[0-6])|(6[0-8])|(7[0-79]))|(5(0[2-8])|([124-6][\\d])|([38][0-8])|([79][0-7]))|(6(0[02-9])|([1-358][\\d])|([47][0-8])|(6[1-9]))|(7(0[2-8])|(1[1-9])|([27][0-7])|(3[\\d])|([4-6][0-8])|(8[0-5])|(9[013-7]))|(8(0[2-9])|(1[0-79])|(2[\\d])|(3[0-46-9])|(4[0-6])|(5[013-9])|(6[1-8])|(7[0-8])|(8[0-24-6]))|(9(0[6-9])|([1-4][\\d])|([589][0-7])|(6[0-8])|(7[0-467]))[\\d]{3:12}))", + }, + "DJ": {"code": "253", "pattern": "((2(1[2-5])|(7[45])[\\d]{5}))"}, + "DK": { + "code": "45", + "pattern": "((([2-7][\\d])|(8[126-9])|(9[1-46-9])[\\d]{6}))", + }, + "DM": { + "code": "1", + "pattern": "((767(2(55)|(66))|(4(2[01])|(4[0-25-9]))|(50[0-4])[\\d]{4}))", + }, + "DO": { + "code": "1", + "pattern": "((8([04]9[2-9][\\d][\\d])|(29(2([0-59][\\d])|(6[04-9])|(7[0-27])|(8[0237-9]))|(3([0-35-9][\\d])|(4[7-9]))|([45][\\d][\\d])|(6([0-27-9][\\d])|([3-5][1-9])|(6[0135-8]))|(7(0[013-9])|([1-37][\\d])|(4[1-35689])|(5[1-4689])|(6[1-57-9])|(8[1-79])|(9[1-8]))|(8(0[146-9])|(1[0-48])|([248][\\d])|(3[1-79])|(5[01589])|(6[013-68])|(7[124-8])|(9[0-8]))|(9([0-24][\\d])|(3[02-46-9])|(5[0-79])|(60)|(7[0169])|(8[57-9])|(9[02-9])))[\\d]{4}))", + }, + "DZ": { + "code": "213", + "pattern": "((9619[\\d]{5})|((1[\\d])|(2[013-79])|(3[0-8])|(4[0135689])[\\d]{6}))", + }, + "EC": {"code": "593", "pattern": "(([2-7][2-7][\\d]{6}))"}, + "EE": { + "code": "372", + "pattern": "(((3[23589])|(4[3-8])|(6[\\d])|(7[1-9])|(88)[\\d]{5}))", + }, + "EG": { + "code": "20", + "pattern": "((13[23][\\d]{6})|((15)|(57)[\\d]{6:7})|((2[2-4])|(3)|(4[05-8])|(5[05])|(6[24-689])|(8[2468])|(9[235-7])[\\d]{7}))", + }, + "EH": {"code": "212", "pattern": "((528[89][\\d]{5}))"}, + "ER": { + "code": "291", + "pattern": "(((1(1[12568])|([24]0)|(55)|(6[146]))|(8[\\d][\\d])[\\d]{4}))", + }, + "ES": { + "code": "34", + "pattern": "((96906(0[0-8])|(1[1-9])|([2-9][\\d])[\\d][\\d])|(9(69(0[0-57-9])|([1-9][\\d]))|(73([0-8][\\d])|(9[1-9]))[\\d]{4})|((8([1356][\\d])|([28][0-8])|([47][1-9]))|(9([135][\\d])|([268][0-8])|(4[1-9])|(7[124-9]))[\\d]{6}))", + }, + "ET": { + "code": "251", + "pattern": "((116671[\\d]{3})|((11(1(1[124])|(2[2-7])|(3[1-5])|(5[5-8])|(8[6-8]))|(2(13)|(3[6-8])|(5[89])|(7[05-9])|(8[2-6]))|(3(2[01])|(3[0-289])|(4[1289])|(7[1-4])|(87))|(4(1[69])|(3[2-49])|(4[0-3])|(6[5-8]))|(5(1[578])|(44)|(5[0-4]))|(6(1[78])|(2[69])|(39)|(4[5-7])|(5[1-5])|(6[0-59])|(8[015-8])))|(2(2(11[1-9])|(22[0-7])|(33[\\d])|(44[1467])|(66[1-68]))|(5(11[124-6])|(33[2-8])|(44[1467])|(55[14])|(66[1-3679])|(77[124-79])|(880)))|(3(3(11[0-46-8])|((22)|(55)[0-6])|(33[0134689])|(44[04])|(66[01467]))|(4(44[0-8])|(55[0-69])|(66[0-3])|(77[1-5])))|(4(6(119)|(22[0-24-7])|(33[1-5])|(44[13-69])|(55[14-689])|(660)|(88[1-4]))|(7((11)|(22)[1-9])|(33[13-7])|(44[13-6])|(55[1-689])))|(5(7(227)|(55[05])|((66)|(77)[14-8]))|(8(11[149])|(22[013-79])|(33[0-68])|(44[013-8])|(550)|(66[1-5])|(77[\\d])))[\\d]{4}))", + }, + "FI": { + "code": "358", + "pattern": "(((1[3-79][1-8])|([235689][1-8][\\d])[\\d]{2:6}))", + }, + "FJ": { + "code": "679", + "pattern": "((603[\\d]{4})|((3[0-5])|(6[25-7])|(8[58])[\\d]{5}))", + }, + "FK": {"code": "500", "pattern": "(([2-47][\\d]{4}))"}, + "FM": { + "code": "691", + "pattern": "((31(00[67])|(208)|(309)[\\d][\\d])|((3([2357]0[1-9])|(602)|(804)|(905))|((820)|(9[2-6][\\d])[\\d])[\\d]{3}))", + }, + "FO": {"code": "298", "pattern": "(((20)|([34][\\d])|(8[19])[\\d]{4}))"}, + "FR": {"code": "33", "pattern": "((([1-35][\\d])|(4[1-9])[\\d]{7}))"}, + "GA": {"code": "241", "pattern": "(([01]1[\\d]{6}))"}, + "GB": { + "code": "44", + "pattern": "(((1(1(3([0-58][\\d][\\d])|(73[03]))|((4[0-5])|(5[0-26-9])|(6[0-4])|([78][0-49])[\\d][\\d]))|(2((0[024-9])|(2[3-9])|(3[3-79])|(4[1-689])|([58][02-9])|(6[0-47-9])|(7[013-9])|(9[\\d])[\\d][\\d])|(1([0-7][\\d][\\d])|(8(0[\\d])|(20))))|((3(0[\\d])|(1[0-8])|([25][02-9])|(3[02-579])|([468][0-46-9])|(7[1-35-79])|(9[2-578]))|(4(0[03-9])|([137][\\d])|([28][02-57-9])|(4[02-69])|(5[0-8])|([69][0-79]))|(5(0[1-35-9])|([16][\\d])|(2[024-9])|(3[015689])|(4[02-9])|(5[03-9])|(7[0-35-9])|(8[0-468])|(9[0-57-9]))|(6(0[034689])|(1[\\d])|(2[0-35689])|([38][013-9])|(4[1-467])|(5[0-69])|(6[13-9])|(7[0-8])|(9[0-24578]))|(7(0[0246-9])|(2[\\d])|(3[0236-8])|(4[03-9])|(5[0-46-9])|(6[013-9])|(7[0-35-9])|(8[024-9])|(9[02-9]))|(8(0[35-9])|(2[1-57-9])|(3[02-578])|(4[0-578])|(5[124-9])|(6[2-69])|(7[\\d])|(8[02-9])|(9[02569]))|(9(0[02-589])|([18][\\d])|(2[02-689])|(3[1-57-9])|(4[2-9])|(5[0-579])|(6[2-47-9])|(7[0-24578])|(9[2-57]))[\\d][\\d]))|(2(0[013478])|(3[0189])|(4[017])|(8[0-46-9])|(9[0-2])[\\d]{3})[\\d]{4})|(1(2(0(46[1-4])|(87[2-9]))|(545[1-79])|(76(2[\\d])|(3[1-8])|(6[1-6]))|(9(7(2[0-4])|(3[2-5]))|(8(2[2-8])|(7[0-47-9])|(8[3-5]))))|(3(6(38[2-5])|(47[23]))|(8(47[04-9])|(64[0157-9])))|(4(044[1-7])|(20(2[23])|(8[\\d]))|(6(0(30)|(5[2-57])|(6[1-8])|(7[2-8]))|(140))|(8(052)|(87[1-3])))|(5(2(4(3[2-79])|(6[\\d]))|(76[\\d]))|(6(26[06-9])|(686)))|(6(06(4[\\d])|(7[4-79]))|(295[5-7])|(35[34][\\d])|(47(24)|(61))|(59(5[08])|(6[67])|(74))|(9(55[0-4])|(77[23])))|(7(26(6[13-9])|(7[0-7]))|((442)|(688)[\\d])|(50(2[0-3])|([3-68]2)|(76)))|(8(27[56][\\d])|(37(5[2-5])|(8[239]))|(843[2-58]))|(9(0(0(6[1-8])|(85))|(52[\\d]))|(3583)|(4(66[1-8])|(9(2[01])|(81)))|(63(23)|(3[1-4]))|(9561))[\\d]{3}))", + }, + "GD": { + "code": "1", + "pattern": "((473(2(3[0-2])|(69))|(3(2[89])|(86))|(4([06]8)|(3[5-9])|(4[0-49])|(5[5-79])|(73)|(90))|(63[68])|(7(58)|(84))|(800)|(938)[\\d]{4}))", + }, + "GE": { + "code": "995", + "pattern": "(((3([256][\\d])|(4[124-9])|(7[0-4]))|(4(1[\\d])|(2[2-7])|(3[1-79])|(4[2-8])|(7[239])|(9[1-7]))[\\d]{6}))", + }, + "GF": { + "code": "594", + "pattern": "((594([023][\\d])|(1[01])|(4[03-9])|(5[6-9])|(6[0-3])|(80)|(9[014])[\\d]{4}))", + }, + "GG": {"code": "44", "pattern": "((1481[25-9][\\d]{5}))"}, + "GH": { + "code": "233", + "pattern": "((3082[0-5][\\d]{4})|(3(0([237][\\d])|(8[01]))|([167](2[0-6])|(7[\\d])|(80))|(2(2[0-5])|(7[\\d])|(80))|(3(2[0-3])|(7[\\d])|(80))|(4(2[013-9])|(3[01])|(7[\\d])|(80))|(5(2[0-7])|(7[\\d])|(80))|(8(2[0-2])|(7[\\d])|(80))|(9([28]0)|(7[\\d]))[\\d]{5}))", + }, + "GI": { + "code": "350", + "pattern": "((21(6[24-7][\\d])|(90[0-2])[\\d]{3})|(2(00)|(2[25])[\\d]{5}))", + }, + "GL": { + "code": "299", + "pattern": "(((19)|(3[1-7])|(6[14689])|(8[14-79])|(9[\\d])[\\d]{4}))", + }, + "GM": { + "code": "220", + "pattern": "(((4([23][\\d][\\d])|(4(1[024679])|([6-9][\\d])))|(5(5(3[\\d])|(4[0-7]))|(6[67][\\d])|(7(1[04])|(2[035])|(3[58])|(48)))|(8[\\d]{3})[\\d]{3}))", + }, + "GN": { + "code": "224", + "pattern": "((3(0(24)|(3[12])|(4[1-35-7])|(5[13])|(6[189])|([78]1)|(9[1478]))|(1[\\d][\\d])[\\d]{4}))", + }, + "GP": { + "code": "590", + "pattern": "((590(0[1-68])|(1[0-2])|(2[0-68])|(3[1289])|(4[0-24-9])|(5[3-579])|(6[0189])|(7[08])|(8[0-689])|(9[\\d])[\\d]{4}))", + }, + "GQ": { + "code": "240", + "pattern": "((33[0-24-9][\\d][46][\\d]{4})|(3(33)|(5[\\d])[\\d][7-9][\\d]{4}))", + }, + "GR": { + "code": "30", + "pattern": "((2(1[\\d][\\d])|(2(2[1-46-9])|([36][1-8])|(4[1-7])|(5[1-4])|(7[1-5])|([89][1-9]))|(3(1[\\d])|(2[1-57])|([35][1-3])|(4[13])|(7[1-7])|(8[124-6])|(9[1-79]))|(4(1[\\d])|(2[1-8])|(3[1-4])|(4[13-5])|(6[1-578])|(9[1-5]))|(5(1[\\d])|([29][1-4])|(3[1-5])|(4[124])|(5[1-6]))|(6(1[\\d])|([269][1-6])|(3[1245])|(4[1-7])|(5[13-9])|(7[14])|(8[1-5]))|(7(1[\\d])|(2[1-5])|(3[1-6])|(4[1-7])|(5[1-57])|(6[135])|(9[125-7]))|(8(1[\\d])|(2[1-5])|([34][1-4])|(9[1-57]))[\\d]{6}))", + }, + "GT": {"code": "502", "pattern": "(([267][2-9][\\d]{6}))"}, + "GU": { + "code": "1", + "pattern": "((671(3(00)|(3[39])|(4[349])|(55)|(6[26]))|(4(00)|(56)|(7[1-9])|(8[0236-9]))|(5(55)|(6[2-5])|(88))|(6(3[2-578])|(4[24-9])|(5[34])|(78)|(8[235-9]))|(7([0479]7)|(2[0167])|(3[45])|(8[7-9]))|(8([2-57-9]8)|(6[48]))|(9(2[29])|(6[79])|(7[1279])|(8[7-9])|(9[78]))[\\d]{4}))", + }, + "GW": {"code": "245", "pattern": "((443[\\d]{6}))"}, + "GY": { + "code": "592", + "pattern": "(((2(1[6-9])|(2[0-35-9])|(3[1-4])|(5[3-9])|(6[\\d])|(7[0-24-79]))|(3(2[25-9])|(3[\\d]))|(4(4[0-24])|(5[56]))|(77[1-57])[\\d]{4}))", + }, + "HK": { + "code": "852", + "pattern": "(((384[0-5])|(58(0[1-8])|(1[2-9]))[\\d]{4})|((2([13-9][\\d])|(2[013-9]))|(3([1569][0-24-9])|(4[0-246-9])|(7[0-24-69])|(89))[\\d]{5}))", + }, + "HN": { + "code": "504", + "pattern": "((2(2(0[0139])|(1[1-36])|([23][\\d])|(4[04-6])|(5[57])|(6[24])|(7[0135689])|(8[01346-9])|(9[0-2]))|(4(07)|(2[3-59])|(3[13-689])|(4[0-68])|(5[1-35]))|(5(0[78])|(16)|(4[03-5])|(5[\\d])|(6[014-6])|(74)|(80))|(6([056][\\d])|(17)|(2[07])|(3[04])|(4[0-378])|([78][0-8])|(9[01]))|(7(6[46-9])|(7[02-9])|(8[034])|(91))|(8(79)|(8[0-357-9])|(9[1-57-9]))[\\d]{4}))", + }, + "HR": { + "code": "385", + "pattern": "((1[\\d]{7})|((2[0-3])|(3[1-5])|(4[02-47-9])|(5[1-3])[\\d]{6:7}))", + }, + "HT": { + "code": "509", + "pattern": "((2(2[\\d])|(5[1-5])|(81)|(9[149])[\\d]{5}))", + }, + "HU": { + "code": "36", + "pattern": "(((1[\\d])|([27][2-9])|(3[2-7])|(4[24-9])|(5[2-79])|(6[23689])|(8[2-57-9])|(9[2-69])[\\d]{6}))", + }, + "ID": { + "code": "62", + "pattern": "((2[124][\\d]{7:8})|(619[\\d]{8})|(2(1(14)|(500))|(2[\\d]{3})[\\d]{3})|(61[\\d]{5:8})|((2([35][1-4])|(6[0-8])|(7[1-6])|(8[\\d])|(9[1-8]))|(3(1)|([25][1-8])|(3[1-68])|(4[1-3])|(6[1-3568])|(7[0-469])|(8[\\d]))|(4(0[1-589])|(1[01347-9])|(2[0-36-8])|(3[0-24-68])|(43)|(5[1-378])|(6[1-5])|(7[134])|(8[1245]))|(5(1[1-35-9])|(2[25-8])|(3[124-9])|(4[1-3589])|(5[1-46])|(6[1-8]))|(6([25][\\d])|(3[1-69])|(4[1-6]))|(7(02)|([125][1-9])|([36][\\d])|(4[1-8])|(7[0-36-9]))|(9(0[12])|(1[013-8])|(2[0-479])|(5[125-8])|(6[23679])|(7[159])|(8[01346]))[\\d]{5:8}))", + }, + "IE": { + "code": "353", + "pattern": "(((1[\\d])|(21)[\\d]{6:7})|((2[24-9])|(4(0[24])|(5[\\d])|(7))|(5(0[45])|(1[\\d])|(8))|(6(1[\\d])|([237-9]))|(9(1[\\d])|([35-9]))[\\d]{5})|((23)|(4([1-469])|(8[\\d]))|(5[23679])|(6[4-6])|(7[14])|(9[04])[\\d]{7}))", + }, + "IL": { + "code": "972", + "pattern": "((153[\\d]{8:9})|(29[1-9][\\d]{5})|((2[0-8])|([3489][\\d])[\\d]{6}))", + }, + "IM": {"code": "44", "pattern": "((1624[5-8][\\d]{5}))"}, + "IN": { + "code": "91", + "pattern": "((2717([2-7][\\d])|(95)[\\d]{4})|((271[0-689])|(782[0-6])[2-7][\\d]{5})|((170[24])|(2(([02][2-79])|(90)[\\d])|(80[13468]))|((3(23)|(80))|(683)|(79[1-7])[\\d])|(4(20[24])|(72[2-8]))|(552[1-7])[\\d]{6})|((11)|(33)|(4[04])|(80)[2-7][\\d]{7})|((342)|(674)|(788)([0189][2-7])|([2-7][\\d])[\\d]{5})|((1(2[0-249])|(3[0-25])|(4[145])|([59][14])|(6[014])|(7[1257])|(8[01346]))|(2(1[257])|(3[013])|(4[01])|(5[0137])|(6[0158])|(78)|(8[1568])|(9[14]))|(3(26)|(4[13])|(5[34])|(6[01489])|(7[02-46])|(8[159]))|(4(1[36])|(2[1-47])|(3[15])|(5[12])|(6[0-26-9])|(7[014-9])|(8[013-57])|(9[014-7]))|(5(1[025])|(22)|([36][25])|(4[28])|([578]1)|(9[15]))|(6(12)|([2-47]1)|(5[17])|(6[13])|(80))|(7(12)|(2[14])|(3[134])|(4[47])|(5[15])|([67]1))|(8(16)|(2[014])|(3[126])|(6[136])|(7[078])|(8[34])|(91))[2-7][\\d]{6})|((1(2[35-8])|(3[346-9])|(4[236-9])|([59][0235-9])|(6[235-9])|(7[34689])|(8[257-9]))|(2(1[134689])|(3[24-8])|(4[2-8])|(5[25689])|(6[2-4679])|(7[3-79])|(8[2-479])|(9[235-9]))|(3(01)|(1[79])|(2[1245])|(4[5-8])|(5[125689])|(6[235-7])|(7[157-9])|(8[2-46-8]))|(4(1[14578])|(2[5689])|(3[2-467])|(5[4-7])|(6[35])|(73)|(8[2689])|(9[2389]))|(5([16][146-9])|(2[14-8])|(3[1346])|(4[14-69])|(5[46])|(7[2-4])|(8[2-8])|(9[246]))|(6(1[1358])|(2[2457])|(3[2-4])|(4[235-7])|(5[2-689])|(6[24578])|(7[235689])|(8[124-6]))|(7(1[013-9])|(2[0235-9])|(3[2679])|(4[1-35689])|(5[2-46-9])|([67][02-9])|(8[013-7])|(9[089]))|(8(1[1357-9])|(2[235-8])|(3[03-57-9])|(4[0-24-9])|(5[\\d])|(6[2457-9])|(7[1-6])|(8[1256])|(9[2-4]))[\\d][2-7][\\d]{5}))", + }, + "IO": {"code": "246", "pattern": "((37[\\d]{5}))"}, + "IQ": { + "code": "964", + "pattern": "((1[\\d]{7})|((2[13-5])|(3[02367])|(4[023])|(5[03])|(6[026])[\\d]{6:7}))", + }, + "IR": { + "code": "98", + "pattern": "(((1[137])|(2[13-68])|(3[1458])|(4[145])|(5[1468])|(6[16])|(7[1467])|(8[13467])([03-57][\\d]{7})|([16][\\d]{3}([\\d]{4})?)|([289][\\d]{3}([\\d]([\\d]{3})?)?))|(94(000[09])|(2(121)|([2689]0[\\d]))|(30[0-2][\\d])|(4(111)|(40[\\d]))[\\d]{4}))", + }, + "IS": { + "code": "354", + "pattern": "(((4(1[0-24-69])|(2[0-7])|([37][0-8])|(4[0-245])|(5[0-68])|(6[\\d])|(8[0-36-8]))|(5(05)|([156][\\d])|(2[02578])|(3[0-579])|(4[03-7])|(7[0-2578])|(8[0-35-9])|(9[013-689]))|(872)[\\d]{4}))", + }, + "IT": { + "code": "39", + "pattern": "((0669[0-79][\\d]{1:6})|(0(1([0159][\\d])|([27][1-5])|(31)|(4[1-4])|(6[1356])|(8[2-57]))|(2[\\d][\\d])|(3([0159][\\d])|(2[1-4])|(3[12])|([48][1-6])|(6[2-59])|(7[1-7]))|(4([0159][\\d])|([23][1-9])|(4[245])|(6[1-5])|(7[1-4])|(81))|(5([0159][\\d])|(2[1-5])|(3[2-6])|(4[1-79])|(6[4-6])|(7[1-578])|(8[3-8]))|(6([0-57-9][\\d])|(6[0-8]))|(7([0159][\\d])|(2[12])|(3[1-7])|(4[2-46])|(6[13569])|(7[13-6])|(8[1-59]))|(8([0159][\\d])|(2[3-578])|(3[1-356])|([6-8][1-5]))|(9([0159][\\d])|([238][1-5])|(4[12])|(6[1-8])|(7[1-6]))[\\d]{2:7}))", + }, + "JE": {"code": "44", "pattern": "((1534[0-24-8][\\d]{5}))"}, + "JM": { + "code": "1", + "pattern": "(((658(2([0-8][\\d])|(9[0-46-9]))|([3-9][\\d][\\d]))|(876(5(02)|(1[0-468])|(2[35])|(63))|(6(0[1-3579])|(1[0237-9])|([23][\\d])|(40)|(5[06])|(6[2-589])|(7[05])|(8[04])|(9[4-9]))|(7(0[2-689])|([1-6][\\d])|(8[056])|(9[45]))|(9(0[1-8])|(1[02378])|([2-8][\\d])|(9[2-468])))[\\d]{4}))", + }, + "JO": { + "code": "962", + "pattern": "((87(000)|(90[01])[\\d]{3})|((2(6(2[0-35-9])|(3[0-578])|(4[24-7])|(5[0-24-8])|([6-8][023])|(9[0-3]))|(7(0[1-79])|(10)|(2[014-7])|(3[0-689])|(4[019])|(5[0-3578])))|(32(0[1-69])|(1[1-35-7])|(2[024-7])|(3[\\d])|(4[0-3])|([5-7][023]))|(53(0[0-3])|([13][023])|(2[0-59])|(49)|(5[0-35-9])|(6[15])|(7[45])|(8[1-6])|(9[0-36-9]))|(6(2([05]0)|(22))|(3(00)|(33))|(4(0[0-25])|(1[2-467])|(2[0569])|([38][07-9])|(4[025689])|(6[0-589])|(7[\\d])|(9[0-2]))|(5([01][056])|(2[034])|(3[0-57-9])|(4[178])|(5[0-69])|(6[0-35-9])|(7[1-379])|(8[0-68])|(9[0239])))|(87(20)|(7[078])|(99))[\\d]{4}))", + }, + "JP": { + "code": "81", + "pattern": "(((1(1[235-8])|(2[3-6])|(3[3-9])|(4[2-6])|([58][2-8])|(6[2-7])|(7[2-9])|(9[1-9]))|((2[2-9])|([36][1-9])[\\d])|(4([2-578][\\d])|(6[02-8])|(9[2-59]))|(5([2-589][\\d])|(6[1-9])|(7[2-8]))|(7([25-9][\\d])|(3[4-9])|(4[02-9]))|(8([2679][\\d])|(3[2-9])|(4[5-9])|(5[1-9])|(8[03-9]))|(9([2-58][\\d])|([679][1-9]))[\\d]{6}))", + }, + "KE": { + "code": "254", + "pattern": "(((4[245])|(5[1-79])|(6[01457-9])[\\d]{5:7})|((4[136])|(5[08])|(62)[\\d]{7})|(([24]0)|(66)[\\d]{6:7}))", + }, + "KG": { + "code": "996", + "pattern": "((312(5[0-79][\\d])|(9([0-689][\\d])|(7[0-24-9]))[\\d]{3})|((3(1(2[0-46-8])|(3[1-9])|(47)|([56][\\d]))|(2(22)|(3[0-479])|(6[0-7]))|(4(22)|(5[6-9])|(6[\\d]))|(5(22)|(3[4-7])|(59)|(6[\\d]))|(6(22)|(5[35-7])|(6[\\d]))|(7(22)|(3[468])|(4[1-9])|(59)|([67][\\d]))|(9(22)|(4[1-8])|(6[\\d])))|(6(09)|(12)|(2[2-4])[\\d])[\\d]{5}))", + }, + "KH": { + "code": "855", + "pattern": "((23(4([2-4])|([56][\\d]))|([568][\\d][\\d])[\\d]{4})|(23[236-9][\\d]{5})|((2[4-6])|(3[2-6])|(4[2-4])|([5-7][2-5])(([237-9])|(4[56])|(5[\\d])[\\d]{5})|(6[\\d]{5:6})))", + }, + "KI": { + "code": "686", + "pattern": "((([24][\\d])|(3[1-9])|(50)|(65(02[12])|(12[56])|(22[89])|([3-5]00))|(7(27[\\d][\\d])|(3100)|(5(02[12])|(12[56])|(22[89])|([34](00)|(81))|(500)))|(8[0-5])[\\d]{3}))", + }, + "KM": {"code": "269", "pattern": "((7[4-7][\\d]{5}))"}, + "KN": { + "code": "1", + "pattern": "((869(2(29)|(36))|(302)|(4(6[015-9])|(70))[\\d]{4}))", + }, + "KP": { + "code": "850", + "pattern": "((((195)|(2)[\\d])|(3[19])|(4[159])|(5[37])|(6[17])|(7[39])|(85)[\\d]{6}))", + }, + "KR": { + "code": "82", + "pattern": "(((2)|(3[1-3])|([46][1-4])|(5[1-5])[1-9][\\d]{6:7})|((3[1-3])|([46][1-4])|(5[1-5])1[\\d]{2:3}))", + }, + "KW": { + "code": "965", + "pattern": "((2([23][\\d][\\d])|(4([1-35-9][\\d])|(44))|(5(0[034])|([2-46][\\d])|(5[1-3])|(7[1-7]))[\\d]{4}))", + }, + "KY": { + "code": "1", + "pattern": "((345(2(22)|(3[23])|(44)|(66))|(333)|(444)|(6(23)|(38)|(40))|(7(30)|(4[35-79])|(6[6-9])|(77))|(8(00)|(1[45])|(25)|([48]8))|(9(14)|(4[035-9]))[\\d]{4}))", + }, + "KZ": { + "code": "7", + "pattern": "(((33622)|(7(1(0([23][\\d])|(4[0-3])|(59)|(63))|(1([23][\\d])|(4[0-79])|(59))|(2([23][\\d])|(59))|(3(2[\\d])|(3[0-79])|(4[0-35-9])|(59))|(4([24][\\d])|(3[013-9])|(5[1-9]))|(5(2[\\d])|(3[1-9])|(4[0-7])|(59))|(6([2-4][\\d])|(5[19])|(61))|(72[\\d])|(8([27][\\d])|(3[1-46-9])|(4[0-5])))|(2(1([23][\\d])|(4[46-9])|(5[3469]))|(2(2[\\d])|(3[0679])|(46)|(5[12679]))|(3([2-4][\\d])|(5[139]))|(4(2[\\d])|(3[1-35-9])|(59))|(5([23][\\d])|(4[0-246-8])|(59)|(61))|(6(2[\\d])|(3[1-9])|(4[0-4])|(59))|(7([2379][\\d])|(40)|(5[279]))|(8([23][\\d])|(4[0-3])|(59))|(9(2[\\d])|(3[124578])|(59))))[\\d]{5}))", + }, + "LA": { + "code": "856", + "pattern": "(((2[13])|([35-7][14])|(41)|(8[1468])[\\d]{6}))", + }, + "LB": { + "code": "961", + "pattern": "(((([14-69][\\d])|(8[02-9])[\\d])|(7([2-57][\\d])|(62)|(8[0-7])|(9[04-9]))[\\d]{4}))", + }, + "LC": { + "code": "1", + "pattern": "((758(234)|(4(30)|(5[\\d])|(6[2-9])|(8[0-2]))|(57[0-2])|((63)|(75)8)[\\d]{4}))", + }, + "LI": { + "code": "423", + "pattern": "(((2(01)|(1[27])|(22)|(3[\\d])|(6[02-578])|(96))|(3(33)|(40)|(7[0135-7])|(8[048])|(9[0269]))[\\d]{4}))", + }, + "LK": { + "code": "94", + "pattern": "(((12[2-9])|(602)|(8[12][\\d])|(9(1[\\d])|(22)|(9[245]))[\\d]{6})|((11)|(2[13-7])|(3[1-8])|(4[157])|(5[12457])|(6[35-7])[2-57][\\d]{6}))", + }, + "LR": {"code": "231", "pattern": "(((2[\\d]{3})|(33333)[\\d]{4}))"}, + "LS": {"code": "266", "pattern": "((2[\\d]{7}))"}, + "LT": {"code": "370", "pattern": "(((3[1478])|(4[124-6])|(52)[\\d]{6}))"}, + "LU": { + "code": "352", + "pattern": "(((35[013-9])|(80[2-9])|(90[89])[\\d]{1:8})|((2[2-9])|(3[0-46-9])|([457][\\d])|(8[13-9])|(9[2-579])[\\d]{2:9}))", + }, + "LV": {"code": "371", "pattern": "((6[\\d]{7}))"}, + "LY": { + "code": "218", + "pattern": "(((2(0[56])|([1-6][\\d])|(7[124579])|(8[124]))|(3(1[\\d])|(2[2356]))|(4([17][\\d])|(2[1-357])|(5[2-4])|(8[124]))|(5([1347][\\d])|(2[1-469])|(5[13-5])|(8[1-4]))|(6([1-479][\\d])|(5[2-57])|(8[1-5]))|(7([13][\\d])|(2[13-79]))|(8([124][\\d])|(5[124])|(84))[\\d]{6}))", + }, + "MA": { + "code": "212", + "pattern": "((5(29([189][05])|(2[29])|(3[01]))|(38[89][05])[\\d]{4})|(5(2([015-7][\\d])|(2[02-9])|(3[0-578])|(4[02-46-8])|(8[0235-7])|(90))|(3([0-47][\\d])|(5[02-9])|(6[02-8])|(80)|(9[3-9]))|((4[067])|(5[03])[\\d])[\\d]{5}))", + }, + "MC": {"code": "377", "pattern": "(((870)|(9[2-47-9][\\d])[\\d]{5}))"}, + "MD": { + "code": "373", + "pattern": "((((2[1-9])|(3[1-79])[\\d])|(5(33)|(5[257]))[\\d]{5}))", + }, + "ME": { + "code": "382", + "pattern": "(((20[2-8])|(3([0-2][2-7])|(3[24-7]))|(4(0[2-467])|(1[2467]))|(5(0[2467])|(1[24-7])|(2[2-467]))[\\d]{5}))", + }, + "MF": { + "code": "590", + "pattern": "((590(0[079])|([14]3)|([27][79])|(30)|(5[0-268])|(87)[\\d]{4}))", + }, + "MG": { + "code": "261", + "pattern": "((2072[29][\\d]{4})|(20(2[\\d])|(4[47])|(5[3467])|(6[279])|(7[35])|(8[268])|(9[245])[\\d]{5}))", + }, + "MH": {"code": "692", "pattern": "(((247)|(528)|(625)[\\d]{4}))"}, + "MK": { + "code": "389", + "pattern": "(((2([23][\\d])|(5[0-24578])|(6[01])|(82))|(3(1[3-68])|([23][2-68])|(4[23568]))|(4([23][2-68])|(4[3-68])|(5[2568])|(6[25-8])|(7[24-68])|(8[4-68]))[\\d]{5}))", + }, + "ML": { + "code": "223", + "pattern": "((2(07[0-8])|(12[67])[\\d]{4})|((2(02)|(1[4-689]))|(4(0[0-4])|(4[1-39]))[\\d]{5}))", + }, + "MM": { + "code": "95", + "pattern": "(((1((2[\\d])|(3[56])|([89][0-6])[\\d])|(4(2[2-469])|(39)|(46)|(6[25])|(7[0-3])|(83))|(6))|(2(2(00)|(8[34]))|(4(0[\\d])|(2[246])|(39)|(46)|(62)|(7[0-3])|(83))|(51[\\d][\\d]))|(4(2(2[\\d][\\d])|(48[0-3]))|(3(20[\\d])|(4(70)|(83))|(56))|(420[\\d])|(5470))|(6(0([23])|(88[\\d]))|((124)|([56]2[\\d])[\\d])|(247[23])|(3(20[\\d])|(470))|(4(2[04][\\d])|(47[23]))|(7((3[\\d])|(8[01459])[\\d])|(4(39)|(60)|(7[013]))))[\\d]{4})|(5(2(2[\\d]{5:6})|(47[023][\\d]{4}))|((347[23])|(4(2(1)|(86))|(470))|(522[\\d])|(6(20[\\d])|(483))|(7(20[\\d])|(48[0-2]))|(8(20[\\d])|(47[02]))|(9(20[\\d])|(47[01]))[\\d]{4}))|(7((0470)|(4(25[\\d])|(470))|(5(202)|(470)|(96[\\d]))[\\d]{4})|(1(20[\\d]{4:5})|(4(70)|(83)[\\d]{4})))|(8(1(2[\\d]{5:6})|(4(10)|(7[01][\\d])[\\d]{3}))|(2(2[\\d]{5:6})|((320)|(490[\\d])[\\d]{3}))|((3(2[\\d][\\d])|(470))|(4[24-7])|(5(2[\\d])|(4[1-9])|(51)[\\d])|(6[23])[\\d]{4}))|((1[2-6][\\d])|(4(2[24-8])|(3[2-7])|([46][2-6])|(5[3-5]))|(5([27][2-8])|(3[2-68])|(4[24-8])|(5[23])|(6[2-4])|(8[24-7])|(9[2-7]))|(6([19]20)|(42[03-6])|((52)|(7[45])[\\d]))|(7([04][24-8])|([15][2-7])|(22)|(3[2-4]))|(8(1[2-689])|(2[2-8])|([35]2[\\d]))[\\d]{4})|(25[\\d]{5:6})|((2[2-9])|(6(1[2356])|([24][2-6])|(3[24-6])|(5[2-4])|(6[2-8])|(7[235-7])|(8[245])|(9[24]))|(8(3[24])|(5[245]))[\\d]{4}))", + }, + "MN": { + "code": "976", + "pattern": "(([12]2[1-3][\\d]{5:6})|(7(0[0-5][\\d])|(128)[\\d]{4})|(([12](1)|(27))|(5[368])[\\d]{6})|([12](3[2-8])|(4[2-68])|(5[1-4689])[\\d]{6:7}))", + }, + "MO": { + "code": "853", + "pattern": "(((28[2-9])|(8(11)|([2-57-9][\\d]))[\\d]{5}))", + }, + "MP": { + "code": "1", + "pattern": "((670(2(3[3-7])|(56)|(8[4-8]))|(32[1-38])|(4(33)|(8[348]))|(5(32)|(55)|(88))|(6(64)|(70)|(82))|(78[3589])|(8[3-9]8)|(989)[\\d]{4}))", + }, + "MQ": { + "code": "596", + "pattern": "((596(0[0-7])|(10)|(2[7-9])|(3[05-9])|(4[0-46-8])|([5-7][\\d])|(8[09])|(9[4-8])[\\d]{4}))", + }, + "MR": {"code": "222", "pattern": "(((25[08])|(35[\\d])|(45[1-7])[\\d]{5}))"}, + "MS": {"code": "1", "pattern": "((6644(1[0-3])|(91)[\\d]{4}))"}, + "MT": { + "code": "356", + "pattern": "((2(0([19][\\d])|(3[1-4])|(6[059]))|([1-357][\\d][\\d])[\\d]{4}))", + }, + "MU": { + "code": "230", + "pattern": "(((2([0346-8][\\d])|(1[0-7]))|(4([013568][\\d])|(2[4-7]))|(54([34][\\d])|(71))|(6[\\d][\\d])|(8(14)|(3[129]))[\\d]{4}))", + }, + "MV": { + "code": "960", + "pattern": "(((3(0[0-3])|(3[0-59]))|(6([57][02468])|(6[024-68])|(8[024689]))[\\d]{4}))", + }, + "MW": {"code": "265", "pattern": "(((1[2-9])|(21[\\d][\\d])[\\d]{5}))"}, + "MX": { + "code": "52", + "pattern": "(((2(0[01])|(2[1-9])|(3[1-35-8])|(4[13-9])|(7[1-689])|(8[1-578])|(9[467]))|(3(1[1-79])|([2458][1-9])|(3[\\d])|(7[1-8])|(9[1-5]))|(4(1[1-57-9])|([24-7][1-9])|(3[1-8])|(8[1-35-9])|(9[2-689]))|(5([56][\\d])|(88)|(9[1-79]))|(6(1[2-68])|([2-4][1-9])|(5[1-3689])|(6[1-57-9])|(7[1-7])|(8[67])|(9[4-8]))|(7([1-467][1-9])|(5[13-9])|(8[1-69])|(9[17]))|(8(1[\\d])|(2[13-689])|(3[1-6])|(4[124-6])|(6[1246-9])|(7[1-378])|(9[12479]))|(9(1[346-9])|(2[1-4])|(3[2-46-8])|(5[1348])|([69][1-9])|(7[12])|(8[1-8]))[\\d]{7}))", + }, + "MY": { + "code": "60", + "pattern": "(((3(2[0-36-9])|(3[0-368])|(4[0-278])|(5[0-24-8])|(6[0-467])|(7[1246-9])|(8[\\d])|(9[0-57])[\\d])|(4(2[0-689])|([3-79][\\d])|(8[1-35689]))|(5(2[0-589])|([3468][\\d])|(5[0-489])|(7[1-9])|(9[23]))|(6(2[2-9])|(3[1357-9])|([46][\\d])|(5[0-6])|(7[0-35-9])|(85)|(9[015-8]))|(7([2579][\\d])|(3[03-68])|(4[0-8])|(6[5-9])|(8[0-35-9]))|(8([24][2-8])|(3[2-5])|(5[2-7])|(6[2-589])|(7[2-578])|([89][2-9]))|(9(0[57])|(13)|([25-7][\\d])|([3489][0-8]))[\\d]{5}))", + }, + "MZ": { + "code": "258", + "pattern": "((2([1346][\\d])|(5[0-2])|([78][12])|(93)[\\d]{5}))", + }, + "NA": { + "code": "264", + "pattern": "((6(1([02-4][\\d][\\d])|(17))|(2(17)|(54[\\d])|(69)|(70))|(3(17)|(2[0237][\\d])|(34)|(6[289])|(7[01])|(81))|(4(17)|((27)|(41)|(5[25])[\\d])|(69)|(7[01]))|(5(17)|(2[236-8][\\d])|(69)|(7[01]))|(6(17)|(26[\\d])|(38)|(42)|(69)|(7[01]))|(7(17)|((2[2-4])|(30)[\\d])|(6[89])|(7[01]))[\\d]{4})|(6(1(2[2-7])|(3[01378])|(4[0-4])|(69)|(7[014]))|(25[0-46-8])|(32[\\d])|(4(2[0-27])|(4[016])|(5[0-357]))|(52[02-9])|(62[56])|(7(2[2-69])|(3[013]))[\\d]{4}))", + }, + "NC": { + "code": "687", + "pattern": "(((2[03-9])|(3[0-5])|(4[1-7])|(88)[\\d]{4}))", + }, + "NE": { + "code": "227", + "pattern": "((2(0(20)|(3[1-8])|(4[13-5])|(5[14])|(6[14578])|(7[1-578]))|(1(4[145])|(5[14])|(6[14-68])|(7[169])|(88))[\\d]{4}))", + }, + "NF": { + "code": "672", + "pattern": "(((1(06)|(17)|(28)|(39))|(3[0-2][\\d])[\\d]{3}))", + }, + "NG": { + "code": "234", + "pattern": "(((([1-356][\\d])|(4[02-8])|(8[2-9])[\\d])|(9(0[3-9])|([1-9][\\d]))[\\d]{5})|(7(0([013-689][\\d])|(2[0-24-9])[\\d]{3:4})|([1-79][\\d]{6}))|(([12][\\d])|(4[147])|(5[14579])|(6[1578])|(7[1-3578])[\\d]{5}))", + }, + "NI": {"code": "505", "pattern": "((2[\\d]{7}))"}, + "NL": { + "code": "31", + "pattern": "(((1([035][\\d])|(1[13-578])|(6[124-8])|(7[24])|(8[0-467]))|(2([0346][\\d])|(2[2-46-9])|(5[125])|(9[479]))|(3([03568][\\d])|(1[3-8])|(2[01])|(4[1-8]))|(4([0356][\\d])|(1[1-368])|(7[58])|(8[15-8])|(9[23579]))|(5([0358][\\d])|([19][1-9])|(2[1-57-9])|(4[13-8])|(6[126])|(7[0-3578]))|(7[\\d][\\d])[\\d]{6}))", + }, + "NO": { + "code": "47", + "pattern": "(((2[1-4])|(3[1-3578])|(5[1-35-7])|(6[1-4679])|(7[0-8])[\\d]{6}))", + }, + "NP": { + "code": "977", + "pattern": "(((1[0-6][\\d])|(99[02-6])[\\d]{5})|((2[13-79])|(3[135-8])|(4[146-9])|(5[135-7])|(6[13-9])|(7[15-9])|(8[1-46-9])|(9[1-7])[2-6][\\d]{5}))", + }, + "NR": {"code": "674", "pattern": "((444[\\d]{4}))"}, + "NU": {"code": "683", "pattern": "(([47][\\d]{3}))"}, + "NZ": { + "code": "64", + "pattern": "((24099[\\d]{3})|((3[2-79])|([49][2-9])|(6[235-9])|(7[2-57-9])[\\d]{6}))", + }, + "OM": {"code": "968", "pattern": "((2[2-6][\\d]{6}))"}, + "PA": { + "code": "507", + "pattern": "(((1(0[\\d])|(1[479])|(2[37])|(3[0137])|(4[17])|(5[05])|(6[58])|(7[0167])|(8[258])|(9[139]))|(2([0235-79][\\d])|(1[0-7])|(4[013-9])|(8[026-9]))|(3([089][\\d])|(1[014-7])|(2[0-5])|(33)|(4[0-79])|(55)|(6[068])|(7[03-8]))|(4(00)|(3[0-579])|(4[\\d])|(7[0-57-9]))|(5([01][\\d])|(2[0-7])|([56]0)|(79))|(7(0[09])|(2[0-26-8])|(3[03])|(4[04])|(5[05-9])|(6[056])|(7[0-24-9])|(8[6-9])|(90))|(8(09)|(2[89])|(3[\\d])|(4[0-24-689])|(5[014])|(8[02]))|(9(0[5-9])|(1[0135-8])|(2[036-9])|(3[35-79])|(40)|(5[0457-9])|(6[05-9])|(7[04-9])|(8[35-8])|(9[\\d]))[\\d]{4}))", + }, + "PE": { + "code": "51", + "pattern": "((((4[34])|(5[14])[0-8][\\d])|(7(173)|(3[0-8][\\d]))|(8(10[05689])|(6(0[06-9])|(1[6-9])|(29))|(7(0[569])|([56]0)))[\\d]{4})|((1[0-8])|(4[12])|(5[236])|(6[1-7])|(7[246])|(8[2-4])[\\d]{6}))", + }, + "PF": {"code": "689", "pattern": "((4(0[4-689])|(9[4-68])[\\d]{5}))"}, + "PG": { + "code": "675", + "pattern": "(((64[1-9])|(7730)|(85[02-46-9])[\\d]{4})|((3[0-2])|(4[257])|(5[34])|(77[0-24])|(9[78])[\\d]{5}))", + }, + "PH": { + "code": "63", + "pattern": "((((2[3-8])|(3[2-68])|(4[2-9])|(5[2-6])|(6[2-58])|(7[24578])[\\d]{3})|(88(22[\\d][\\d])|(42))[\\d]{4})|(2[\\d]{5}([\\d]{2})?)|(8[2-8][\\d]{7}))", + }, + "PK": { + "code": "92", + "pattern": "((((21)|(42)[2-9])|(58[126])[\\d]{7})|((2[25])|(4[0146-9])|(5[1-35-7])|(6[1-8])|(7[14])|(8[16])|(91)[2-9][\\d]{6:7})|((2(3[2358])|(4[2-4])|(9[2-8]))|(45[3479])|(54[2-467])|(60[468])|(72[236])|(8(2[2-689])|(3[23578])|(4[3478])|(5[2356]))|(9(2[2-8])|(3[27-9])|(4[2-6])|(6[3569])|(9[25-8]))[2-9][\\d]{5:6}))", + }, + "PL": { + "code": "48", + "pattern": "(((1[2-8])|(2[2-69])|(3[2-4])|(4[1-468])|(5[24-689])|(6[1-3578])|(7[14-7])|(8[1-79])|(9[145])([02-9][\\d]{6})|(1([0-8][\\d]{5})|(9[\\d]{3}([\\d]{2})?))))", + }, + "PM": {"code": "508", "pattern": "(((4[1-3])|(50)[\\d]{4}))"}, + "PR": {"code": "1", "pattern": "(((787)|(939)[2-9][\\d]{6}))"}, + "PS": { + "code": "970", + "pattern": "(((22[2-47-9])|(42[45])|(82[014-68])|(92[3569])[\\d]{5}))", + }, + "PT": { + "code": "351", + "pattern": "((2([12][\\d])|([35][1-689])|(4[1-59])|(6[1-35689])|(7[1-9])|(8[1-69])|(9[1256])[\\d]{6}))", + }, + "PW": { + "code": "680", + "pattern": "(((2(55)|(77))|(345)|(488)|(5(35)|(44)|(87))|(6(22)|(54)|(79))|(7(33)|(47))|(8(24)|(55)|(76))|(900)[\\d]{4}))", + }, + "PY": { + "code": "595", + "pattern": "((([26]1)|(3[289])|(4[1246-8])|(7[1-3])|(8[1-36])[\\d]{5:7})|((2(2[4-68])|([4-68][\\d])|(7[15])|(9[1-5]))|(3(18)|(3[167])|(4[2357])|(51)|([67][\\d]))|(4(3[12])|(5[13])|(9[1-47]))|(5([1-4][\\d])|(5[02-4]))|(6(3[1-3])|(44)|(7[1-8]))|(7(4[0-4])|(5[\\d])|(6[1-578])|(75)|(8[0-8]))|(858)[\\d]{5:6}))", + }, + "QA": {"code": "974", "pattern": "(((23)|(4[04])[\\d]{6}))"}, + "RE": {"code": "262", "pattern": "((26(2[\\d][\\d])|(30[01])[\\d]{4}))"}, + "RO": { + "code": "40", + "pattern": "(([23][13-6][\\d]{7})|((2(19[\\d])|([3-6][\\d]9))|(31[\\d][\\d])[\\d][\\d]))", + }, + "RS": { + "code": "381", + "pattern": "(((11[1-9][\\d])|((2[389])|(39)(0[2-9])|([2-9][\\d]))[\\d]{3:8})|((1[02-9])|(2[0-24-7])|(3[0-8])[2-9][\\d]{4:9}))", + }, + "RU": { + "code": "7", + "pattern": "(((3(0[12])|(4[1-35-79])|(5[1-3])|(65)|(8[1-58])|(9[0145]))|(4(01)|(1[1356])|(2[13467])|(7[1-5])|(8[1-7])|(9[1-689]))|(8(1[1-8])|(2[01])|(3[13-6])|(4[0-8])|(5[15])|(6[1-35-79])|(7[1-37-9]))[\\d]{7}))", + }, + "RW": {"code": "250", "pattern": "(((06)|(2[23568][\\d])[\\d]{6}))"}, + "SA": { + "code": "966", + "pattern": "((1(1[\\d])|(2[24-8])|(3[35-8])|(4[3-68])|(6[2-5])|(7[235-7])[\\d]{6}))", + }, + "SB": { + "code": "677", + "pattern": "(((1[4-79])|([23][\\d])|(4[0-2])|(5[03])|(6[0-37])[\\d]{3}))", + }, + "SC": {"code": "248", "pattern": "((4[2-46][\\d]{5}))"}, + "SD": {"code": "249", "pattern": "((1(5[\\d])|(8[35-7])[\\d]{6}))"}, + "SE": { + "code": "46", + "pattern": "(((([12][136])|(3[356])|(4[0246])|(6[03])|(8[\\d])[\\d])|(90[1-9])[\\d]{4:6})|((1(2[0-35])|(4[0-4])|(5[0-25-9])|(7[13-6])|([89][\\d]))|(2(2[0-7])|(4[0136-8])|(5[0138])|(7[018])|(8[01])|(9[0-57]))|(3(0[0-4])|(1[\\d])|(2[0-25])|(4[056])|(7[0-2])|(8[0-3])|(9[023]))|(4(1[013-8])|(3[0135])|(5[14-79])|(7[0-246-9])|(8[0156])|(9[0-689]))|(5(0[0-6])|([15][0-5])|(2[0-68])|(3[0-4])|(4[\\d])|(6[03-5])|(7[013])|(8[0-79])|(9[01]))|(6(1[1-3])|(2[0-4])|(4[02-57])|(5[0-37])|(6[0-3])|(7[0-2])|(8[0247])|(9[0-356]))|(9(1[0-68])|(2[\\d])|(3[02-5])|(4[0-3])|(5[0-4])|([68][01])|(7[0135-8]))[\\d]{5:6}))", + }, + "SG": { + "code": "65", + "pattern": "((662[0-24-9][\\d]{4})|(6([1-578][\\d])|(6[013-57-9])|(9[0-35-9])[\\d]{5}))", + }, + "SH": {"code": "290", "pattern": "((2([0-57-9][\\d])|(6[4-9])[\\d][\\d]))"}, + "SI": {"code": "386", "pattern": "((([1-357][2-8])|(4[24-8])[\\d]{6}))"}, + "SJ": {"code": "47", "pattern": "((79[\\d]{6}))"}, + "SK": { + "code": "421", + "pattern": "(((2(16)|([2-9][\\d]{3}))|((([3-5][1-8][\\d])|(819)[\\d])|(601[1-5])[\\d])[\\d]{4})|((2)|([3-5][1-8])1[67][\\d]{3})|([3-5][1-8]16[\\d][\\d]))", + }, + "SL": {"code": "232", "pattern": "((22[2-4][2-9][\\d]{4}))"}, + "SM": {"code": "378", "pattern": "((0549(8[0157-9])|(9[\\d])[\\d]{4}))"}, + "SN": { + "code": "221", + "pattern": "((3(0(1[0-2])|(80))|(282)|(3(8[1-9])|(9[3-9]))|(611)[\\d]{5}))", + }, + "SO": { + "code": "252", + "pattern": "(((1[\\d])|(2[0-79])|(3[0-46-8])|(4[0-7])|(5[57-9])[\\d]{5})|(([134][\\d])|(8[125])[\\d]{4}))", + }, + "SR": { + "code": "597", + "pattern": "(((2[1-3])|(3[0-7])|((4)|(68)[\\d])|(5[2-58])[\\d]{4}))", + }, + "SS": {"code": "211", "pattern": "((1[89][\\d]{7}))"}, + "ST": {"code": "239", "pattern": "((22[\\d]{5}))"}, + "SV": { + "code": "503", + "pattern": "((2([1-6][\\d]{3})|([79]90[034])|(890[0245])[\\d]{3}))", + }, + "SX": {"code": "1", "pattern": "((7215(4[2-8])|(8[239])|(9[056])[\\d]{4}))"}, + "SY": { + "code": "963", + "pattern": "((21[\\d]{6:7})|((1([14][\\d])|([2356]))|(2[235])|(3([13][\\d])|(4))|(4[134])|(5[1-3])[\\d]{6}))", + }, + "SZ": {"code": "268", "pattern": "(([23][2-5][\\d]{6}))"}, + "TA": {"code": "290", "pattern": "((8[\\d]{3}))"}, + "TC": {"code": "1", "pattern": "((649(266)|(712)|(9(4[\\d])|(50))[\\d]{4}))"}, + "TD": {"code": "235", "pattern": "((22([37-9]0)|(5[0-5])|(6[89])[\\d]{4}))"}, + "TG": { + "code": "228", + "pattern": "((2(2[2-7])|(3[23])|(4[45])|(55)|(6[67])|(77)[\\d]{5}))", + }, + "TH": { + "code": "66", + "pattern": "(((1[0689])|(2[\\d])|(3[2-9])|(4[2-5])|(5[2-6])|(7[3-7])[\\d]{6}))", + }, + "TJ": { + "code": "992", + "pattern": "(((3(1[3-5])|(2[245])|(3[12])|(4[24-7])|(5[25])|(72))|(4(46)|(74)|(87))[\\d]{6}))", + }, + "TK": {"code": "690", "pattern": "(((2[2-4])|([34][\\d])[\\d]{2:5}))"}, + "TL": {"code": "670", "pattern": "(((2[1-5])|(3[1-9])|(4[1-4])[\\d]{5}))"}, + "TM": { + "code": "993", + "pattern": "(((1(2[\\d])|(3[1-9]))|(2(22)|(4[0-35-8]))|(3(22)|(4[03-9]))|(4(22)|(3[128])|(4[\\d])|(6[15]))|(5(22)|(5[7-9])|(6[014-689]))[\\d]{5}))", + }, + "TN": { + "code": "216", + "pattern": "((81200[\\d]{3})|((3[0-2])|(7[\\d])[\\d]{6}))", + }, + "TO": { + "code": "676", + "pattern": "(((2[\\d])|(3[0-8])|(4[0-4])|(50)|(6[09])|(7[0-24-69])|(8[05])[\\d]{3}))", + }, + "TR": { + "code": "90", + "pattern": "(((2([13][26])|([28][2468])|([45][268])|([67][246]))|(3([13][28])|([24-6][2468])|([78][02468])|(92))|(4([16][246])|([23578][2468])|(4[26]))[\\d]{7}))", + }, + "TT": { + "code": "1", + "pattern": "((868(2(0[13])|(1[89])|([23][\\d])|(4[0-2]))|(6(0[7-9])|(1[02-8])|(2[1-9])|([3-69][\\d])|(7[0-79]))|(82[124])[\\d]{4}))", + }, + "TV": {"code": "688", "pattern": "((2[02-9][\\d]{3}))"}, + "TW": { + "code": "886", + "pattern": "(((2[2-8][\\d])|(370)|(55[01])|(7[1-9])[\\d]{6})|(4((0(0[1-9])|([2-48][\\d]))|(1[023][\\d])[\\d]{4:5})|(([239][\\d][\\d])|(4(0[56])|(12)|(49))[\\d]{5}))|(6([01][\\d]{7})|(4(0[56])|(12)|(24)|(4[09])[\\d]{4:5}))|(8((2(3[\\d])|(4[0-269])|([578]0)|(66))|(36[24-9])|(90[\\d][\\d])[\\d]{4})|(4(0[56])|(12)|(24)|(4[09])[\\d]{4:5}))|((2(2(0[\\d][\\d])|(4(0[68])|([249]0)|(3[0-467])|(5[0-25-9])|(6[0235689])))|((3([09][\\d])|(1[0-4]))|((4[\\d])|(5[0-49])|(6[0-29])|(7[0-5])[\\d])[\\d]))|(((3[2-9])|(5[2-8])|(6[0-35-79])|(8[7-9])[\\d][\\d])|(4(2([089][\\d])|(7[1-9]))|((3[0-4])|([78][\\d])|(9[01])[\\d]))[\\d])[\\d]{3}))", + }, + "TZ": {"code": "255", "pattern": "((2[2-8][\\d]{7}))"}, + "UA": { + "code": "380", + "pattern": "(((3[1-8])|(4[13-8])|(5[1-7])|(6[12459])[\\d]{7}))", + }, + "UG": { + "code": "256", + "pattern": "((20(((24)|(81)0)|(30[67])[\\d])|(6(00[0-2])|(30[0-4]))[\\d]{3})|((20([0147][\\d])|(2[5-9])|(32)|(5[0-4])|(6[15-9]))|([34][\\d]{3})[\\d]{5}))", + }, + "US": { + "code": "1", + "pattern": "(((2(0[1-35-9])|(1[02-9])|(2[03-589])|(3[149])|(4[08])|(5[1-46])|(6[0279])|(7[0269])|(8[13]))|(3(0[1-57-9])|(1[02-9])|(2[0135])|(3[0-24679])|(4[167])|(5[12])|(6[014])|(8[056]))|(4(0[124-9])|(1[02-579])|(2[3-5])|(3[0245])|(4[0235])|(58)|(6[39])|(7[0589])|(8[04]))|(5(0[1-57-9])|(1[0235-8])|(20)|(3[0149])|(4[01])|(5[19])|(6[1-47])|(7[013-5])|(8[056]))|(6(0[1-35-9])|(1[024-9])|(2[03689])|([34][016])|(5[0179])|(6[0-279])|(78)|(8[0-29]))|(7(0[1-46-8])|(1[2-9])|(2[04-7])|(3[1247])|(4[037])|(5[47])|(6[02359])|(7[02-59])|(8[156]))|(8(0[1-68])|(1[02-8])|(2[08])|(3[0-28])|(4[3578])|(5[046-9])|(6[02-5])|(7[028]))|(9(0[1346-9])|(1[02-9])|(2[0589])|(3[0146-8])|(4[0179])|(5[12469])|(7[0-389])|(8[04-69]))[2-9][\\d]{6}))", + }, + "UY": {"code": "598", "pattern": "(((2[\\d])|(4[2-7])[\\d]{6}))"}, + "UZ": { + "code": "998", + "pattern": "(((6(1(22)|(3[124])|(4[1-4])|(5[1-3578])|(64))|(2(22)|(3[0-57-9])|(41))|(5(22)|(3[3-7])|(5[024-8]))|(6[\\d][\\d])|(7([23][\\d])|(7[69]))|(9(22)|(4[1-8])|(6[135])))|(7(0(5[4-9])|(6[0146])|(7[124-6])|(9[135-8]))|((1[12])|(8[\\d])[\\d])|(2(22)|(3[13-57-9])|(4[1-3579])|(5[14]))|(3(2[\\d])|(3[1578])|(4[1-35-7])|(5[1-57])|(61))|(4(2[\\d])|(3[1-579])|(7[1-79]))|(5(22)|(5[1-9])|(6[1457]))|(6(22)|(3[12457])|(4[13-8]))|(9(22)|(5[1-9])))[\\d]{5}))", + }, + "VA": {"code": "39", "pattern": "((06698[\\d]{1:6}))"}, + "VC": { + "code": "1", + "pattern": "((784(266)|(3(6[6-9])|(7[\\d])|(8[0-6]))|(4(38)|(5[0-36-8])|(8[0-8]))|(5(55)|(7[0-2])|(93))|(638)|(784)[\\d]{4}))", + }, + "VE": { + "code": "58", + "pattern": "(((2(12)|(3[457-9])|([467][\\d])|([58][1-9])|(9[1-6]))|([4-6]00)[\\d]{7}))", + }, + "VG": { + "code": "1", + "pattern": "((284496[0-5][\\d]{3})|(284(229)|(4(22)|(9[45]))|(774)|(8(52)|(6[459]))[\\d]{4}))", + }, + "VI": { + "code": "1", + "pattern": "((340(2(0[12])|(2[06-8])|(4[49])|(77))|(3(32)|(44))|(4(2[23])|(44)|(7[34])|(89))|(5(1[34])|(55))|(6(2[56])|(4[23])|(77)|(9[023]))|(7(1[2-57-9])|(2[57])|(7[\\d]))|(884)|(998)[\\d]{4}))", + }, + "VN": { + "code": "84", + "pattern": "((2(0[3-9])|(1[0-689])|(2[0-25-9])|(3[2-9])|(4[2-8])|(5[124-9])|(6[0-39])|(7[0-7])|(8[2-79])|(9[0-4679])[\\d]{7}))", + }, + "VU": { + "code": "678", + "pattern": "(((38[0-8])|(48[4-9])[\\d][\\d])|((2[02-9])|(3[4-7])|(88)[\\d]{3}))", + }, + "WF": {"code": "681", "pattern": "(((50)|(68)|(72)[\\d]{4}))"}, + "WS": {"code": "685", "pattern": "((6[1-9][\\d]{3})|(([2-5])|(60)[\\d]{4}))"}, + "XK": { + "code": "383", + "pattern": "(((2[89])|(39)0[\\d]{6})|([23][89][\\d]{6}))", + }, + "YE": { + "code": "967", + "pattern": "((78[0-7][\\d]{4})|(17[\\d]{6})|(([12][2-68])|(3[2358])|(4[2-58])|(5[2-6])|(6[3-58])|(7[24-6])[\\d]{5}))", + }, + "YT": { + "code": "262", + "pattern": "((269(0[67])|(5[0-2])|(6[\\d])|([78]0)[\\d]{4}))", + }, + "ZA": { + "code": "27", + "pattern": "(((2(0330)|(4302))|(52087)0[\\d]{3})|((1[0-8])|(2[1-378])|(3[1-69])|(4[\\d])|(5[1346-8])[\\d]{7}))", + }, + "ZM": {"code": "260", "pattern": "((21[1-8][\\d]{6}))"}, + "ZW": { + "code": "263", + "pattern": "(((1((3[\\d])|(9)[\\d])|([4-8]))|(2(((0(2[014])|(5))|((2[0157])|(31)|(84)|(9)[\\d][\\d])|([56]([14][\\d][\\d])|(20))|(7([089])|(2[03])|([35][\\d][\\d]))[\\d])|(4(2[\\d][\\d])|(8))[\\d])|(1(2)|([39][\\d]{4})))|(3((123)|((29[\\d])|(92)[\\d])[\\d][\\d])|(7([19])|([56][\\d])))|(5(0)|(1[2-478])|(26)|([37]2)|(4(2[\\d]{3})|(83))|(5(25[\\d][\\d])|([78]))|([689][\\d]))|(6(([16-8]21)|(28)|(52[013])[\\d][\\d])|([39]))|(8([1349]28)|(523)[\\d][\\d])[\\d]{3})|((4[\\d][\\d])|(9[2-9])[\\d]{4:5})|(((2(((0)|(8[146])[\\d])|(7[1-7])[\\d])|(2([278][\\d])|(92))|(58(2[\\d])|(3)))|(3([26])|(9[\\d]{3}))|(5(4[\\d])|(5)[\\d][\\d])[\\d])|(6((([0-246])|([78][\\d])[\\d])|(37)[\\d])|(5[2-8]))[\\d][\\d])|((2([569][\\d])|(8[2-57-9]))|(3([013-59][\\d])|(8[37]))|(6[89]8)[\\d]{3}))", + }, + }, +} diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..a66c14a --- /dev/null +++ b/setup.cfg @@ -0,0 +1,9 @@ +[mypy] +python_version = 3.5 +ignore_missing_imports = True + +[flake8] +max-line-length = 88 +count = True +extend-ignore = E203 +exclude = patterns.py \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..608756b --- /dev/null +++ b/setup.py @@ -0,0 +1,39 @@ +from pathlib import Path + +from setuptools import find_packages, setup + +readme = Path('.', 'README.md').absolute() +with readme.open('r', encoding='utf-8') as file: + long_description = file.read() + +setup( + name='phone_gen', + packages=find_packages(exclude=('tests', 'dev_tools')), + url='https://github.com/tolstislon/phone-gen', + license='MIT License', + author='tolstislon', + author_email='tolstislon@gmail.com', + description='Phone number generator', + long_description=long_description, + long_description_content_type='text/markdown', + use_scm_version={"write_to": "phone_gen/__version__.py"}, + setup_requires=['setuptools_scm'], + python_requires='>=3.5', + include_package_data=True, + keywords=[], + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Natural Language :: English', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: Implementation :: CPython', + 'Programming Language :: Python :: Implementation :: PyPy', + 'Topic :: Software Development :: Libraries :: Python Modules' + ] +) diff --git a/tests/pytest.ini b/tests/pytest.ini new file mode 100644 index 0000000..8963b15 --- /dev/null +++ b/tests/pytest.ini @@ -0,0 +1,5 @@ +[pytest] +addopts = + --cov-report html + --cov=phone_gen tests/ + -l \ No newline at end of file diff --git a/tests/test_generator.py b/tests/test_generator.py new file mode 100644 index 0000000..2929df5 --- /dev/null +++ b/tests/test_generator.py @@ -0,0 +1,40 @@ +import re + +import pytest + +from phone_gen.generator import NumberGenerator, NumberGeneratorException, NumberGeneratorSyntaxException + + +def test_one(): + data = NumberGenerator(r'[9-0][\d]{4}').render() + assert re.match(r'\d{5}', data) + + +def test_two(): + NumberGenerator(r'[0-9][\d\{]').render() + + +SYNTAX_ERROR_PATTERN = ( + r'[136-9]\d{7}', + r'[136-9][\d{7}', + r'[136-9]\d]{7}', + r'[136-9][\d]{7,8}', + r'[136-9][\d]{7:}', + r'(4[\d]{8})|([1-9][\d]{7}', + r'(4[\d]{8})|[1-9][\d]{7})', + r'(4[\d]{8})|', + r'|([1-9][\d]{7})', + r'(4[\d]{8})|([1-][\d]{7})' +) + + +@pytest.mark.parametrize('pattern', SYNTAX_ERROR_PATTERN) +def test_syntax_error(pattern): + with pytest.raises(NumberGeneratorSyntaxException): + NumberGenerator(pattern).render() + + +@pytest.mark.parametrize('pattern', (r'[0-9][\d]{',)) +def test_base_error(pattern): + with pytest.raises(NumberGeneratorException): + NumberGenerator(pattern).render() diff --git a/tests/test_phone.py b/tests/test_phone.py new file mode 100644 index 0000000..aebdb7c --- /dev/null +++ b/tests/test_phone.py @@ -0,0 +1,30 @@ +import phonenumbers +import pytest +import random +from phone_gen import PhoneNumber +from phone_gen.patterns import PATTERNS +from phone_gen.generator import NumberGeneratorException + + +@pytest.mark.parametrize('count', range(10)) +@pytest.mark.parametrize('country', PATTERNS['data'].keys()) +def test_patterns(country, count): + number = PhoneNumber(country).get_number() + num_obj = phonenumbers.parse(number, country) + assert phonenumbers.is_valid_number_for_region(num_obj, country) + + +def test_info(): + phone_number = PhoneNumber('gb') + assert phone_number.info.startswith('libphonenumber') + + +def test_get_code(): + country = random.choice(tuple(PATTERNS['data'].keys())) + phone_number = PhoneNumber(country) + assert phone_number.get_code() == PATTERNS['data'][country]['code'] + + +def test_invalid_country(): + with pytest.raises(NumberGeneratorException): + PhoneNumber('qwe')