Refactor metadata entry and settings name code a bit

This commit is contained in:
Jim Miller 2026-01-29 13:53:27 -06:00
parent 94c932cd2f
commit c1fb7f0fc5

View file

@ -139,19 +139,6 @@ def get_valid_sections():
allowedsections.append('%s:%s'%(section,f))
return allowedsections
def get_valid_list_entries():
return list(['category',
'genre',
'characters',
'ships',
'warnings',
'extratags',
'author',
'authorId',
'authorUrl',
'lastupdate',
])
boollist=['true','false']
base_xenforo2_list=['base_xenforo2forum',
'forums.sufficientvelocity.com',
@ -188,7 +175,7 @@ def get_valid_set_options():
This is to further restrict keywords to certain sections and/or
values. get_valid_keywords() below is the list of allowed
keywords. Any keyword listed here must also be listed there.
keywords. Any keyword not listed here must be listed there.
This is what's used by the code when you save personal.ini in
plugin that stops and points out possible errors in keyword
@ -343,6 +330,158 @@ def get_valid_set_options():
return dict(valdict)
# *known* keywords -- or rather regexps for them.
def get_valid_keywords():
'''
Among other things, this list is used by the color highlighting in
personal.ini editing in plugin. Note that entries in
get_valid_set_options() do not need to be duplicated here anymore.
'''
return list(get_valid_set_options().keys())+\
['(in|ex)clude_metadata_(pre|post)',
'add_category_when_multi_category',
'add_genre_when_multi_category',
'adult_ratings',
'allow_unsafe_filename',
'always_overwrite',
'anthology_merge_keepsingletocs',
'anthology_tags',
'anthology_title_pattern',
'background_color',
'browser_cache_age_limit',
'chapter_end',
'chapter_start',
'chapter_title_add_pattern',
'chapter_title_addnew_pattern',
'chapter_title_def_pattern',
'chapter_title_error_mark',
'chapter_title_new_pattern',
'chapter_title_strip_pattern',
'chardet_confidence_limit',
'comma_entries',
'connect_timeout',
'continue_on_chapter_error_try_limit',
'convert_images_to',
'cover_content',
'cover_exclusion_regexp',
'cover_min_size',
'custom_columns_settings',
'dateCreated_format',
'datePublished_format',
'dateUpdated_format',
'datethreadmark_format',
'default_cover_image',
'description_limit',
'epub_version',
'exclude_editor_signature',
'exclude_notes',
'extra_logpage_entries',
'extra_subject_tags',
'extra_titlepage_entries',
'extra_valid_entries',
'extracategories',
'extracharacters',
'extragenres',
'extraships',
'extratags',
'extrawarnings',
'fail_on_password',
'file_end',
'file_start',
'fileformat',
'find_chapters',
'fix_pseudo_html',
'flaresolverr_proxy_address',
'flaresolverr_proxy_port',
'flaresolverr_proxy_protocol',
'flaresolverr_proxy_timeout',
'flaresolverr_session',
'force_cover_image',
'force_img_self_referer_regexp',
'force_login',
'generate_cover_settings',
'http_proxy',
'https_proxy',
'ignore_chapter_url_list',
'image_max_size',
'include_subject_tags',
'join_string_authorHTML',
'keep_empty_tags',
'keep_html_attrs',
'keep_summary_html',
'logpage_end',
'logpage_entries',
'logpage_entry',
'logpage_start',
'logpage_update_end',
'logpage_update_start',
'make_directories',
'make_linkhtml_entries',
'max_fg_sleep',
'max_fg_sleep_at_downloads',
'max_zalgo',
'min_fg_sleep',
'no_image_processing_regexp',
'nsapa_proxy_address',
'nsapa_proxy_port',
'order_threadmarks_by_date_categories',
'output_css',
'output_filename',
'output_filename_safepattern',
'password',
'post_process_cmd',
'rating_titles',
'reader_posts_per_page',
'remove_tags',
'remove_transparency',
'replace_chapter_text',
'replace_metadata',
'replace_tags_with_spans',
'replace_xbr_with_hr',
'show_spoiler_tags',
'skip_threadmarks_categories',
'slow_down_sleep_time',
'sort_ships_splits',
'strip_chapter_numeral',
'threadmark_category_order',
'threadmarks_per_page',
'title_chapter_range_pattern',
'titlepage_end',
'titlepage_entries',
'titlepage_entry',
'titlepage_no_title_entry',
'titlepage_start',
'titlepage_wide_entry',
'tocpage_end',
'tocpage_entry',
'tocpage_start',
'user_agent',
'username',
'website_encodings',
'wide_titlepage_entries',
'wrap_width',
'zip_filename',
'zip_output'
]
# *known* entry keywords -- or rather regexps for them.
def get_valid_entry_keywords():
return list(['%s_(label|format)',
'(default_value|include_in|join_string|keep_in_order)_%s',])
def get_valid_list_entries():
return list(['category',
'genre',
'characters',
'ships',
'warnings',
'extratags',
'author',
'authorId',
'authorUrl',
'lastupdate',
])
def get_valid_scalar_entries():
return list(['series',
'seriesUrl',
@ -382,264 +521,6 @@ def get_valid_scalar_entries():
def get_valid_entries():
return get_valid_list_entries() + get_valid_scalar_entries()
# *known* keywords -- or rather regexps for them.
def get_valid_keywords():
'''
Among other things, this list is used by the color highlighting in
personal.ini editing in plugin. Note that it's separate from
value checking and most keywords need to be added to both.
'''
return list(['(in|ex)clude_metadata_(pre|post)',
'add_chapter_numbers',
'add_genre_when_multi_category',
'add_category_when_multi_category',
'adult_ratings',
'allow_unsafe_filename',
'always_overwrite',
'anthology_tags',
'anthology_title_pattern',
'anthology_merge_keepsingletocs',
'background_color',
'bulk_load',
'chapter_end',
'chapter_start',
'chapter_title_strip_pattern',
'chapter_title_def_pattern',
'chapter_title_add_pattern',
'chapter_title_new_pattern',
'chapter_title_addnew_pattern',
'title_chapter_range_pattern',
'mark_new_chapters',
'check_next_chapter',
'meta_from_last_chapter',
'skip_author_cover',
'try_shortened_title_urls',
'collect_series',
'comma_entries',
'connect_timeout',
'convert_images_to',
'cover_content',
'cover_exclusion_regexp',
'custom_columns_settings',
'dateCreated_format',
'datePublished_format',
'dateUpdated_format',
'default_cover_image',
'force_cover_image',
'force_img_self_referer_regexp',
'description_limit',
'do_update_hook',
'use_archived_author',
'use_view_full_work',
'use_workskin',
'always_login',
'exclude_notes',
'remove_authorfootnotes_on_update',
'use_archive_transformativeworks_org',
'use_archiveofourown_gay',
'exclude_editor_signature',
'extra_logpage_entries',
'extra_subject_tags',
'extra_titlepage_entries',
'extra_valid_entries',
'extratags',
'extracategories',
'extragenres',
'extracharacters',
'extraships',
'extrawarnings',
'fail_on_password',
'file_end',
'file_start',
'fileformat',
'find_chapters',
'fix_fimf_blockquotes',
'keep_prequel_in_description',
'scrape_bookshelf',
'include_author_notes',
'force_login',
'generate_cover_settings',
'grayscale_images',
'image_max_size',
'include_images',
'jpg_quality',
'additional_images',
'include_logpage',
'logpage_at_end',
'calibre_series_meta',
'force_update_epub_always',
'page_progression_direction_rtl',
'include_subject_tags',
'include_titlepage',
'include_tocpage',
'chardet_confidence_limit',
'is_adult',
'join_string_authorHTML',
'keep_style_attr',
'keep_title_attr',
'keep_html_attrs',
'remove_class_chapter',
'replace_tags_with_spans',
'keep_empty_tags',
'remove_tags',
'keep_summary_html',
'logpage_end',
'logpage_entries',
'logpage_entry',
'logpage_start',
'logpage_update_end',
'logpage_update_start',
'make_directories',
'make_firstimage_cover',
'use_old_cover',
'make_linkhtml_entries',
'max_fg_sleep',
'max_fg_sleep_at_downloads',
'min_fg_sleep',
'never_make_cover',
'cover_min_size',
'no_image_processing',
'no_image_processing_regexp',
'dedup_img_files',
'convert_inline_images',
'non_breaking_spaces',
'download_text_version',
'nook_img_fix',
'output_css',
'output_filename',
'output_filename_safepattern',
'password',
'post_process_cmd',
'rating_titles',
'remove_transparency',
'replace_br_with_p',
'replace_chapter_text',
'replace_hr',
'remove_empty_p',
'replace_xbr_with_hr',
'replace_metadata',
'slow_down_sleep_time',
'sort_ships',
'sort_ships_splits',
'strip_chapter_numbers',
'strip_chapter_numeral',
'strip_text_links',
'centeredcat_to_characters',
'pairingcat_to_characters_ships',
'romancecat_to_characters_ships',
'use_meta_keywords',
'clean_chapter_titles',
'conditionals_use_lists',
'description_in_chapter',
'order_chapters_by_date',
'fetch_stories_from_api',
'tags_from_chapters',
'dates_from_chapters',
'include_chapter_descriptions_in_summary',
'inject_chapter_title',
'inject_chapter_image',
'append_datepublished_to_storyurl',
'auto_sub',
'titlepage_end',
'titlepage_entries',
'titlepage_entry',
'titlepage_no_title_entry',
'titlepage_start',
'titlepage_use_table',
'titlepage_wide_entry',
'tocpage_end',
'tocpage_entry',
'tocpage_start',
'tweak_fg_sleep',
'universe_as_series',
'use_ssl_unverified_context',
'use_ssl_default_seclevelone',
'http_proxy',
'https_proxy',
'use_cloudscraper',
'use_basic_cache',
'use_browser_cache',
'use_browser_cache_only',
'open_pages_in_browser',
'use_nsapa_proxy',
'nsapa_proxy_address',
'nsapa_proxy_port',
'use_flaresolverr_proxy',
'flaresolverr_proxy_address',
'flaresolverr_proxy_port',
'flaresolverr_proxy_protocol',
'flaresolverr_proxy_timeout',
'use_flaresolverr_session',
'flaresolverr_session',
'browser_cache_path',
'browser_cache_age_limit',
'user_agent',
'username',
'website_encodings',
'wide_titlepage_entries',
'windows_eol',
'wrap_width',
'zip_filename',
'zip_output',
'capitalize_forumtags',
'continue_on_chapter_error',
'chapter_title_error_mark',
'continue_on_chapter_error_try_limit',
'minimum_threadmarks',
'first_post_title',
'always_include_first_post',
'always_reload_first_chapter',
'always_use_forumtags',
'use_reader_mode',
'author_avatar_cover',
'reader_posts_per_page',
'threadmarks_per_page',
'remove_spoilers',
'legend_spoilers',
'details_spoilers',
'apocrypha_to_omake',
'skip_threadmarks_categories',
'fix_relative_text_links',
'normalize_text_links',
'internalize_text_links',
'replace_failed_smilies_with_alt_text',
'use_threadmark_wordcounts',
'always_include_first_post_chapters',
'threadmark_category_order',
'order_threadmarks_by_date',
'order_threadmarks_by_date_categories',
'reveal_invisible_text',
'use_threadmarks_description',
'use_threadmarks_status',
'use_threadmarks_cover',
'skip_sticky_first_posts',
'include_dice_rolls',
'include_nonauthor_poster',
'link_embedded_media',
'include_chapter_banner_images',
'dateUpdated_method',
'datethreadmark_format',
'fix_pseudo_html',
'fix_excess_space',
'dedup_order_chapter_list',
'ignore_chapter_url_list',
'include_appendices',
'dedup_chapter_list',
'show_timestamps',
'show_nsfw_cover_images',
'show_spoiler_tags',
'max_zalgo',
'decode_emails',
'epub_version',
'prepend_section_titles',
'replace_text_formatting',
])
# *known* entry keywords -- or rather regexps for them.
def get_valid_entry_keywords():
return list(['%s_(label|format)',
'(default_value|include_in|join_string|keep_in_order)_%s',])
# Moved here for test_config.
def make_generate_cover_settings(param):
vlist = []