aboutsummaryrefslogtreecommitdiffstats
path: root/datamaps/api/api.py
diff options
context:
space:
mode:
authorMatthew Lemon <matt@matthewlemon.com>2021-05-16 16:53:13 +0100
committerMatthew Lemon <matt@matthewlemon.com>2021-05-16 16:53:13 +0100
commit4dff45ad4f5459e62fde51071bb03b7fbde12954 (patch)
tree3411e22c6d4714e4d373b3c4bf144ad5d32e736a /datamaps/api/api.py
parent4364d434b7f494a42937f4303020f86d8ca2821a (diff)
working on Month class
Diffstat (limited to 'datamaps/api/api.py')
-rw-r--r--datamaps/api/api.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/datamaps/api/api.py b/datamaps/api/api.py
index 6cc6f4e..c9f9a64 100644
--- a/datamaps/api/api.py
+++ b/datamaps/api/api.py
@@ -13,3 +13,27 @@ def project_data_from_master_api(master_file: str, quarter: int, year: int):
"""
m = Master(Quarter(quarter, year), master_file)
return m
+
+def project_data_from_master_month_api(master_file: str, month: int, year: int):
+ """Create a Master object directly without the need to explicitly pass
+ a Month object.
+
+ Args:
+ master_file (str): the path to a master file
+ month (int): an integer representing the month
+ year (int): an integer representing the year
+ """
+ # we need to work out what Quarter we are dealing with from the month
+ if month in [1, 2, 3]:
+ quarter = 4
+ elif month in [4, 5, 6]:
+ quarter = 1
+ elif month in [7, 8, 9]:
+ quarter = 2
+ elif month in [10, 11, 12]:
+ quarter = 3
+ else:
+ pass
+ # TODO: raise exception here
+ m = Master(Quarter(quarter, year), master_file)
+ return m