honestnft_utils.misc

honestnft_utils.misc.strtobool(val)

Convert a string representation of truth to True or False.

True values are ‘y’, ‘yes’, ‘t’, ‘true’, ‘on’, and ‘1’; false values are ‘n’, ‘no’, ‘f’, ‘false’, ‘off’, and ‘0’.

Parameters

val (str) – string representation of truth

Raises

ValueError – if val can’t be converted to a truthish value

Return type

bool

Returns

True or False

honestnft_utils.misc.mount_session(allowed_methods=['GET'], total_retries=5, backoff_factor=0.5, raise_on_status=True, user_agent=None)

Create a requests.session() with optimised strategy for retrying and respecting errors

Parameters
  • allowed_methods (List[str]) – List of uppercased HTTP method verbs that we should retry on.

  • total_retries (int) – Total number of retries to allow.

  • backoff_factor (float) – A backoff factor to apply between attempts after the second try.

  • raise_on_status (bool) – Whether we should raise an exception, or return a response, if status falls in status_forcelist range and retries have been exhausted.

  • user_agent (Optional[str]) – The user agent to use for the session

Return type

Session

Returns

A requests session with retry and error handling

honestnft_utils.misc.get_first_filename_in_dir(dir_path)

Get the first filename in a directory

Parameters

dir_path (Path) – The path to the directory

Raises

FileNotFoundError – if the directory is empty

Return type

str

Returns

The name of the first file in the directory