:py:mod:`khard.helpers.typing`
==============================

.. py:module:: khard.helpers.typing

.. autoapi-nested-parse::

   Helper code for type annotations and runtime type conversion.



Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   khard.helpers.typing.ObjectType



Functions
~~~~~~~~~

.. autoapisummary::

   khard.helpers.typing.convert_to_vcard
   khard.helpers.typing.list_to_string
   khard.helpers.typing.string_to_list
   khard.helpers.typing.string_to_date



Attributes
~~~~~~~~~~

.. autoapisummary::

   khard.helpers.typing.Date
   khard.helpers.typing.StrList


.. py:class:: ObjectType

   Bases: :py:obj:`enum.Enum`

   Generic enumeration.

   Derive from this class to define new enumerations.

   .. py:attribute:: str
      :annotation: = 1

      

   .. py:attribute:: list
      :annotation: = 2

      

   .. py:attribute:: both
      :annotation: = 3

      


.. py:data:: Date
   

   

.. py:data:: StrList
   

   

.. py:function:: convert_to_vcard(name: str, value: StrList, constraint: ObjectType) -> StrList

   converts user input into vcard compatible data structures

   :param name: object name, only required for error messages
   :param value: user input
   :param constraint: set the accepted return type for vcard attribute
   :returns: cleaned user input, ready for vcard or a ValueError


.. py:function:: list_to_string(input: Union[str, List], delimiter: str) -> str

   converts list to string recursively so that nested lists are supported

   :param input: a list of strings and lists of strings (and so on recursive)
   :param delimiter: the deimiter to use when joining the items
   :returns: the recursively joined list


.. py:function:: string_to_list(input: Union[str, List[str]], delimiter: str) -> List[str]


.. py:function:: string_to_date(string: str) -> datetime.datetime

   Convert a date string into a date object.

   :param string: the date string to parse
   :returns: the parsed datetime object


