Python Algerian mobile phone number package
This package provides several methods to deal with Algerian phone numbers.
The aim of this package is to create a python community in Algeria and provide all possible libraries to make python frameworks and projects such as Django or Flask adapted to Algerian market and easy to use.
Inspired by the PHP Package authored by Mohamed Cherif Bouchelaghem.
Installation
Use the package manager pip to install Python Algerian mobile phone number package.
pip install python-algerian-mobile-phone-number
Usage:
Instantiation:
Create an instance of the class AlgerianMobilePhoneNumber and pass the phone number value as an attribute
- Import
from python_algerian_mobile_phone_number import AlgerianMobilePhoneNumber
phoneNumber = AlgerianMobilePhoneNumber('0770000000')
Or:
phoneNumber = AlgerianMobilePhoneNumber('07 70 00 00 00')
Or:
phoneNumber = AlgerianMobilePhoneNumber('07-70-00-00-00')
NOTE: For now only space and hyphens "-" separated numbers are accepted.
NOTE: International phone indicative such 00213 or +213 are accepted.
API:
str
To get the string representation of the instance use the built in function __str__:
phoneNumber.__str__() #'0770000000'
equalsTo
To compare two phone numbers:
other = AlgerianMobilePhoneNumber('0770000000')
phoneNumber.equalsTo(other) #True
isMobilis, isDjezzy and isOoredoo
To check the mobile phone number provider including Mobilis, Djezzy and Ooredoo
phoneNumber = AlgerianMobilePhoneNumber('0770000000')
phoneNumber.isMobilis() #False
phoneNumber.isDjezzy() #True
phoneNumber.isOoredoo() #False
changeNumber
To change the phone number of an instance:
phoneNumber = AlgerianMobilePhoneNumber('0770000000')
phoneNumber.changeNumber('0798000000') #'0798000000'
convertToInternational
The method takes one parameter named prefix -- values only '00' and '+'
phoneNumber = AlgerianMobilePhoneNumber('0770000000')
phoneNumber.convertToInternational() #'00213770000000'
phoneNumber.convertToInternational('00') #'00213770000000'
phoneNumber.convertToInternational('+') #'+213770000000'
convertToLocal
The method convert the internaltionl number to local one. Accepts both '00213' and '+213'
phoneNumber = AlgerianMobilePhoneNumber('00213770000000')
phoneNumber.convertToLocal() #'0770000000'
NOTE: convertToInternational and convertToLocal does not change the number instance so you can assign it to a variable. If you want to change the class instance use changeNumber instead to avoid mistakes.
Contribution
Contributions are welcome to give the best of this package.
- Clone the repo:
$ git clone git@github.com:mohamine18/python_algerian_mobile_phone_number.git
- Enter the cloned repository directory.
Testing:
- Install pytest:
$ pip install pytest
- Run test.py script for unit testing:
$ pytest test.py
License
Release files for python-algerian-mobile-phone-number 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| python_algerian_mobile_phone_number-0.2.tar.gz | 3.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_algerian_mobile_phone_number-0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.5 kB
Release files / python_algerian_mobile_phone_number-0.2.tar.gz
| Download URL | python_algerian_mobile_phone_number-0.2.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f10f2161e227e9a2a264678b43e575216445fff99633c979027b05135435fcd
|
|
BLAKE2b-256 checksum How to use checksums |
9865c9eb56c1cb00ec0ab6dcccba2c1d0693f2c1a1e223515a8de2f9ef8f3479
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.0
|
Release files / python_algerian_mobile_phone_number-0.2-py3-none-any.whl
| Download URL | python_algerian_mobile_phone_number-0.2-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
deb7e0c6ba077160efc11276b5c2848503bb71a560dd0056e04ec7f11d103454
|
|
BLAKE2b-256 checksum How to use checksums |
a5bb28e38c2dee134c328619fb11243501346b25bb0581e8a298e64eab08c0eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.0
|