diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4bed15b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,65 @@ +dist: bionic +language: python + +git: + depth: false + +stages: + - black + - flake8 + - test + +jobs: + include: + - stage: "black" + python: "3.6" + env: BLACK=19.10b0 + install: pip install black==$BLACK + script: black ./phone_gen --check + after_success: false + - stage: "flake8" + python: "3.6" + env: + - FLAKE8=3.8.1 + - PEP8_NAMING=0.10.0 + install: + - pip install flake8==$FLAKE8 + - pip install pep8-naming==$PEP8_NAMING + script: flake8 ./phone_gen + after_success: false + +env: + - PHONENUMBERS="-U phonenumbers" # last version + +python: + - "pypy3" + - "3.5" + - "3.6" + - "3.7" + - "3.8" +install: + - pip install $PHONENUMBERS + - pip install pytest-cov==2.8.1 + - pip install pytest==5.4.2 + - pip install -e . +script: + - pip freeze | grep phonenumbers + - pytest tests +deploy: + provider: pypi + user: $PYPI_USER + password: $PYPI_PASSWORD + skip_existing: true + distributions: bdist_wheel --universal + on: + tags: true + repo: tolstislon/phone_gen + python: "3.8" + +after_success: + - bash <(curl -s https://codecov.io/bash) + +notifications: + email: + on_success: never + on_failure: always \ No newline at end of file diff --git a/README.md b/README.md index 8efd092..d5d0919 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,40 @@ -# phone_gen -Phone number generator +# Phone Gen + +[![Build Status](https://travis-ci.com/tolstislon/phone_gen.svg?branch=master)](https://travis-ci.com/tolstislon/phone_gen) +[![codecov](https://codecov.io/gh/tolstislon/phone-gen/branch/master/graph/badge.svg)](https://codecov.io/gh/tolstislon/phone-gen) + + +Phone number generator for [Google's libphonenumber library](https://github.com/google/libphonenumber) + + +Install +---- + +```bash +pip install phone-gen +``` + +Example +---- +```python +from phone_gen import PhoneNumber + +phone_number = PhoneNumber('GB') + +# Get full phone number +number = phone_number.get_number() +print(number) # +442908124840 + +# Get country code +country_code = phone_number.get_code() +print(country_code) # 44 + +# Phone number without country code +number = phone_number.get_number(full=False) +print(number) # 183782623 +``` + + +Contributing +---- +Contributions are very welcome. \ No newline at end of file diff --git a/phone_gen/generator.py b/phone_gen/generator.py index 1c00284..a3d4def 100644 --- a/phone_gen/generator.py +++ b/phone_gen/generator.py @@ -266,7 +266,7 @@ def render(self) -> str: class PhoneNumber: def __init__(self, code: str): - self.country = PATTERNS['data'].get(code.upper(), {}) + self.country = PATTERNS["data"].get(code.upper(), {}) if not self.country: raise NumberGeneratorException("Not found country {}".format(code)) self.generator = NumberGenerator(self.country["pattern"]) diff --git a/setup.py b/setup.py index 608756b..c6fc944 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ license='MIT License', author='tolstislon', author_email='tolstislon@gmail.com', - description='Phone number generator', + description='Phone number generator for libphonenumber', long_description=long_description, long_description_content_type='text/markdown', use_scm_version={"write_to": "phone_gen/__version__.py"}, @@ -22,10 +22,9 @@ include_package_data=True, keywords=[], classifiers=[ - 'Development Status :: 5 - Production/Stable', + 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', - 'Natural Language :: English', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 3.5', @@ -34,6 +33,7 @@ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', - 'Topic :: Software Development :: Libraries :: Python Modules' + 'Topic :: Software Development :: Testing', + 'Topic :: Communications :: Telephony' ] )