https://github.com/abderrahmanemustapha/leblad-py
A python library providing a list of Algerian administrative areas with many useful APIs, based on leblad
https://github.com/abderrahmanemustapha/leblad-py
algeria dz provinces python
Last synced: 9 days ago
JSON representation
A python library providing a list of Algerian administrative areas with many useful APIs, based on leblad
- Host: GitHub
- URL: https://github.com/abderrahmanemustapha/leblad-py
- Owner: abderrahmaneMustapha
- License: mit
- Created: 2020-11-23T20:17:29.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-01-20T19:46:28.000Z (over 4 years ago)
- Last Synced: 2024-08-11T00:05:34.367Z (9 months ago)
- Topics: algeria, dz, provinces, python
- Language: Python
- Homepage:
- Size: 181 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Leblad py
the python version of leblad library, provide a list of Algerian administrative areas with many useful APIs
based on [dzcode-io/leblad](https://github.com/dzcode-io/leblad)# Meta
**Coverage**
[](https://codecov.io/gh/abderrahmaneMustapha/leblad-py)
## Getting started### Usage
### Installation
```
pip install leblad
```## API
### import
```python
import lebladapi = leblad.Api()
```### getWilayaList
Returns a list of algeria provinces or wilayas
#### Arguments
- return : Array of Wilaya Object attributes to keep
#### Examples
```python
allWilayasDetails = api.getWilayaList()
```### getWilayaByZipCode
Returns a wilaya that includes the given zipCode
#### Arguments
- `zip_code` number (required) A zip code
return : Array of Wilaya Object attributes to keep
**Examples**```python
wilaya = api.getWilayaByZipCode(zip_code)
```### getWilayaByCode
Returns a wilaya that includes the given wilaya code (mattricule).
#### Arguments
- `wilaya_code` number (**required**) A zip code
return : Array of Wilaya Object attributes to keep**Examples**
```python
wilaya = api.getWilayaByCode(14)
print(wilaya) # will print the wilaya object ({name: "Tiaret"...})
```### getAdjacentWilayas
Takes a wilaya code (matricule) and returns a list of adjacent wilayas codes
**Arguments**
- `wilaya_code` (**required**) the Wilaya's "matricule"
**Examples**
```python
adjacent_wilayas = api.getAdjacentWilaya(31)
print(adjacent_wilayas) # will print [46, 22, 29, 27]
```### getZipCodesForWilaya
Takes a wilaya code (matricule) and returns a list of Respective Zip-Codes for that wilaya
**Arguments**
- `wilaya_code` (**required**) the Wilaya's "matricule"
**Examples**
```python
wilayas_zipcodes = api.getZipCodesForWilaya(31)
print(wilayas_zipcodes) #returns list of zip codes for wilaya 31
```#### getWilayasByPhoneCode
Takes a phone code and returns the matching wilaya.
**Arguments**
- `phone_code` (**required**) the Wilaya's "phoneCode"
**Examples**
```python
wilaya = api.getWilayasByPhoneCode(34)
print(wilaya) # will the wilaya object ({name: "Béjaïa"...})
```### getWilayaByDairaName
Takes a daira name and returns the matching wilaya.
**Arguments**
- `dairaName: string` (**required**) the Wilaya's "dairaName"
**Examples**
```python
wilaya = api.getWilayaByDairaName("OUED RHIOU")
print(wilaya) #will print the wilaya object ({name: "Relizane"...})
```#### getBaladyiatsForDaira
Takes a daira code and returns the matching baladyiats.
**Arguments**
- `daira_code: int` (**required**) the Wilaya's "dairaName"
**Examples**
```python
baladiyats = api.getBaladyiatsForDaira(1401)
print(baladiyats) # will return baladyiats for daira of "Tiaret"
```### getDairatsForWilaya
Takes a wilaya code (matricule) ans returns list of all dairats of that wilaya.
**Arguments**
- `wilaya_code: number` (**required**) the Wilaya's "matricule"
**Examples**
```python
wilaya_dairats = api.getDairatsForWilaya(3)
print(wilaya_dairats) #returns list of dairats for wilaya 3
```#### getPhoneCodesForWilaya
Takes a wilaya code (matricule) and returns a list of phone codes for given wilaya
**Arguments**
- `wilaya_code: number` (**required**) the Wilaya's "matricule"
**Examples**
```python
phones = api.getPhoneCodesForWilaya(22)
print(phones) #returns list of phone codes for wilaya 22
```#### getFirstPhoneCodeForWilaya
Takes a wilaya code (matricule) and returns the first phone code from a list of phone codes for given wilaya
**Arguments**
- `wilayaCode: number` (**required**) the Wilaya's "matricule"
**Examples**
```python
first_phonecode = api.getFirstPhoneCodeForWilaya(16)
print(first_phonecode) #returns first phone code for wilaya 16
```### getBaladyiatsForWilaya
Takes a wilaya code (mattricule) and returns array of Baladiyates of wilaya.
**Arguments**
- `wilaya_code: number` (**required**) the Wilaya's "matricule"
**Examples**
```python
wilaya_bladiyats = api.getBaladyiatsForWilaya(31)
print(wilaya_bladiyats) # will print the baladyiats list ([{ code: 3125, name: 'AIN KERMA'..},{ code: 3105,name: 'ES SENIA',}])
```### getWilayaByBaladyiaName
Takes a Baladyia name and returns wilaya in which baladyia is located.
**Arguments**
- `baladya: number` (**required**) the Baladyia name
**Examples**
```python
wilaya = api.getWilayaByBaladyiaName('ES SENIA')
print(wilaya) # will print the wilaya object ({name: "Oran"...})
```### getDairaByBaladyiaName
Takes a Baladyia name and returns daira in which baladyia is located.
**Arguments**
- `baladyia_name: string` (**required**) the Baladyia name
**Examples**
```python
daira =api.getDairaByBaladyiaName('ES SENIA')
print(daira) #will print the daira object ({name: "ES SENIA"...})
```### getFullAdjacentWilaya
Takes a wilaya code and returns a list of adjacent wilaya objects
**Arguments**
- `wilaya_code: integer` (**required**) the wilaya code (matricule)
**Examples**
```python
adjacent_wilaya_obj =api.getFullAdjacentWilaya('14')
print(adjacent_wilaya_obj) #will print a list of objects of adjacent wilaya
```
### getAdjacentWilayaTakes a wilaya code and returns a list of adjacent wilayas
**Arguments**
- `wilaya_code: integer` (**required**) the wilaya code (matricule)
**Examples**
```python
adjacent_wilaya_obj =api.getAdjacentWilaya('14')
print(adjacent_wilaya_obj) #will print a list of objects of adjacent wilaya
```
## TestingSimply run
```python
python -m unittest tests/test_index.py
```## License
Copyright (c) 2020 Licensed under the MIT license.