euporie.core.config
Define a configuration class for euporie.core.
Functions
|
Add a command to the centralized command system. |
|
Register a new config item. |
|
Cast a value to a type. |
|
Get a command from the centralized command system by name. |
|
Evaluate an expression node or a string containing only a Python expression. |
|
Accept both booleans and Filters as input and turn it into a Filter. |
|
|
Classes
|
An argument parser which lexes and formats the help message before printing it. |
|
Action for boolean flags. |
|
A ChainMap groups multiple dicts (or other mappings) together to create a single, updateable view. |
|
Turn any callable into a Filter. |
|
A configuration store. |
|
Simple event to which event handlers can be attached. For instance::. |
|
JSON encode class which encodes paths as strings. |
|
PurePath subclass that can make system calls. |
|
Base class for protocol classes. |
|
A single configuration item. |
|
Typed version of the return of open() in text mode. |
|
|
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords. |
- class euporie.core.config.ArgumentParser(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True, exit_on_error=True)
Bases:
argparse.ArgumentParser
An argument parser which lexes and formats the help message before printing it.
- add_argument(dest, ..., name=value, ...)
- add_argument(option_string, option_string, ..., name=value, ...) None
- add_argument_group(*args, **kwargs)
- add_mutually_exclusive_group(**kwargs)
- add_subparsers(**kwargs)
- convert_arg_line_to_args(arg_line)
- error(message: string)
Prints a usage message incorporating the message to stderr and exits.
If you override this in a subclass, it should not return – it should either exit or raise an exception.
- exit(status=0, message=None)
- format_help()
- format_usage()
- get_default(dest)
- parse_args(args=None, namespace=None)
- parse_intermixed_args(args=None, namespace=None)
- parse_known_args(args=None, namespace=None)
- parse_known_intermixed_args(args=None, namespace=None)
- print_help(file=None)
- print_usage(file=None)
- register(registry_name, value, object)
- set_defaults(**kwargs)
- class euporie.core.config.BooleanOptionalAction(option_strings: list[str], *args: Any, **kwargs: Any)
Bases:
argparse.Action
Action for boolean flags.
Included because argparse.BooleanOptionalAction is not present in python<=3.9.
- class euporie.core.config.Config
Bases:
object
A configuration store.
- conf_file_name = 'config.json'
- get(name: str, default: Any = None) Any
Access a configuration value, falling back to the default value if unset.
- Parameters
name – The name of the attribute to access.
default – The value to return if the name is not found
- Returns
The configuration variable value.
- get_item(name: str) Any
Access a configuration item.
- Parameters
name – The name of the attribute to access.
- Returns
The configuration item.
- load_env(app_name: str = '') dict[str, Any]
Attempt to load configuration settings from environment variables.
- load_parser() argparse.ArgumentParser
Construct an
ArgumentParser
.
- settings: dict[str, Setting] = {'accent_color': <Setting accent_color='ansiblue'>, 'always_show_tab_bar': <Setting always_show_tab_bar=False>, 'app': <Setting app='notebook'>, 'auth': <Setting auth=True>, 'autocomplete': <Setting autocomplete=False>, 'autoformat': <Setting autoformat=False>, 'autoinspect': <Setting autoinspect=False>, 'autosuggest': <Setting autosuggest=True>, 'background_character': <Setting background_character='·'>, 'background_pattern': <Setting background_pattern=2>, 'cell_start': <Setting cell_start=None>, 'cell_stop': <Setting cell_stop=None>, 'client_keys': <Setting client_keys=['~/.ssh/authorized_keys']>, 'clipboard': <Setting clipboard='external'>, 'color_depth': <Setting color_depth=None>, 'color_scheme': <Setting color_scheme='default'>, 'connection_file': <Setting connection_file=None>, 'cursor_blink': <Setting cursor_blink=False>, 'custom_background_color': <Setting custom_background_color=''>, 'custom_foreground_color': <Setting custom_foreground_color=''>, 'edit_mode': <Setting edit_mode='micro'>, 'expand': <Setting expand=False>, 'external_editor': <Setting external_editor=None>, 'files': <Setting files=[]>, 'format_black': <Setting format_black=True>, 'format_isort': <Setting format_isort=True>, 'format_ssort': <Setting format_ssort=True>, 'graphics': <Setting graphics=None>, 'host': <Setting host=''>, 'host_keys': <Setting host_keys=['/etc/ssh/ssh_host_ecdsa_key']>, 'kernel_name': <Setting kernel_name='python3'>, 'key_bindings': <Setting key_bindings={}>, 'line_numbers': <Setting line_numbers=True>, 'log_config': <Setting log_config=None>, 'log_file': <Setting log_file=''>, 'log_level': <Setting log_level='warning'>, 'max_notebook_width': <Setting max_notebook_width=120>, 'max_stored_outputs': <Setting max_stored_outputs=100>, 'mouse_support': <Setting mouse_support=None>, 'output_file': <Setting output_file='-'>, 'page': <Setting page=False>, 'port': <Setting port=8022>, 'record_cell_timing': <Setting record_cell_timing=False>, 'run': <Setting run=False>, 'run_after_external_edit': <Setting run_after_external_edit=False>, 'save': <Setting save=False>, 'save_widget_state': <Setting save_widget_state=True>, 'set_cursor_shape': <Setting set_cursor_shape=True>, 'show_cell_borders': <Setting show_cell_borders=False>, 'show_file_icons': <Setting show_file_icons=False>, 'show_filenames': <Setting show_filenames=False>, 'show_scroll_bar': <Setting show_scroll_bar=True>, 'show_shadows': <Setting show_shadows=True>, 'show_side_bar': <Setting show_side_bar=False>, 'show_status_bar': <Setting show_status_bar=True>, 'show_top_bar': <Setting show_top_bar=True>, 'syntax_theme': <Setting syntax_theme='euporie'>, 'tab_mode': <Setting tab_mode='stack'>, 'tab_size': <Setting tab_size=4>, 'terminal_polling_interval': <Setting terminal_polling_interval=0>, 'tmux_graphics': <Setting tmux_graphics=False>, 'version': <Setting version=False>, 'wrap_cell_outputs': <Setting wrap_cell_outputs=False>}
- class euporie.core.config.JSONEncoderPlus(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
Bases:
json.encoder.JSONEncoder
JSON encode class which encodes paths as strings.
- default(o: Any) bool | int | float | str | None
Encode an object to JSON.
- Parameters
o – The object to encode
- Returns
The encoded object
- encode(o)
Return a JSON string representation of a Python data structure.
>>> from json.encoder import JSONEncoder >>> JSONEncoder().encode({"foo": ["bar", "baz"]}) '{"foo": ["bar", "baz"]}'
- item_separator = ', '
- iterencode(o, _one_shot=False)
Encode the given object and yield each string representation as available.
For example:
for chunk in JSONEncoder().iterencode(bigobject): mysocket.write(chunk)
- key_separator = ': '
- class euporie.core.config.Setting(name: str, default: Any, help_: str, description: str, type_: Callable[[Any], Any] | None = None, title: str | None = None, choices: list[Any] | None = None, action: argparse.Action | str | None = None, flags: list[str] | None = None, schema: dict[str, Any] | None = None, nargs: str | int | None = None, hidden: FilterOrBool = False, hooks: list[Callable[[Setting], None]] | None = None, cmd_filter: FilterOrBool = True, **kwargs: Any)
Bases:
object
A single configuration item.
Return a menu item for the setting.
- property parser_args: tuple[list[str], dict[str, Any]]
Return arguments for construction of an
argparse.ArgumentParser
.
- property value: Any
Return the current value.
- euporie.core.config.add_setting(name: str, default: Any, help_: str, description: str, type_: Callable[[Any], Any] | None = None, action: argparse.Action | str | None = None, flags: list[str] | None = None, schema: dict[str, Any] | None = None, nargs: str | int | None = None, hidden: FilterOrBool = False, hooks: list[Callable[[Setting], None]] | None = None, cmd_filter: FilterOrBool = True, **kwargs: Any) None
Register a new config item.