Skip to content

Commit

Permalink
Merge pull request #11 from RHDZMOTA/DEV
Browse files Browse the repository at this point in the history
2022-09-18 RELEASE-PRD (1)
  • Loading branch information
RHDZMOTA authored Sep 19, 2022
2 parents 8c7e872 + a855eb4 commit 7249e86
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 1 deletion.
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
package_dir={
"": "src"
},
package_data={
"": [
os.path.join("iso3166", "datafiles", "*.json"),
]
},
scripts=[
"bin/rhdzmota"
],
Expand Down
2 changes: 1 addition & 1 deletion src/rhdzmota/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
2.3.0
1 change: 1 addition & 0 deletions src/rhdzmota/iso3166/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .country_codes import Country
29 changes: 29 additions & 0 deletions src/rhdzmota/iso3166/country_codes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os
import enum
import json


from rhdzmota.settings import logger_manager


logger = logger_manager.get_logger(name=__name__)


class Country(enum.Enum):
MEXICO = "MX"

@property
def subdivisions_data_filepath(self) -> str:
filename = f"{self.value}.json".lower()
filepath = os.path.join(os.path.dirname(__file__), "datafiles", filename)
if os.path.exists(filepath):
return filepath
logger.error("Missing datafile for %s", self.name)
return os.path.join(os.path.dirname(filepath), "default.json")

@property
def subdivisions(self):
data_filepath = self.subdivisions_data_filepath
with open(data_filepath, "r") as file:
payload = json.loads(file.read())
return enum.Enum(self.name, payload)
1 change: 1 addition & 0 deletions src/rhdzmota/iso3166/datafiles/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
34 changes: 34 additions & 0 deletions src/rhdzmota/iso3166/datafiles/mx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"AGU": "Aguascalientes",
"BCN": "Baja California",
"BCS": "Baja California Sur",
"CAM": "Campeche",
"CHP": "Chiapas",
"CHH": "Chihuahua",
"CMX": "Ciudad de M\u00e9xico",
"COA": "Coahuila de Zaragoza",
"COL": "Colima",
"DUR": "Durango",
"GUA": "Guanajuato",
"GRO": "Guerrero",
"HID": "Hidalgo",
"JAL": "Jalisco",
"MIC": "Michoac\u00e1n de Ocampo",
"MOR": "Morelos",
"MEX": "M\u00e9xico",
"NAY": "Nayarit",
"NLE": "Nuevo Le\u00f3n",
"OAX": "Oaxaca",
"PUE": "Puebla",
"QUE": "Quer\u00e9taro",
"ROO": "Quintana Roo",
"SLP": "San Luis Potos\u00ed",
"SIN": "Sinaloa",
"SON": "Sonora",
"TAB": "Tabasco",
"TAM": "Tamaulipas",
"TLA": "Tlaxcala",
"VER": "Veracruz de Ignacio de la Llave",
"YUC": "Yucat\u00e1n",
"ZAC": "Zacatecas"
}

0 comments on commit 7249e86

Please sign in to comment.