Skip to content

myke.io

myke.read

Functions for reading.

Classes

read

Functions

cfg classmethod
cfg(*args: str, **kwargs: str) -> Dict[str, Any]

Parse object(s) from a INI/CFG text file.

PARAMETER DESCRIPTION
*args

...

TYPE: str DEFAULT: ()

**kwargs

...

TYPE: str DEFAULT: {}

RETURNS DESCRIPTION
Dict[str, Any]

...

Examples:

>>> import myke
...
>>> myke.read.cfg('/path/to/file.cfg')
dotfile classmethod
dotfile(*args: str, **kwargs: str) -> Dict[str, str]

Parse key-value pairs from a dotfile (aka "envfile").

PARAMETER DESCRIPTION
*args

...

TYPE: str DEFAULT: ()

**kwargs

...

TYPE: str DEFAULT: {}

RETURNS DESCRIPTION
Dict[str, str]

...

Examples:

>>> import myke
...
>>> myke.read.dotfile('/path/to/vars.env')
envfile classmethod
envfile(*args: str, **kwargs: str) -> Dict[str, str]

Parse key-value pairs from a dotfile (aka "envfile").

PARAMETER DESCRIPTION
*args

...

TYPE: str DEFAULT: ()

**kwargs

...

TYPE: str DEFAULT: {}

RETURNS DESCRIPTION
Dict[str, str]

...

Examples:

>>> import myke
...
>>> myke.read.envfile('/path/to/vars.env')
ini classmethod
ini(*args: str, **kwargs: str) -> Dict[str, Any]

Parse object(s) from a INI/CFG text file.

PARAMETER DESCRIPTION
*args

...

TYPE: str DEFAULT: ()

**kwargs

...

TYPE: str DEFAULT: {}

RETURNS DESCRIPTION
Dict[str, Any]

...

Examples:

>>> import myke
...
>>> myke.read.ini('/path/to/file.ini')
json classmethod
json(*args: str, **kwargs: str) -> Dict[str, Any]

Parse object(s) from a JSON text file.

PARAMETER DESCRIPTION
*args

...

TYPE: str DEFAULT: ()

**kwargs

...

TYPE: str DEFAULT: {}

RETURNS DESCRIPTION
Dict[str, Any]

...

Examples:

>>> import myke
...
>>> myke.read.json('/path/to/file.json')
lines classmethod
lines(*args: str, **kwargs: str) -> List[str]

Read lines from a text file, strip whitespace from each line, and return list of non-empty elements.

PARAMETER DESCRIPTION
*args

...

TYPE: str DEFAULT: ()

**kwargs

...

TYPE: str DEFAULT: {}

RETURNS DESCRIPTION
List[str]

...

Examples:

>>> import myke
...
>>> myke.read.lines('/path/to/file.txt')
text staticmethod
text(path: Union[str, Path], encoding: str = 'utf-8') -> str

Read text file contents and strip surrounding whitespace.

Equivalent to: Path(path).read_text().strip()

PARAMETER DESCRIPTION
path

...

TYPE: Union[str, Path]

encoding

...

TYPE: str DEFAULT: 'utf-8'

RETURNS DESCRIPTION
str

...

Examples:

>>> import myke
...
>>> myke.read.text('/path/to/file.txt')
toml classmethod
toml(*args: str, **kwargs: str) -> Dict[str, Any]

Parse object(s) from a TOML text file.

PARAMETER DESCRIPTION
*args

...

TYPE: str DEFAULT: ()

**kwargs

...

TYPE: str DEFAULT: {}

RETURNS DESCRIPTION
Dict[str, Any]

...

Examples:

>>> import myke
...
>>> myke.read.toml('/path/to/file.toml')
url classmethod
url(addr: str, **kwargs: Any) -> str

Return text from HTTP GET response.

PARAMETER DESCRIPTION
addr

URL of the remote file.

TYPE: str

**kwargs

passed to requests.request

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
str

...

Examples:

>>> import myke
...
>>> myke.read.url('https://github.com/.../README.md')
url_json classmethod
url_json(addr: str, **kwargs: Any) -> Dict[str, Any]

Parse JSON from HTTP GET response.

PARAMETER DESCRIPTION
addr

URL of the remote file.

TYPE: str

**kwargs

passed to requests.request

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
Dict[str, Any]

...

Examples:

>>> import myke
...
>>> myke.read.url_json('https://github.com/.../data.json')
yaml classmethod
yaml(*args: str, **kwargs: str) -> Dict[str, Any]

Parse object(s) from a YAML text file.

PARAMETER DESCRIPTION
*args

...

TYPE: str DEFAULT: ()

**kwargs

...

TYPE: str DEFAULT: {}

RETURNS DESCRIPTION
Dict[str, Any]

...

Examples:

>>> import myke
...
>>> myke.read.yaml('/path/to/file.yaml')
yaml_all classmethod
yaml_all(*args: str, **kwargs: str) -> List[Dict[str, Any]]

Parse object(s) from multiple documents in a single YAML text file.

PARAMETER DESCRIPTION
*args

...

TYPE: str DEFAULT: ()

**kwargs

...

TYPE: str DEFAULT: {}

RETURNS DESCRIPTION
List[Dict[str, Any]]

...

Examples:

>>> import myke
...
>>> myke.read.yaml_all('/path/to/file.yaml')