Skip to content

Commit

Permalink
add time examples/docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Evidlo committed Feb 29, 2024
1 parent 9a65d26 commit 14d7cd1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
46 changes: 42 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ a flattened list of all groups in the database
Group: "/"
Entry Functions
---------------
Entry Functions and Properties
------------------------------
**add_entry** (destination_group, title, username, password, url=None, notes=None, tags=None, expiry_time=None, icon=None, force_creation=False)

**delete_entry** (entry)
Expand All @@ -183,6 +183,18 @@ move a group to the recycle bin. The recycle bin is created if it does not exit

**move_entry** (entry, destination_group)

**atime**

access time

**ctime**

creation time

**mtime**

modification time

where ``destination_group`` is a ``Group`` instance. ``entry`` is an ``Entry`` instance. ``title``, ``username``, ``password``, ``url``, ``notes``, ``tags``, ``icon`` are strings. ``expiry_time`` is a ``datetime`` instance.

If ``expiry_time`` is a naive datetime object (i.e. ``expiry_time.tzinfo`` is not set), the timezone is retrieved from ``dateutil.tz.gettz()``.
Expand Down Expand Up @@ -210,8 +222,15 @@ If ``expiry_time`` is a naive datetime object (i.e. ``expiry_time.tzinfo`` is no
# save the database
>>> kp.save()
Group Functions
---------------
# change creation time
>>> from datetime import datetime, timezone
>>> entry.ctime = datetime(2023, 1, 1, tzinfo=timezone.utc)
# update modification or access time
>>> entry.touch(modify=True)
Group Functions and Properties
------------------------------
**add_group** (destination_group, group_name, icon=None, notes=None)

**delete_group** (group)
Expand All @@ -226,6 +245,18 @@ delete all entries and subgroups of a group. ``group`` is an instance of ``Grou

**move_group** (group, destination_group)

**atime**

access time

**ctime**

creation time

**mtime**

modification time

``destination_group`` and ``group`` are instances of ``Group``. ``group_name`` is a string

.. code:: python
Expand All @@ -249,6 +280,13 @@ delete all entries and subgroups of a group. ``group`` is an instance of ``Grou
# save the database
>>> kp.save()
# change creation time
>>> from datetime import datetime, timezone
>>> group.ctime = datetime(2023, 1, 1, tzinfo=timezone.utc)
# update modification or access time
>>> group.touch(modify=True)
Attachments
-----------

Expand Down
3 changes: 3 additions & 0 deletions pykeepass/baseelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def expiry_time(self, value):

@property
def ctime(self):
"""(datetime.datetime): Creation time."""
return self._get_times_property('CreationTime')

@ctime.setter
Expand All @@ -140,6 +141,7 @@ def ctime(self, value):

@property
def atime(self):
"""(datetime.datetime): Access time. Update with touch()"""
return self._get_times_property('LastAccessTime')

@atime.setter
Expand All @@ -148,6 +150,7 @@ def atime(self, value):

@property
def mtime(self):
"""(datetime.datetime): Access time. Update with touch(modify=True)"""
return self._get_times_property('LastModificationTime')

@mtime.setter
Expand Down

0 comments on commit 14d7cd1

Please sign in to comment.