def setup_instance(req): go_nord = GoNord() hex_colors = [] if req.form.get('colors'): hex_colors = req.form.get('colors').split(',') if len(hex_colors) > 0: go_nord.reset_palette() for hex_color in hex_colors: go_nord.add_color_to_palette(hex_color) if req.form.get('is_avg'): go_nord.enable_avg_algorithm() if req.form.get('avg_box_width') and req.form.get('avg_box_height'): go_nord.set_avg_box_data(int(req.form.get('avg_box_width')), int(req.form.get('avg_box_height'))) if req.form.get('blur'): go_nord.enable_gaussian_blur() return go_nord
go_nord.set_avg_box_data(w=area_value[0], h=area_value[0]) to_console(confarg.logs["pxls"][0].format(area_value[0]), confarg.logs["pxls"][1].format(area_value[0])) except IndexError: to_console(confarg.logs["pxls"][-2].format(arg), confarg.logs["pxls"][-1], confarg.logs["err"][0]) sys.exit(1) condition_argument = key in ["--blur", "-b"] if condition_argument: if len(key_value) > 1: to_console(confarg.logs["blur"][-2].format(arg), confarg.logs["blur"][-1], confarg.logs["err"][0]) sys.exit(1) else: go_nord.enable_gaussian_blur() to_console(confarg.logs["blur"][0]) continue del condition_argument for palette in palettes: if "--{}".format(palette) in key: palette_path = src_path + "/palettes/" + palette.capitalize( ) + "/" go_nord.set_palette_lookup_path(palette_path) if len(key_value) > 1: go_nord.reset_palette() palette_set = [ palette_file.replace(".txt", '') for palette_file in listdir(palette_path) ]