Logging for python files
This commit is contained in:
@ -6,6 +6,8 @@ import datetime
|
||||
|
||||
class MiIndicador:
|
||||
def __init__(self, base_url: str = None):
|
||||
print('Creating object Mindicador')
|
||||
|
||||
if base_url is None:
|
||||
base_url = 'https://mindicador.cl/api'
|
||||
self.base_url = base_url
|
||||
@ -30,10 +32,14 @@ class MiIndicador:
|
||||
return json.loads(resp.text)
|
||||
|
||||
def list(self):
|
||||
print('List possible indicators')
|
||||
|
||||
url = self.__build_url('')
|
||||
return self.__get(url)
|
||||
|
||||
def get(self, indicador: str, fecha: str = None):
|
||||
print('Getting {} in date {} from {}'.format(indicador, fecha, self.base_url))
|
||||
|
||||
url = indicador
|
||||
if fecha is not None:
|
||||
url = '/'.join([url, fecha])
|
||||
@ -45,6 +51,8 @@ class MiIndicador:
|
||||
return res
|
||||
|
||||
def historical(self, indicador: str, since: str = None):
|
||||
print('Getting historical data for {} since {} from {}'.format(indicador, since, self.base_url))
|
||||
|
||||
sub = indicador
|
||||
if since is not None:
|
||||
sub = '/'.join([sub, since])
|
||||
@ -65,6 +73,9 @@ if __name__ == '__main__':
|
||||
hparser.add_argument('-hi', '--historical', action='store_true')
|
||||
hparser.add_argument('-s', '--since')
|
||||
args = parser.parse_args()
|
||||
|
||||
print('Called with args: {}'.format(vars(args)))
|
||||
|
||||
mi = MiIndicador(args.url)
|
||||
if 'historical' in args and args.historical:
|
||||
print(mi.historical(args.indicador, args.since))
|
||||
|
Reference in New Issue
Block a user