def create_legend_files(template_path, themes_path, map_path, fonts_path, use_debug): with open(os.path.join(template_path, "SeaChart_Legend_THEME.map")) as f: template = Template(f.read()) for theme in os.listdir(themes_path): # Remove file suffix theme = os.path.splitext(theme)[0] debug_string = "" if use_debug: debug_string = str.format(debug_template, theme) d = get_dictionary(theme, map_path, fonts_path, debug_string) legend_path = dirutils.force_sub_dir(map_path, "legends") fileout = open(os.path.join( legend_path, "SeaChart_Legend_" + theme + ".map"), 'w') fileout.write(template.substitute(d))
data_path = config_relative(data_path, args) map_path = args.config['paths'].get('map') if not map_path: map_path = os.path.normpath(os.path.join(data_path, '../map')) else: map_path = config_relative(map_path, args) rule_set_path = args.config['paths'].get('ruleset') if not rule_set_path: rule_set_path = RESOURCES_PATH else: rule_set_path = config_relative(rule_set_path, args) rule_set_path = dirutils.force_sub_dir(rule_set_path, 'rules') color_tables_exist = dirutils.does_color_tables_exist(rule_set_path) if not color_tables_exist: create_color_rules(RESOURCES_PATH, os.path.join(rule_set_path, "color_tables"), None) chartsymbols = args.config['paths'].get('chartsymbols') if not chartsymbols: chartsymbols = os.path.abspath( os.path.join(RESOURCES_PATH, 'chartsymbols/chartsymbols_S57.xml')) else: chartsymbols = config_relative(chartsymbols, args) if not os.path.isfile(chartsymbols): print("chartsymbols.xml not found at: " + chartsymbols)