Skip to content

Commit

Permalink
file bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Druvo committed May 6, 2021
1 parent ab6f194 commit d5ba251
Show file tree
Hide file tree
Showing 21 changed files with 266 additions and 32 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Change Log
==========

0.0.1 (19/04/2020)
-------------------
- First Release
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global-include *.txt *.py *.json
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -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/
1 change: 1 addition & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 3 additions & 0 deletions bangladesh/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
from .main import get_districts, get_divisions, get_postcodes, get_upazilas

__version__ = '0.0.7'
__author__ = 'Zahid Hasan'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
77 changes: 60 additions & 17 deletions bangladesh/main.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions bangladesh/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .district import *
from .division import *
from .districts_geo import *
from .postcode import *
from .udd import *
from .upazila import *
25 changes: 25 additions & 0 deletions bangladesh/models/district.py
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions bangladesh/models/districts_geo.py
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions bangladesh/models/division.py
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions bangladesh/models/postcode.py
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions bangladesh/models/udd.py
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions bangladesh/models/upazila.py
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from bangladesh import *


print(get_divisions())

0 comments on commit d5ba251

Please sign in to comment.