utils
=====

.. py:module:: utils

.. autoapi-nested-parse::

   Auto Archiver Utilities.



Submodules
----------

.. toctree::
   :maxdepth: 1

   /autoapi/utils/misc/index
   /autoapi/utils/url/index
   /autoapi/utils/webdriver/index






Package Contents
----------------

.. py:function:: mkdir_if_not_exists(folder)

.. py:function:: expand_url(url)

.. py:function:: getattr_or(o: object, prop: str, default=None)

.. py:class:: DateTimeEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

   Bases: :py:obj:`json.JSONEncoder`


   Extensible JSON <https://json.org> encoder for Python data structures.

   Supports the following objects and types by default:

   +-------------------+---------------+
   | Python            | JSON          |
   +===================+===============+
   | dict              | object        |
   +-------------------+---------------+
   | list, tuple       | array         |
   +-------------------+---------------+
   | str               | string        |
   +-------------------+---------------+
   | int, float        | number        |
   +-------------------+---------------+
   | True              | true          |
   +-------------------+---------------+
   | False             | false         |
   +-------------------+---------------+
   | None              | null          |
   +-------------------+---------------+

   To extend this to recognize other objects, subclass and implement a
   ``.default()`` method with another method that returns a serializable
   object for ``o`` if possible, otherwise it should call the superclass
   implementation (to raise ``TypeError``).



   .. py:method:: default(o)

      Implement this method in a subclass such that it returns
      a serializable object for ``o``, or calls the base implementation
      (to raise a ``TypeError``).

      For example, to support arbitrary iterators, you could
      implement default like this::

          def default(self, o):
              try:
                  iterable = iter(o)
              except TypeError:
                  pass
              else:
                  return list(iterable)
              # Let the base class default method raise the TypeError
              return JSONEncoder.default(self, o)




.. py:function:: dump_payload(p)

.. py:function:: update_nested_dict(dictionary, update_dict)

.. py:function:: random_str(length: int = 32) -> str

.. py:function:: json_loader(cli_val)

.. py:function:: calculate_file_hash(filename: str, hash_algo=hashlib.sha256, chunksize: int = 16000000) -> str

.. py:function:: get_current_datetime_iso() -> str

.. py:function:: get_datetime_from_str(dt_str: str, fmt: str | None = None) -> datetime.datetime | None

.. py:function:: get_timestamp(ts, utc=True, iso=True) -> str | datetime.datetime | None

.. py:function:: get_current_timestamp() -> str

.. py:class:: Webdriver(width: int, height: int, timeout_seconds: int, facebook_accept_cookies: bool = False, http_proxy: str = '', print_options: dict = {}, auth: dict = {})

   .. py:attribute:: width


   .. py:attribute:: height


   .. py:attribute:: timeout_seconds


   .. py:attribute:: auth


   .. py:attribute:: facebook_accept_cookies
      :value: False



   .. py:attribute:: http_proxy
      :value: ''



   .. py:attribute:: print_options


