diff --git a/CHANGELOG.txt b/CHANGELOG.txt new file mode 100644 index 0000000..b9aa21f --- /dev/null +++ b/CHANGELOG.txt @@ -0,0 +1,6 @@ +Change Log +========== + +0.0.1 (19/04/2020) +------------------- +- First Release diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..2b7139a --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +global-include *.txt *.py *.json \ No newline at end of file diff --git a/README.md b/README.md index 6b44e62..ed0b172 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,15 @@ Bangladesh information like District, Division, Thana, post code etc. -This package allows you to direct use those data into the python code. +This package allows you to direct use those data into the python code. -Under construction! Not ready for use yet! Currently experimenting and planning! -Developed by Zahid Hasan (c) 2021 +.. Note:: Under construction! ot ready for use yet! Currently experimenting and planning! -Examples of How To Use (Alpha Version) +Options +- get_divisions() +- get_districts() +- get_upazilas() +- get_postcodes() -from bangladesh import get_districts, get_divisions, get_postcodes, get_upazilas -print(get_districts()) -print(get_divisions()) -print(get_upazilas()) -print(get_postcodes()) +Developed by Zahid Hasan (c) 2021 (Alpha Version)(https://github.com/Druvo) + -Check out: https://github.com/Druvo/ diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..ca5aabd --- /dev/null +++ b/README.txt @@ -0,0 +1 @@ +Bangladesh information like District, Division, Thana, post code etc. This package allows you to direct use those data into the python code.Under construction! Not ready for use yet! Currently experimenting and planning! Developed by Zahid Hasan (c) 2021 (Alpha Version) diff --git a/bangladesh/__init__.py b/bangladesh/__init__.py index 36bf8dd..4c773a5 100644 --- a/bangladesh/__init__.py +++ b/bangladesh/__init__.py @@ -1 +1,4 @@ from .main import get_districts, get_divisions, get_postcodes, get_upazilas + +__version__ = '0.0.7' +__author__ = 'Zahid Hasan' diff --git a/bangladesh/json/districts.geojson b/bangladesh/data/districts.geojson similarity index 100% rename from bangladesh/json/districts.geojson rename to bangladesh/data/districts.geojson diff --git a/bangladesh/json/districts.json b/bangladesh/data/districts.json similarity index 100% rename from bangladesh/json/districts.json rename to bangladesh/data/districts.json diff --git a/bangladesh/json/divisions.json b/bangladesh/data/divisions.json similarity index 100% rename from bangladesh/json/divisions.json rename to bangladesh/data/divisions.json diff --git a/bangladesh/json/postcodes.json b/bangladesh/data/postcodes.json similarity index 100% rename from bangladesh/json/postcodes.json rename to bangladesh/data/postcodes.json diff --git a/bangladesh/json/upazila-district-division.json b/bangladesh/data/upazila-district-division.json similarity index 100% rename from bangladesh/json/upazila-district-division.json rename to bangladesh/data/upazila-district-division.json diff --git a/bangladesh/json/upazilas.json b/bangladesh/data/upazilas.json similarity index 100% rename from bangladesh/json/upazilas.json rename to bangladesh/data/upazilas.json diff --git a/bangladesh/main.py b/bangladesh/main.py index 264228d..eccfe57 100644 --- a/bangladesh/main.py +++ b/bangladesh/main.py @@ -1,30 +1,73 @@ import json +import os +from types import SimpleNamespace +from .models import DivisionList + + +script_dir = os.path.dirname(__file__) # <-- absolute dir the script is in + + +def get_absolute_path(str): + """[Get a absolute path of a file] + + Args: + str ([path]): [The file location/path] + + Returns: + [str]: [full string fromate of the a path from the os] + """ + return os.path.join(script_dir, str) + + +def get_file_data(str): + """[Get json file data] + + Args: + str ([path]): [The file location/path] + + Returns: + [dictionary]: [The data in the file] + """ + data = open(get_absolute_path(str), encoding="utf8") + respons_dict = json.load(data) + return respons_dict def get_divisions(): - # with json load (file) - info = open('./json/divisions.json', encoding="utf8") - respons = json.load(info) - return respons + """[Get divisions list] + + Returns: + [dictionary]: [divisions list] + """ + info = get_file_data(r'data\divisions.json') + return info def get_districts(): - # with json load (file) - import json - info = open('./json/districts.json', encoding="utf8") - respons = json.load(info) - return respons + """[Get districts list] + + Returns: + [dictionary]: [districts list] + """ + info = get_file_data(r'data/districts.json') + return info def get_postcodes(): - # with json load (file) - info = open('./json/postcodes.json', encoding="utf8") - respons = json.load(info) - return respons + """[Get postcodes list] + + Returns: + [dictionary]: [postcodes list] + """ + info = get_file_data(r'data/postcodes.json') + return info def get_upazilas(): - # with json load (file) - info = open('./json/upazilas.json', encoding="utf8") - respons = json.load(info) - return respons + """[Get upazilas list] + + Returns: + [dictionary]: [upazilas list] + """ + info = get_file_data(r'data/upazilas.json') + return info diff --git a/bangladesh/models/__init__.py b/bangladesh/models/__init__.py new file mode 100644 index 0000000..93368ef --- /dev/null +++ b/bangladesh/models/__init__.py @@ -0,0 +1,6 @@ +from .district import * +from .division import * +from .districts_geo import * +from .postcode import * +from .udd import * +from .upazila import * diff --git a/bangladesh/models/district.py b/bangladesh/models/district.py new file mode 100644 index 0000000..c316dde --- /dev/null +++ b/bangladesh/models/district.py @@ -0,0 +1,25 @@ +from typing import List + + +class District: + id: int + division_id: int + name: str + bn_name: str + lat: str + long: str + + def __init__(self, id: int, division_id: int, name: str, bn_name: str, lat: str, long: str) -> None: + self.id = id + self.division_id = division_id + self.name = name + self.bn_name = bn_name + self.lat = lat + self.long = long + + +class Welcome6: + districts: List[District] + + def __init__(self, districts: List[District]) -> None: + self.districts = districts diff --git a/bangladesh/models/districts_geo.py b/bangladesh/models/districts_geo.py new file mode 100644 index 0000000..9ea1aae --- /dev/null +++ b/bangladesh/models/districts_geo.py @@ -0,0 +1,50 @@ +from enum import Enum +from typing import List + + +class GeometryType(Enum): + MULTI_POLYGON = "MultiPolygon" + + +class Geometry: + type: GeometryType + coordinates: List[List[List[List[float]]]] + + def __init__(self, type: GeometryType, coordinates: List[List[List[List[float]]]]) -> None: + self.type = type + self.coordinates = coordinates + + +class Properties: + adm2_en: str + adm1_en: str + + def __init__(self, adm2_en: str, adm1_en: str) -> None: + self.adm2_en = adm2_en + self.adm1_en = adm1_en + + +class FeatureType(Enum): + FEATURE = "Feature" + + +class Feature: + type: FeatureType + properties: Properties + geometry: Geometry + + def __init__(self, type: FeatureType, properties: Properties, geometry: Geometry) -> None: + self.type = type + self.properties = properties + self.geometry = geometry + + +class Welcome3: + type: str + name: str + features: List[Feature] + + def __init__(self, type: str, name: str, features: List[Feature]) -> None: + self.type = type + self.name = name + self.features = features diff --git a/bangladesh/models/division.py b/bangladesh/models/division.py new file mode 100644 index 0000000..2b1255b --- /dev/null +++ b/bangladesh/models/division.py @@ -0,0 +1,23 @@ +from typing import List + + +class Division: + id: int + name: str + bn_name: str + lat: str + long: str + + def __init__(self, id: int, name: str, bn_name: str, lat: str, long: str) -> None: + self.id = id + self.name = name + self.bn_name = bn_name + self.lat = lat + self.long = long + + +class DivisionList: + divisions: List[Division] + + def __init__(self, divisions: List[Division]) -> None: + self.divisions = divisions diff --git a/bangladesh/models/postcode.py b/bangladesh/models/postcode.py new file mode 100644 index 0000000..c4b79bc --- /dev/null +++ b/bangladesh/models/postcode.py @@ -0,0 +1,30 @@ +from enum import Enum +from typing import Optional, List + + +class District(Enum): + CHAPINAWABGANJ = "Chapinawabganj" + + +class Postcode: + division_id: int + district_id: Optional[int] + upazila: str + post_office: str + post_code: int + district: Optional[District] + + def __init__(self, division_id: int, district_id: Optional[int], upazila: str, post_office: str, post_code: int, district: Optional[District]) -> None: + self.division_id = division_id + self.district_id = district_id + self.upazila = upazila + self.post_office = post_office + self.post_code = post_code + self.district = district + + +class Welcome8: + postcodes: List[Postcode] + + def __init__(self, postcodes: List[Postcode]) -> None: + self.postcodes = postcodes diff --git a/bangladesh/models/udd.py b/bangladesh/models/udd.py new file mode 100644 index 0000000..9a2f60d --- /dev/null +++ b/bangladesh/models/udd.py @@ -0,0 +1,22 @@ +from enum import Enum + + +class Division(Enum): + BARISAL = "Barisal" + CHITTAGONG = "Chittagong" + DHAKA = "Dhaka" + KHULNA = "Khulna" + RAJSHAHI = "Rajshahi" + RANGPUR = "Rangpur" + SYLHET = "Sylhet" + + +class Welcome1Element: + upazila: str + district: str + division: Division + + def __init__(self, upazila: str, district: str, division: Division) -> None: + self.upazila = upazila + self.district = district + self.division = division diff --git a/bangladesh/models/upazila.py b/bangladesh/models/upazila.py new file mode 100644 index 0000000..b7fc2ea --- /dev/null +++ b/bangladesh/models/upazila.py @@ -0,0 +1,21 @@ +from typing import List + + +class Upazila: + id: int + district_id: int + name: str + bn_name: str + + def __init__(self, id: int, district_id: int, name: str, bn_name: str) -> None: + self.id = id + self.district_id = district_id + self.name = name + self.bn_name = bn_name + + +class Welcome10: + upazilas: List[Upazila] + + def __init__(self, upazilas: List[Upazila]) -> None: + self.upazilas = upazilas diff --git a/setup.py b/setup.py index 8798b89..8b2354d 100644 --- a/setup.py +++ b/setup.py @@ -7,10 +7,9 @@ with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh: long_description = "\n" + fh.read() -VERSION = '0.0.5' +VERSION = '0.0.8' DESCRIPTION = 'A python package For Bangladesh information (District, Division, Thana, post code and etc)' -LONG_DESCRIPTION = 'A package that allows to build simple streams of video, audio and camera data.' - +LONG_DESCRIPTION = '' setup( name="bangladesh", @@ -22,11 +21,12 @@ long_description=long_description, packages=find_packages(), license='MIT License', + include_package_data=True, + package_data={'': ['data/*.json']}, url='https://github.com/Druvo', install_requires=[], Platform='python', - keywords=['Bangladesh', 'District', 'Division', 'Thana', - 'post code', 'Bangladesh District', 'Division District'], + keywords=['Bangladesh', 'District', 'Division', 'Thana', 'upazilas'], classifiers=[ "Development Status :: 1 - Planning", "Intended Audience :: Developers", diff --git a/test.py b/test.py new file mode 100644 index 0000000..26bb0fe --- /dev/null +++ b/test.py @@ -0,0 +1,4 @@ +from bangladesh import * + + +print(get_divisions())