euporie.core.config

Define a configuration class for euporie.core.

Functions

add_cmd(**kwargs)

Add a command to the centralized command system.

add_setting(name, default, help_, description)

Register a new config item.

cast(typ, val)

Cast a value to a type.

get_cmd(name)

Get a command from the centralized command system by name.

literal_eval(node_or_string)

Evaluate an expression node or a string containing only a Python expression.

to_filter(bool_or_filter)

Accept both booleans and Filters as input and turn it into a Filter.

user_config_dir([appname, appauthor, ...])

param appname

See appname <platformdirs.api.PlatformDirsABC.appname>.

Classes

ArgumentParser([prog, usage, description, ...])

An argument parser which lexes and formats the help message before printing it.

BooleanOptionalAction(option_strings, *args, ...)

Action for boolean flags.

ChainMap(*maps)

A ChainMap groups multiple dicts (or other mappings) together to create a single, updateable view.

Condition(func)

Turn any callable into a Filter.

Config()

A configuration store.

Event(sender[, handler])

Simple event to which event handlers can be attached. For instance::.

JSONEncoderPlus(*[, skipkeys, ensure_ascii, ...])

JSON encode class which encodes paths as strings.

Path(*args, **kwargs)

PurePath subclass that can make system calls.

Protocol()

Base class for protocol classes.

Setting(name, default, help_, description[, ...])

A single configuration item.

TextIO()

Typed version of the return of open() in text mode.

UPath(*args, **kwargs)

partial

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.

format_usage() str

Format the action string.

Returns

The formatted string.

class euporie.core.config.Config

Bases: object

A configuration store.

conf_file_name = 'config.json'
filter(name: str) Filter

Return a Filter for a configuration item.

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(cls: type[ConfigurableApp]) None

Load the command line, environment, and user configuration.

load_args() dict[str, Any]

Attempt to load configuration settings from commandline flags.

load_config_file() dict[str, Any]

Attempt to load JSON configuration file.

load_env(app_name: str = '') dict[str, Any]

Attempt to load configuration settings from environment variables.

load_parser() argparse.ArgumentParser

Construct an ArgumentParser.

load_user(app_name: str = '') dict[str, Any]

Attempt to load JSON configuration file.

property schema: dict[str, Any]

Return a JSON schema for the config.

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>}
warn() None

Warn about unrecognised configuration items.

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.

property menu: MenuItem

Return a menu item for the setting.

property parser_args: tuple[list[str], dict[str, Any]]

Return arguments for construction of an argparse.ArgumentParser.

register_commands() None

Register commands to set this setting.

property schema: dict[str, Any]

Return a json schema property for the config item.

toggle() None

Toggle the setting’s value.

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.