def write_header(self, tool_definition, result_arguments): configuration_folder = tool_definition['configuration_folder'] tool_argument_names = list(tool_definition['argument_names']) # Write tool_definition template = '[tool_definition]\n%s' command_path = self.write_script(tool_definition, result_arguments) self.write(template % format_summary(OrderedDict([ ('tool_name', tool_definition['tool_name']), ('configuration_path', tool_definition['configuration_path']), ]))) print(format_summary({'command_path': command_path})) # Put target_folder at end of result_arguments target_folder = result_arguments['target_folder'] try: tool_argument_names.remove('target_folder') except ValueError: pass result_arguments = sort_dictionary( result_arguments, tool_argument_names) # Write result_arguments template = '\n[result_arguments]\n%s\n' result_arguments['target_folder'] = target_folder for k, v in result_arguments.items(): if not k.endswith('_path') or isabs(v): continue result_arguments[k] = abspath(join(configuration_folder, v)) self.write(template % format_summary(result_arguments))
def write_footer(self, result_properties): template = '[result_properties]\n%s' self.write( screen_text=template % format_summary( result_properties, censored=False), file_text=template % format_summary( result_properties, censored=True))
def run_scripts(scripts_by_name, args, target_name=None): if not target_name: target_name = args.command for script in scripts_by_name[target_name]: d = script.run(args) if not d: continue print(format_summary(d))
target_path = join(target_folder, 'selected_nyc_traffic_injury_summary_by_month.jpg') fig.savefig(target_path) return target_path if __name__ == '__main__': argument_parser = ArgumentParser() argument_parser.add_argument('--target_folder', metavar='FOLDER', type=make_folder) argument_parser.add_argument('--target_date', metavar='DATE', type=parse_date) argument_parser.add_argument('--from_date', metavar='DATE', type=parse_date) argument_parser.add_argument('--to_date', metavar='DATE', type=parse_date) argument_parser.add_argument('--search_address', metavar='ADDRESS') argument_parser.add_argument('--search_radius_in_meters', metavar='RADIUS', type=float) args = argument_parser.parse_args() d = run(args.target_folder or make_enumerated_folder_for(__file__), args.target_date, args.from_date, args.to_date, args.search_address, args.search_radius_in_meters) print(format_summary(d))
metavar='FOLDER', type=make_folder) argument_parser.add_argument( '--demographic_by_year_table_path', metavar='PATH', required=True) argument_parser.add_argument( '--demographic_by_year_table_population_column', metavar='COLUMN', required=True) argument_parser.add_argument( '--electricity_consumption_by_population_table_path', metavar='PATH', required=True) argument_parser.add_argument( '--electricity_consumption_by_population_table_population_column', metavar='COLUMN', required=True) argument_parser.add_argument( '--electricity_consumption_by_population_table_consumption_column', metavar='COLUMN', required=True) args = argument_parser.parse_args() d = run( args.target_folder or make_enumerated_folder_for(__file__), read_csv(args.demographic_by_year_table_path), args.demographic_by_year_table_population_column, read_csv(args.electricity_consumption_by_population_table_path), args.electricity_consumption_by_population_table_population_column, args.electricity_consumption_by_population_table_consumption_column) print(format_summary(d))
return get_spatialReference(proj4).ExportToProj4() if __name__ == '__main__': argument_parser = ArgumentParser() argument_parser.add_argument('--target_folder', metavar='FOLDER', type=make_folder) argument_parser.add_argument('--coordinate_table_path', metavar='PATH', required=True) argument_parser.add_argument('--coordinate_column_x', metavar='COLUMN', required=True) argument_parser.add_argument('--coordinate_column_y', metavar='COLUMN', required=True) argument_parser.add_argument('--source_proj4', metavar='PROJ4', required=True) argument_parser.add_argument('--target_proj4', metavar='PROJ4', required=True) args = argument_parser.parse_args() coordinate_table = read_csv(args.coordinate_table_path) summary = run(args.target_folder or make_enumerated_folder_for(__file__), coordinate_table, args.coordinate_column_x, args.coordinate_column_y, args.source_proj4, args.target_proj4) print(format_summary(summary))
row = list(row) old_timestamp = parse_datetime(row[timestamp_column_index]) new_timestamp = convert_timestamp(old_timestamp) csv_writer.writerow(row + [new_timestamp.strftime(target_strftime)]) return {'converted_timestamp_table_path': target_path} if __name__ == '__main__': argument_parser = ArgumentParser() argument_parser.add_argument( '--target_folder', metavar='FOLDER', type=make_folder) argument_parser.add_argument( '--timestamp_table_path', metavar='PATH', required=True) argument_parser.add_argument( '--timestamp_column', metavar='COLUMNS', required=True) argument_parser.add_argument( '--source_timezone', metavar='TIMEZONE', required=True) argument_parser.add_argument( '--target_timezone', metavar='TIMEZONE', required=True) argument_parser.add_argument( '--target_strftime', metavar='STRFTIME', default='%H:%M') args = argument_parser.parse_args() summary = run( args.target_folder or make_enumerated_folder_for(__file__), read_csv(args.timestamp_table_path), args.timestamp_column, args.source_timezone, args.target_timezone, args.target_strftime) print(format_summary(summary))