ugokukun.ugoku_helpers

class ugokukun.ugoku_helpers.UgokuHelpers[source]

Bases: object

Helper functions for ugoku-kun.

All methods are static.

static import_json(fpath: str, decode: str = 'utf-8', content_is_str: bool = False) Dict | List[source]

Take a json file and import it

Parameters:
  • fpath (str) – import file path

  • decode (str, optional) – file encoding, by default “utf-8”

  • content_is_str (bool, optional) – True if entire file content is pure string, by default False Sometimes, json gets read as a single string, so this method re-loads the laoded data.

Returns:

imported json data

Return type:

Union[Dict, List]

Raises:

FileNotFoundError – File not found

static strtobool(bool_str: str, true_str: List[str] = None, false_str: List[str] = None) bool[source]

Workaround for distutils.util.strtobool getting deprecated (PEP632).

Parameters:
  • bool_str (str) – String to be converted to bool. numpy.bool is accepted as type str.

  • true_str (List[str], optional) – List of strings that represent True, by default [“true”, “t”, “yes”, “y”, “1”, “mark”]

  • false_str (List[str], optional) – List of strings that represent False, by default [“false”, “f”, “no”, “n”, “0”, “space”]

Returns:

Converted bool. From numpy 2.0.0: if numpy.bool is passed, it will return as is.

Return type:

bool

Raises:

ValueError – Could not convert to bool