khard.helpers.typing
====================

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

.. autoapi-nested-parse::

   Helper code for type annotations and runtime type conversion.



Attributes
----------

.. autoapisummary::

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


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


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

.. py:data:: Date

.. py:data:: StrList

.. py:data:: PostAddress

.. py:function:: convert_to_vcard(name: str, value: StrList, constraint: type[str]) -> str
                 convert_to_vcard(name: str, value: StrList, constraint: type[list]) -> list[str]
                 convert_to_vcard(name: str, value: StrList, constraint: None) -> 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 delimiter 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


