def main(): try: validate_args(sys.argv) except ValueError as e: print(e.args[0]) return currency, start_date, end_date = sys.argv[1:] currency = int(currency) get_rates(currency, start_date, end_date) df = pd.read_csv(generate_file_path(currency, start_date, end_date), sep=',') label = f"BYN/{currency} {start_date} - {end_date}" df.index = pd.to_datetime(df['day'].values, format="%d-%m-%Y") df = df.drop(['day'], axis=1) df_month = df.resample('M').mean() df_quarter = df.resample('Q').mean() # plotting plot_graph(df, label, 'Day') plot_graph(df_month, label, 'Month') plot_graph(df_quarter, label, 'Quarter') plot_decompose(df) plot_changes(df, label, 'Day') plot_histogram(df, 'Day', 12) plot_std(df, label, 'Day')
def test_input_parameters(self): wrong_params = ["[12, ds, 45, 59]", "movies.json"] correct_params = ["23, 36, 49", "data\movies.json"] # check with wring parameters first self.assertEqual(validate_args(wrong_params), False) # see if parameters are valid self.assertDictContainsSubset({"input_movies": (23, 36, 49)}, validate_args(correct_params))
def main(): try: src, start, end = validate_args(sys.argv[1:]) except ValueError: print( "Error: Invalid Arguments: please run this program like " + f"'python {__file__} accounts/account.csv -s 2020-08-24 -e 2020-09-01'" ) return if not src.is_file(): print(f"Error: '{src}' does not exist or is a directory.") return if src.suffix != ".csv": print("Error: Invalid Extension: Only CSV file is available.") return records = RecordList([]) with open(src, "r") as f: for line in f: records.append(Record(*line.strip().split(","))) category_total = records.category_total(start, end) c_length = max_len(category_total.keys()) e_length = max_len(category_total.values()) print(f"{'total':{c_length}s} | {category_total['total']:>{e_length}d}") for category, expense in category_total.items(): if category != "total": print(f"{category:{c_length}s} | {expense:>{e_length}d}")
def main(): try: validate_args(sys.argv) except ValueError as e: print(e.args[0]) return currency, start_date, end_date = sys.argv[1:] get_rates(currency, start_date, end_date) x, y = csv_parse(generate_file_path(currency, start_date, end_date)) label = f"BYN/{currency} {start_date} - {end_date}" plt.plot(x, y, "-", linewidth=1, label=label) plt.xticks(rotation=90) plt.xticks(shorten_dates(x)) plt.legend() plt.show()
def main(args): """Main entry point for the script.""" logging.info('Starting script'.format(args.query_word)) logging.debug('Input parameters: \'{}\', \'{}\', \'{}\''.format( args.search_type, args.query_word, args.out_dir)) if validate_args(args): api_handler = ApiHandler(args.query_word, args.search_type) tweets = api_handler.get_tweets() csv_handler = CSVFileHandler(args, tweets) csv_handler.export_csv() else: logging.info('Script stopped')
if 'pc' in loaded[ref_out_layer]: ref_pc = loaded[ref_out_layer]['pc'] performance_metrics(pc=pc, ref_pc=ref_pc) blob_counters(out_blob=out_blob, ref_out_blob=ref_out_blob) global_accuracy = update_global_accuracy_matrics(global_accuracy=global_accuracy, current_accuracy=a_m) print_all_over_the_net_metrics(global_accuracy=global_accuracy) def main(args): log.info('Inference Engine:\n API version ............ {}'.format(ie.__version__), extra={'no_lvl': True}) set_verbosity(args.verbosity) mode = find_out_cct_mode(args) if mode == 1: log.info('Cross check with one IR was enabled') one_ir_mode(args) elif mode == 2: log.info('Cross check with two IRs was enabled') two_ir_mode(args) elif mode == 3: log.info('Dump mode was enabled') dump_mode(args) elif mode == 4: log.info('Load mode was enabled') load_mode(args) log.info("Execution successful") if __name__ == '__main__': set_logger(log.DEBUG) main(validate_args(build_parser().parse_args()))
def main(): parser = argparse.ArgumentParser(description='DevNet Tool') parser.add_argument('--user', type=str, required=True, help='Username') parser.add_argument('--password', type=str, required=True, help='Password') parser.add_argument('--network', type=str, required=True, help='Management Network') parser.add_argument('--ntp-server', type=str, required=True, help='NTP server') args = parser.parse_args() validate_args(args) output_report = '' for address in get_ip_address_list(args.network): print(f'connection started to {address}') connection = make_connection(address=address, user=args.user, password=args.password) if not connection: continue print('connection success') connection.enable() device_info = parse_show_version(connection=connection) if bool(device_info) is False: print('show version parse failed, skip') continue config = make_backup(connection=connection, hostname=device_info['Hostname']) if not config: print('failed to get config, skip') continue device_cdp_info = parse_cdp_neighbor_detail( connection=connection, hostname=device_info['Hostname']) config_timezone_ntp(connection=connection, hostname=device_info['Hostname'], ntp_server=args.ntp_server, config=config) ntp_service_info = parse_ntp_status(connection=connection, hostname=device_info['Hostname']) close_connection(connection=connection) output_report += make_report(device_info=device_info, cdp_info=device_cdp_info, ntp_info=ntp_service_info) if output_report: print('----SUMMARY----\n') print(output_report)