def main_cli():
def _get_parser_args():<EOL><INDENT>p = argparse.ArgumentParser(description='<STR_LIT>')<EOL>p.add_argument('<STR_LIT>', '<STR_LIT>', action='<STR_LIT:store_true>', help='<STR_LIT>')<EOL>p.add_argument('<STR_LIT>', '<STR_LIT>', action='<STR_LIT:store>', nargs='<STR_LIT:*>',<EOL>help="<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL>p.add_argument('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', action='<STR_LIT:store_true>',<EOL>help="<STR_LIT>")<EOL>p.add_argument('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', action='<STR_LIT:store_true>',<EOL>help="<STR_LIT>")<EOL>p.add_argument('<STR_LIT>', '<STR_LIT>', action='<STR_LIT:store_true>', help="<STR_LIT>")<EOL>p.add_argument('<STR_LIT>', '<STR_LIT>', action='<STR_LIT:store_true>', help='<STR_LIT>')<EOL>arguments = p.parse_args()<EOL>return arguments, p<EOL><DEDENT>def _parse_date(string, columns):<EOL><INDENT>try:<EOL><INDENT>ts = pd.Timestamp(string)<EOL>print_cyan('<STR_LIT>'.format(string, ts, ts.date()))<EOL>columns.remove(string)<EOL>return ts.date().isoformat()<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>args, parser = _get_parser_args()<EOL>print_secc('<STR_LIT>')<EOL>if args.dem:<EOL><INDENT>db_web = DatosREE(update=args.update, force_update=args.forceupdate, verbose=args.verbose)<EOL><DEDENT>else:<EOL><INDENT>db_web = PVPC(update=args.update, force_update=args.forceupdate, verbose=args.verbose)<EOL><DEDENT>data = db_web.data['<STR_LIT:data>']<EOL>if args.info is not None:<EOL><INDENT>if len(args.info) > <NUM_LIT:0>:<EOL><INDENT>cols = args.info.copy()<EOL>dates = [d for d in [_parse_date(s, cols) for s in args.info] if d]<EOL>if len(dates) == <NUM_LIT:2>:<EOL><INDENT>data = data.loc[dates[<NUM_LIT:0>]:dates[<NUM_LIT:1>]]<EOL><DEDENT>elif len(dates) == <NUM_LIT:1>:<EOL><INDENT>data = data.loc[dates[<NUM_LIT:0>]]<EOL><DEDENT>if len(cols) > <NUM_LIT:0>:<EOL><INDENT>try:<EOL><INDENT>data = data[[c.upper() for c in cols]]<EOL><DEDENT>except KeyError as e:<EOL><INDENT>print_red('<STR_LIT>'<EOL>.format(e, data.columns))<EOL><DEDENT><DEDENT>print_info(data)<EOL><DEDENT>else:<EOL><INDENT>print_secc('<STR_LIT>')<EOL>print_info(data.iloc[-<NUM_LIT>:])<EOL>print_cyan(data.columns)<EOL><DEDENT><DEDENT>if args.plot:<EOL><INDENT>if args.dem:<EOL><INDENT>from esiosdata.pvpcplot import pvpcplot_tarifas_hora, pvpcplot_grid_hora<EOL>print_red('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>from esiosdata.pvpcplot import pvpcplot_tarifas_hora, pvpcplot_grid_hora<EOL>if len(data) < <NUM_LIT>:<EOL><INDENT>pvpcplot_grid_hora(data)<EOL><DEDENT>else:<EOL><INDENT>print_red('<STR_LIT>'.<EOL>format(len(data), data.index[<NUM_LIT:0>], data.index[-<NUM_LIT:1>]))<EOL>pvpcplot_grid_hora(db_web.data['<STR_LIT:data>'].iloc[-<NUM_LIT>:])<EOL>pvpcplot_tarifas_hora(db_web.data['<STR_LIT:data>'].iloc[-<NUM_LIT>:])<EOL><DEDENT><DEDENT><DEDENT>
Actualiza la base de datos de PVPC/DEMANDA almacenados como dataframe en local,
creando una nueva si no existe o hubiere algún problema. Los datos registrados se guardan en HDF5