Load references and patches#

class rconf.Loader#

Load configurations, replace references and apply patches.

Uses

__init__(opener=None, decoder=None)#

Build a rconf.Loader.

Parameters:
Return type:

None

load(fp, media_type=None, url=None, *, ptr=None, **kwargs)#

Decode a read-supporting binary file with references and patches.

Parameters:
  • fp (BinaryIO) – read-supporting binary file.

  • media_type (str | None) – Assumed media type, overrides URL-derived media type. It can also be a filename extension.

  • url (str | Path | None) – Assumed document URL or path for media type, fragment and relative reference resolution.

  • ptr (str | None) – Fragment pointer, overrides URL fragment.

  • kwargs – Forwarded to rconf.decode.DecoderDirector.

Raises:

rconf.decode.DecodeError in case of decode errors, rconf.patch.PatchError for patch errors.

Return type:

rconf.Value

loadc(config, media_type=None, url=None, *, ptr=None, **kwargs)#

Decode a configuration document with references and patches.

Parameters:
  • config (rconf.Value) – Configuration rconf.Value.

  • media_type (str | None) – Assumed media type, overrides URL-derived media type. It can also be a filename extension.

  • url (str | Path | None) – Assumed document URL or path for media type, fragment and relative reference resolution.

  • ptr (str | None) – Fragment pointer, overrides URL fragment.

  • kwargs – Forwarded to rconf.decode.DecoderDirector.

Raises:

rconf.decode.DecodeError in case of decode errors, rconf.patch.PatchError for patch errors.

Return type:

rconf.Value

loads(s, media_type=None, url=None, *, ptr=None, **kwargs)#

Decode a str configuration document with references and patches.

Parameters:
  • s (str) – Configuration document.

  • media_type (str | None) – Assumed media type, overrides URL-derived media type. It can also be a filename extension.

  • url (str | Path | None) – Assumed document URL or path for media type, fragment and relative reference resolution.

  • ptr (str | None) – Fragment pointer, overrides URL fragment.

  • kwargs – Forwarded to rconf.decode.DecoderDirector.

Raises:

rconf.decode.DecodeError in case of decode errors, rconf.patch.PatchError for patch errors.

Return type:

rconf.Value

loadu(url, media_type=None, *, base_url=None, ptr=None, **kwargs)#

Decode a configuration document at a URL or path with references and patches.

Parameters:
  • url (str | Path) – Document URL or path, optionally with a language-specific pointer as URL fragment.

  • media_type (str | None) – Assumed media type, overrides URL-derived media type and content-type from urllib.request.OpenerDirector.open(). It can also be a filename extension.

  • base_url (str | Path | None) – Assumed document URL or path for relative reference resolution, overrides URL base.

  • ptr (str | None) – Fragment pointer, overrides URL fragment.

  • kwargs – Forwarded to rconf.decode.DecoderDirector.

Raises:

rconf.decode.DecodeError in case of decode errors, rconf.patch.PatchError for patch errors.

Return type:

rconf.Value