mex.editor package

Subpackages

Submodules

mex.editor.frontend module

mex.editor.frontend._get_node_env() dict[str, str]

Return environment variables for the nodeenv.

mex.editor.frontend._get_npm_command() list[str]

Return the npm command.

mex.editor.frontend._get_npx_command() list[str]

Return the npx command.

mex.editor.frontend.build() None

Build the angular frontend.

mex.editor.frontend.exec_npm(npm_args: list[str]) CompletedProcess[bytes]

Execute an npm command using the nodeenv environment.

mex.editor.frontend.exec_npx(npx_args: list[str]) CompletedProcess[bytes]

Execute an npx command using the nodeenv environment.

mex.editor.frontend.exec_py(py_args: list[str]) CompletedProcess[bytes]

Execute a python module as a subprocess using the current executable.

mex.editor.frontend.install() None

Install nodeenv and npm dependencies.

mex.editor.frontend.install_and_build() None

Install dependencies and build the angular frontend.

mex.editor.frontend.npm() None

Run npm commands via uv run run-npm ….

mex.editor.frontend.npm_watch() Generator[__annotationlib_name_1__]

Start npm run watch and terminate it on exit.

mex.editor.frontend.npx() None

Run npx commands via uv run run-npx ….

mex.editor.frontend.read_npm_version_from_package_json() str | None

Reads the npm version from package.json[‘packageManager’].

mex.editor.logging module

mex.editor.main module

class mex.editor.main.SPAStaticFiles(*, directory: str | PathLike[str] | None = None, packages: list[str | tuple[str, str]] | None = None, html: bool = False, check_dir: bool = True, follow_symlink: bool = False)

Bases: StaticFiles

Custom implementation of StaticFiles for Single Page Applications (SPA).

async get_response(path: str, scope: Scope) Response

Try to serve the file at ‘path’, or fall back to ‘index.html’ for SPA.

This allows browser-based navigation to work correctly.

mex.editor.main.create_fastapi(startup: Literal['api', 'frontend', 'both'] = 'both', mode: Literal['dev'] | None = None) FastAPI

Create and configure the FastAPI application.

mex.editor.main.dev_lifespan(_: FastAPI) AsyncGenerator[None]

Run npm watch during dev mode.

mex.editor.settings module

class mex.editor.settings.EditorSettings(_env_file: Path | str | Sequence[Path | str] | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_nested_delimiter: str | None = None, _secrets_dir: str | Path | None = None, *, MEX_DEBUG: bool = False, MEX_SINK: list[Sink] = [Sink.NDJSON], MEX_ASSETS_DIR: Path = PosixPath('/home/runner/work/mex-editor/mex-editor/assets'), MEX_OPS_DIR: Path = PosixPath('/home/runner/work/mex-editor/mex-editor/ops'), MEX_WORK_DIR: Path = PosixPath('/home/runner/work/mex-editor/mex-editor'), MEX_IDENTITY_PROVIDER: IdentityProvider = IdentityProvider.MEMORY, MEX_ASSETS_CONNECTOR: AssetsConnectorType = AssetsConnectorType.FILESYSTEM, MEX_BACKEND_API_URL: HttpUrl = HttpUrl('http://localhost:8080/'), MEX_BACKEND_API_KEY: SecretStr = SecretStr('**********'), MEX_BACKEND_API_PARALLELIZATION: int = 1, MEX_BACKEND_API_CHUNK_SIZE: int = 25, MEX_VERIFY_SESSION: bool | OpsPath = True, MEX_ORGANIGRAM_PATH: str = 'raw-data/organigram/organizational_units.json', MEX_PRIMARY_SOURCES_PATH: str = 'raw-data/primary-sources/primary-sources.json', MEX_LDAP_URL: SecretStr = SecretStr('**********'), MEX_LDAP_SEARCH_BASE: str = 'dc=ldapmock,dc=local', MEX_WIKI_API_URL: HttpUrl = HttpUrl('http://wikidata/'), MEX_WEB_USER_AGENT: str = 'rki/mex', MEX_ORCID_API_URL: HttpUrl = HttpUrl('https://orcid/'), MEX_EDITOR__HOST: Annotated[str, MinLen(min_length=1), MaxLen(max_length=250)] = 'localhost', MEX_EDITOR__PORT: Annotated[int, Gt(gt=0), Lt(lt=65536)] = 8000, MEX_EDITOR__BASE_HREF: Literal['/', '/editor/'] = '/', MEX_EDITOR__CLIENT_DIR: Path = PosixPath('/home/runner/work/mex-editor/mex-editor/mex/editor/client/dist'))

Bases: BaseSettings

Settings for the editor application.

base_href: Literal['/', '/editor/']
client_dir: Path
host: str
model_config = {'arbitrary_types_allowed': True, 'case_sensitive': False, 'cli_avoid_json': False, 'cli_enforce_required': False, 'cli_exit_on_error': True, 'cli_flag_prefix_char': '-', 'cli_hide_none_type': False, 'cli_ignore_unknown_args': False, 'cli_implicit_flags': False, 'cli_kebab_case': False, 'cli_parse_args': None, 'cli_parse_none_str': None, 'cli_prefix': '', 'cli_prog_name': None, 'cli_shortcuts': None, 'cli_use_class_docs_for_groups': False, 'enable_decoding': True, 'env_file': '.env', 'env_file_encoding': 'utf-8', 'env_ignore_empty': False, 'env_nested_delimiter': '__', 'env_nested_max_split': None, 'env_parse_enums': None, 'env_parse_none_str': None, 'env_prefix': 'mex_', 'env_prefix_target': 'variable', 'extra': 'ignore', 'json_file': None, 'json_file_encoding': None, 'nested_model_default_partial_update': False, 'populate_by_name': True, 'protected_namespaces': ('model_validate', 'model_dump', 'settings_customise_sources'), 'secrets_dir': None, 'toml_file': None, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True, 'validate_default': True, 'yaml_config_section': None, 'yaml_file': None, 'yaml_file_encoding': None}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

port: int

mex.editor.testing module

mex.editor.testing.create_testing_api() FastAPI

Create a FastAPI instance with only the API routes for testing.

mex.editor.testing.create_testing_api_with_frontend() FastAPI

Create a FastAPI instance with API routes and frontend for testing.

mex.editor.testing.run() None

Start the api server and run angular tests against it.

mex.editor.testing.wait_for_server() None

Poll the api server until it responds.

mex.editor.transformer module

exception mex.editor.transformer.DuplicateKeyError(key: str, entry: polib.POEntry, message: str = 'Key already exists and duplicates are not allowed')

Bases: KeyError

Exception raised when a duplicate key created during pofile transformation.

__init__(key: str, entry: polib.POEntry, message: str = 'Key already exists and duplicates are not allowed') None

Initialize DuplicateKeyError.

Parameters:
  • key (str) – The duplicated key.

  • entry (polib.POEntry) – The entry for which the key was generated.

  • message (str, optional) – Defaults to “Key already exists and

  • allowed". (duplicates are not)

mex.editor.transformer.transform_pofile_to_message_format_json(po: polib.POFile | __annotationlib_name_1__) dict[str, str]

Transforms the given pofile (or entries) to message format json.

Parameters:

po (polib.POFile | list[polib.POEntry]) – input to transform.

Raises:

DuplicateKeyError – Raises if the key generation creates a duplicate key.

Returns:

Returns the entries in message format.

Return type:

dict[str, str]

Module contents