citylearn.utilities module

class citylearn.utilities.FileHandler[source]

Bases: object

static join_url(*args: str) str[source]
static read_json(filepath: str, **kwargs) dict[source]

Return JSON document as dictionary.

Parameters:
  • filepath (str)

  • document. (pathname of JSON)

  • **kwargs (dict) – Other infrequently used keyword arguments to be parsed to simplejson.load.

Returns:

JSON document converted to dictionary.

Return type:

dict

static read_pickle(filepath: str, **kwargs) Any[source]

Return pickle file as some Python class object.

Parameters:
  • filepath (str)

  • file. (pathname of pickle)

  • **kwargs (dict) – Other infrequently used keyword arguments to be parsed to pickle.load.

Returns:

Pickle file as a Python object.

Return type:

Any

static read_yaml(filepath: str) dict[source]

Return YAML document as dictionary.

Parameters:
  • filepath (str)

  • document. (pathname of YAML)

Returns:

YAML document converted to dictionary.

Return type:

dict

static write_json(filepath: str, dictionary: dict, **kwargs)[source]

Write dictionary to JSON file.

Parameters:
  • filepath (str) – pathname of JSON document.

  • dictionary (dict) – dictionary to convert to JSON.

  • **kwargs (dict) – Other infrequently used keyword arguments to be parsed to simplejson.dump.

static write_pickle(filepath: str, data: Any, **kwargs)[source]

Write Python object to pickle file.

Parameters:
  • filepath (str) – pathname of pickle document.

  • data (dict) – object to convert to pickle.

  • **kwargs (dict) – Other infrequently used keyword arguments to be parsed to pickle.dump.

static write_yaml(filepath: str, dictionary: dict, **kwargs)[source]

Write dictionary to YAML file.

Parameters:
  • filepath (str) – pathname of YAML document.

  • dictionary (dict) – dictionary to convert to YAML.

  • **kwargs (dict) – Other infrequently used keyword arguments to be parsed to yaml.safe_dump.