Utils

Catch-all module containing methods that might be helpful to GNewCash users.

utils.delete_log_files(gnucash_folder: str | PathLike, ignore_permission_errors: bool = True) None[source]

Deletes log files at the specified directory.

Parameters:
  • gnucash_folder (Union[str, PathLike]) – Directory to delete log files

  • ignore_permission_errors (bool) – Ignore PermissionError thrown when deleting files. (default true)

utils.safe_iso_date_formatting(date_obj: datetime) str[source]

Attempts for format a date with timezone information. If it fails, it tries to format without timezone information.

Parameters:

date_obj (datetime.datetime) – Date object to format

Returns:

Formatted date string

Return type:

str

utils.safe_iso_date_parsing(date_string: str) datetime[source]

Attempts to parse a date with timezone information. If it fails, it tries to parse without timezone information.

Parameters:

date_string (str) – Date string to parse

Returns:

Parsed date object

Return type:

datetime.datetime