typeddfs._mixins._ini_like_mixin

Mixin for INI, .properties, and TOML.

Module Contents

class typeddfs._mixins._ini_like_mixin._IniLikeMixin
classmethod _assert_can_write_properties_class(cls) None
_assert_can_write_properties_instance(self) None
classmethod _properties_files_apply(cls) bool
classmethod _read_properties_like(cls, unescape_keys, unescape_values, comment_chars: Set[str], strip_quotes: bool, path_or_buff, **kwargs) __qualname__

Reads a .properties-like file.

_to_properties_like(self, escape_keys, escape_values, sep: str, comment_char: str, path_or_buff=None, mode: str = 'w', comment: Union[None, str, Sequence[str]] = None, **kwargs) Optional[str]

Writes a .properties-like file.

classmethod read_ini(cls, path_or_buff, hash_sign: bool = False, strip_quotes: bool = False, **kwargs) __qualname__

Reads an INI file.

Caution

This is provided as a preview. It may have issues and may change.

Parameters
  • path_or_buff – Path or buffer

  • hash_sign – Allow # to denote a comment (as well as ;)

  • strip_quotes – Remove quotation marks (”” or β€˜β€™) surrounding the values

  • kwargs – Passed to typeddfs.utils.Utils.read()

classmethod read_properties(cls, path_or_buff, strip_quotes: bool = False, **kwargs) __qualname__

Reads a .properties file. Backslashes, colons, spaces, and equal signs are escaped in keys and values.

Caution

This is provided as a preview. It may have issues and may change. It currently does not support continued lines (ending with an odd number of backslashes).

Parameters
  • path_or_buff – Path or buffer

  • strip_quotes – Remove quotation marks (β€œβ€) surrounding values

  • kwargs – Passed to read_csv; avoid setting

classmethod read_toml(cls, path_or_buff, aot: Optional[str] = 'row', aot_only: bool = True, **kwargs) __qualname__

Reads a TOML file.

Caution

This is provided as a preview. It may have issues and may change.

Parameters
  • path_or_buff – Path or buffer

  • aot – The name of the array of tables (i.e. [[ table ]]) If None, finds the unique outermost TOML key, implying aot_only.

  • aot_only – Fail if any outermost keys other than the AOT are found

  • kwargs – Passed to Utils.read

to_ini(self, path_or_buff=None, comment: Union[None, str, Sequence[str]] = None, mode: str = 'w', **kwargs) __qualname__

Writes an INI file.

Caution

This is provided as a preview. It may have issues and may change.

Parameters
  • path_or_buff – Path or buffer

  • comment – Comment line(s) to add at the top of the document

  • mode – β€˜w’ (write) or β€˜a’ (append)

  • kwargs – Passed to typeddfs.utils.Utils.write()

to_properties(self, path_or_buff=None, mode: str = 'w', *, comment: Union[None, str, Sequence[str]] = None, **kwargs) Optional[str]

Writes a .properties file. Backslashes, colons, spaces, and equal signs are escaped in keys. Backslashes are escaped in values. The separator is always =.

Caution

This is provided as a preview. It may have issues and may change.

Parameters
  • path_or_buff – Path or buffer

  • comment – Comment line(s) to add at the top of the document

  • mode – Write (β€˜w’) or append (β€˜a’)

  • kwargs – Passed to typeddfs.utils.Utils.write()

Returns

The string data if path_or_buff is a buffer; None if it is a file

to_toml(self, path_or_buff=None, aot: str = 'row', comment: Union[None, str, Sequence[str]] = None, mode: str = 'w', **kwargs) __qualname__

Writes a TOML file.

Caution

This is provided as a preview. It may have issues and may change.

Parameters
  • path_or_buff – Path or buffer

  • aot – The name of the array of tables (i.e. [[ table ]])

  • comment – Comment line(s) to add at the top of the document

  • mode – β€˜w’ (write) or β€˜a’ (append)

  • kwargs – Passed to typeddfs.utils.Utils.write()