diff --git a/.gitignore b/.gitignore index 164a5c0..ece74b0 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ Pipfile.lock .idea .venv* TMPNOTES +docs/ diff --git a/Makefile b/Makefile index a8d22b6..21981eb 100644 --- a/Makefile +++ b/Makefile @@ -46,5 +46,5 @@ tag: .PHONY: docs docs: - lazydocs pykeepass --overview-file README.md + pdoc -o docs --docformat google --no-search pykeepass '!pykeepass.icons' ghp-import -f -p -b docs docs diff --git a/pykeepass/__init__.py b/pykeepass/__init__.py index 72135b4..0bed1cc 100644 --- a/pykeepass/__init__.py +++ b/pykeepass/__init__.py @@ -1,4 +1,12 @@ +""" +.. include:: ../README.md +""" + from .pykeepass import PyKeePass, create_database +from .entry import Entry +from .group import Group +from .attachment import Attachment +from .icons import icons as icons from .version import __version__ -__all__ = ["PyKeePass", "create_database", "__version__"] +__all__ = ["PyKeePass", "Entry", "Group", "Attachment", "icons", "create_database", "__version__"] diff --git a/pykeepass/pykeepass.py b/pykeepass/pykeepass.py index ca5078b..776b620 100644 --- a/pykeepass/pykeepass.py +++ b/pykeepass/pykeepass.py @@ -30,7 +30,6 @@ logger = logging.getLogger(__name__) - BLANK_DATABASE_FILENAME = "blank_database.kdbx" BLANK_DATABASE_LOCATION = os.path.join(os.path.dirname(os.path.realpath(__file__)), BLANK_DATABASE_FILENAME) BLANK_DATABASE_PASSWORD = "password" @@ -323,7 +322,7 @@ def dump_xml(self, filename): with open(filename, 'wb') as f: f.write(self.xml()) - def _xpath(self, xpath_str, tree=None, first=False, cast=False, **kwargs): + def xpath(self, xpath_str, tree=None, first=False, cast=False, **kwargs): """Look up elements in the XML payload and return corresponding object. Internal function which searches the payload lxml ElementTree for @@ -332,18 +331,18 @@ def _xpath(self, xpath_str, tree=None, first=False, cast=False, **kwargs): is raised. Args: - xpath_str (str): XPath query for finding element(s) - tree (:obj:`_ElementTree`, :obj:`Element`, optional): use this + xpath_str (`str`): XPath query for finding element(s) + tree (`_ElementTree`, `Element`, optional): use this element as root node when searching - first (bool): If True, function returns first result or None. If - False, function returns list of matches or empty list. Default - is False. - cast (bool): If True, matches are instead instantiated as + first (`bool`): If True, function returns first result or None. If + False, function returns list of matches or empty list. + (default `False`). + cast (`bool`): If True, matches are instead instantiated as pykeepass Group, Entry, or Attachment objects. An exception - is raised if a match cannot be cast. Default is False. + is raised if a match cannot be cast. (default `False`) Returns: - `Group`, `Entry`, `Attachment`, or `lxml.etree.Element` + `list` of `Group`, `Entry`, `Attachment`, or `lxml.etree.Element` """ if tree is None: @@ -373,6 +372,8 @@ def _xpath(self, xpath_str, tree=None, first=False, cast=False, **kwargs): return res + _xpath = xpath + def _find(self, prefix, keys_xp, path=None, tree=None, first=False, history=False, regex=False, flags=None, **kwargs): """Internal function for converting a search into an XPath string"""