prompt.py
Interactive mode prompting for the Scribe-Data CLI to allow users to select request arguments.
- scribe_data.cli.interactive.prompt.create_word_completer(options: list[str], include_all: bool = False) WordCompleter[source]
Return a word completer object of the given options.
- Parameters:
- optionsList[str]
The options that could complete the current input.
- include_allbool
Whether ‘All’ should be an option.
- Returns:
- WordCompleter
The word completer object from which completions can be shown to the user.
- scribe_data.cli.interactive.prompt.prompt_for_languages() None[source]
Request language and data type for lexeme totals.
- Returns:
- None
Languages are added to the configuration or are asked for.
- scribe_data.cli.interactive.prompt._wiktionary_dump_search_dirs(location: Path) list[Path][source]
Build an ordered list of directories to search for Wiktionary dumps.
Each candidate directory is resolved and included only if it exists. Duplicate paths are omitted while preserving the following search order:
The provided
locationdirectory.The default export directory (
DEFAULT_WIKTIONARY_DUMP_EXPORT_DIR).The default export directory under every ancestor of the current working directory.
The current working directory itself.
Searching ancestor directories allows dumps to be found when the interactive mode is started from a nested folder (e.g.,
scribe_data_wiktionary_json_export/spanish).- Parameters:
- locationPath
User-supplied dump path or search root from
resolve_wiktionary_dump_path().
- Returns:
- list[Path]
A deduplicated list of existing directories to search.
- scribe_data.cli.interactive.prompt.resolve_wiktionary_dump_path(language: str, location: str | Path) Path | None[source]
Resolve a Wiktionary dump file for the given source language.
Locates the newest Wiktionary XML dump for the specified language. If the
locationargument points directly to a file, that file is returned. Otherwise, it searches through a prioritized list of directories for dumps matching the{iso}wiktionary*pages-articles.xml*pattern.- Parameters:
- languagestr
Source language name (e.g.
german).- locationstr or Path
Path to a specific dump file, or a base directory to begin searching from.
- Returns:
- Path or None
The path to the newest matching dump file, the explicit file if
locationis a file, orNoneif no matching dump is found.