Skip to content

Commit a27b040

Browse files
committed
Merge branch 'master' into seedregen
2 parents ebfa15c + 7fa6e97 commit a27b040

33 files changed

Lines changed: 926 additions & 873 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ build/
66
*.xml
77
Pipfile.lock
88
*.kdbx
9+
*.kdbx.out

CHANGELOG.rst

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
1+
4.0.4 -
12
------------------
2-
- added Entry.delete_history
3+
- fixed #314 - correctly handle binaries with no data
4+
- fixed #265 - check for keepass signature
5+
- fixed #319 - support pathlib for filename/keyfile
6+
- fixed #194 - added 'protected' arg to _set_string_field
7+
- use official icon names from KeePass source and deprecate old icons
8+
- added Entry.is_custom_property_protected()
9+
10+
4.0.3 - 2022-06-21
11+
------------------
12+
- add otp support
13+
- add debug_setup() function
14+
15+
4.0.2 - 2022-05-21
16+
------------------
17+
- added support for argon2id key derivation function
18+
- added credential expiry functions
19+
- fixes #223 - safe saving
20+
21+
4.0.1 - 2021-05-22
22+
------------------
23+
- added Entry.delete_history()
324
- added HistoryEntry class
25+
- added Group.touch()
26+
- support 2.0 keyfiles
27+
- added PyKeePass.reload()
28+
- dropped python2 tests
29+
- fixed #284 - autotype_sequence returns string 'None'
30+
- fixed #244 - incorrect PKCS padding error
431

532
4.0.0 - 2021-01-15
633
------------------

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version := $(shell python -c "exec(open('pykeepass/version.py').read());print(__version__)")
2+
3+
.PHONY: dist
4+
dist:
5+
python setup.py sdist bdist_wheel
6+
7+
.PHONY: pypi
8+
pypi: dist
9+
twine upload dist/pykeepass-$(version).tar.gz
10+
11+
.PHONY: docs
12+
docs:
13+
lazydocs pykeepass --overview-file README.md
14+
ghp-import -f -p -b docs docs

README.rst

Lines changed: 92 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Come chat at `#pykeepass`_ on Freenode or `#pykeepass:matrix.org`_ on Matrix.
2222
.. _#pykeepass\:matrix.org: https://matrix.to/#/%23pykeepass:matrix.org
2323

2424
Example
25-
--------------
25+
-------
2626
.. code:: python
2727
2828
from pykeepass import PyKeePass
@@ -58,12 +58,15 @@ Example
5858
>>> kp.save()
5959
6060
61+
..
62+
TODO: add `Entry` and `Group` sections to document attributes of each
63+
6164
Finding Entries
62-
----------------------
65+
---------------
6366

64-
**find_entries** (title=None, username=None, password=None, url=None, notes=None, path=None, uuid=None, tags=None, string=None, group=None, recursive=True, regex=False, flags=None, history=False, first=False)
67+
**find_entries** (title=None, username=None, password=None, url=None, notes=None, otp=None, path=None, uuid=None, tags=None, string=None, group=None, recursive=True, regex=False, flags=None, history=False, first=False)
6568

66-
Returns entries which match all provided parameters, where ``title``, ``username``, ``password``, ``url``, ``notes``, and ``autotype_sequence`` are strings, ``path`` is a list, ``string`` is a dict, ``autotype_enabled`` is a boolean, ``uuid`` is a ``uuid.UUID`` and ``tags`` is a list of strings. This function has optional ``regex`` boolean and ``flags`` string arguments, which means to interpret search strings as `XSLT style`_ regular expressions with `flags`_.
69+
Returns entries which match all provided parameters, where ``title``, ``username``, ``password``, ``url``, ``notes``, ``otp``, and ``autotype_sequence`` are strings, ``path`` is a list, ``string`` is a dict, ``autotype_enabled`` is a boolean, ``uuid`` is a ``uuid.UUID`` and ``tags`` is a list of strings. This function has optional ``regex`` boolean and ``flags`` string arguments, which means to interpret search strings as `XSLT style`_ regular expressions with `flags`_.
6770

6871
.. _XSLT style: https://www.xml.com/pub/a/2003/06/04/tr.html
6972
.. _flags: https://www.w3.org/TR/xpath-functions/#flags
@@ -101,14 +104,19 @@ a flattened list of all entries in the database
101104
'facebook.com'
102105
>>> entry.title
103106
'foo_entry'
107+
>>> entry.title = 'hello'
104108
105109
>>> group = kp.find_group(name='social', first=True)
106110
>>> kp.find_entries(title='facebook', group=group, recursive=False, first=True)
107111
Entry: "social/facebook (myusername)"
108112
113+
>>> entry.otp
114+
otpauth://totp/test:lkj?secret=TEST%3D%3D%3D%3D&period=30&digits=6&issuer=test
115+
116+
109117
110118
Finding Groups
111-
----------------------
119+
--------------
112120

113121
**find_groups** (name=None, path=None, uuid=None, notes=None, group=None, recursive=True, regex=False, flags=None, first=False)
114122

@@ -155,12 +163,16 @@ a flattened list of all groups in the database
155163
Group: "/"
156164
157165
158-
Adding Entries
159-
--------------
166+
Entry Functions
167+
---------------
160168
**add_entry** (destination_group, title, username, password, url=None, notes=None, tags=None, expiry_time=None, icon=None, force_creation=False)
161169

162170
**delete_entry** (entry)
163171

172+
**trash_entry** (entry)
173+
174+
move a group to the recycle bin. The recycle bin is created if it does not exit. ``entry`` must be an empty Entry.
175+
164176
**move_entry** (entry, destination_group)
165177

166178
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.
@@ -174,7 +186,7 @@ If ``expiry_time`` is a naive datetime object (i.e. ``expiry_time.tzinfo`` is no
174186
Entry: "testing (foo_user)"
175187
176188
# add a new entry to the social group
177-
>>> group = find_groups(name='social', first=True)
189+
>>> group = kp.find_groups(name='social', first=True)
178190
>>> entry = kp.add_entry(group, 'testing', 'foo_user', 'passw0rd')
179191
Entry: "testing (foo_user)"
180192
@@ -190,12 +202,20 @@ If ``expiry_time`` is a naive datetime object (i.e. ``expiry_time.tzinfo`` is no
190202
# save the database
191203
>>> kp.save()
192204
193-
Adding Groups
194-
--------------
205+
Group Functions
206+
---------------
195207
**add_group** (destination_group, group_name, icon=None, notes=None)
196208

197209
**delete_group** (group)
198210

211+
**trash_group** (group)
212+
213+
move a group to the recycle bin. The recycle bin is created if it does not exit. ``group`` must be an empty Group.
214+
215+
**empty_group** (group)
216+
217+
delete all entries and subgroups of a group. ``group`` is an instance of ``Group``.
218+
199219
**move_group** (group, destination_group)
200220

201221
``destination_group`` and ``group`` are instances of ``Group``. ``group_name`` is a string
@@ -224,11 +244,11 @@ Adding Groups
224244
Attachments
225245
-----------
226246

227-
In this section, *binary* refers to the bytes of the attached data (stored at the root level of the database), while *attachment* is a reference to a binary (stored in an entry). A binary can have none, one or many attachments.
247+
In this section, *binary* refers to the bytes of the attached data (stored at the root level of the database), while *attachment* is a reference to a binary (stored in an entry). A binary can be referenced by none, one or many attachments.
228248

229249
**add_binary** (data, compressed=True, protected=True)
230250

231-
where ``data`` is bytes. Adds a blob of data to the database. The attachment reference must still be added to an entry (see below). ``compressed`` only applies to KDBX3 and ``protected`` only applies to KDBX4. Returns id of attachment.
251+
where ``data`` is bytes. Adds a blob of data to the database. The attachment reference must still be added to an entry (see below). ``compressed`` only applies to KDBX3 and ``protected`` only applies to KDBX4 (no effect if used on wrong database version). Returns id of attachment.
232252

233253
**delete_binary** (id)
234254

@@ -243,7 +263,7 @@ where ``id`` is an int, ``filename`` is a string, and element is an ``Entry`` or
243263

244264
**binaries**
245265

246-
list of bytestrings containing binary data. List index corresponds to attachment id.
266+
list of bytestrings containing binary data. List index corresponds to attachment id
247267

248268
**attachments**
249269

@@ -310,13 +330,37 @@ the entry that this attachment is attached to
310330
311331
# search attachments
312332
>>> kp.find_attachments(filename='hello.txt')
313-
[Attachment: 'hello.txt' -> 0]
333+
[Attachment: 'hello.txt** -> 0]
314334
315335
# delete attachment reference
316336
>>> e.delete_attachment(a)
317337
318338
# or, delete both attachment reference and binary
319-
>>> kp.delete_binary(binary_id)
339+
>>> kp.delete_binary(binary_id**
340+
341+
Credential Expiry
342+
-----------------
343+
344+
**credchange_date**
345+
346+
datetime object with date of last credentials change
347+
348+
**credchange_required**
349+
350+
boolean whether database credentials have expired and are required to change
351+
352+
**credchange_recommended**
353+
354+
boolean whether database credentials have expired and are recommended to change
355+
356+
**credchange_required_days**
357+
358+
days after **credchange_date** that credential update is required
359+
360+
**credchange_recommended_days**
361+
362+
days after **credchange_date** that credential update is recommended
363+
320364
321365
Miscellaneous
322366
-------------
@@ -326,13 +370,21 @@ where ``filename``, ``password``, and ``keyfile`` are strings. ``filename`` is
326370
327371
Can raise ``CredentialsError``, ``HeaderChecksumError``, or ``PayloadChecksumError``.
328372
373+
**reload** ()
374+
375+
reload database from disk using previous credentials
376+
329377
**save** (filename=None)
330378
331379
where ``filename`` is the path of the file to save to. If ``filename`` is not given, the path given in ``read`` will be used.
332380
333381
**password**
334382
335-
string containing database password. Can also be set. Use ``None`` for no password.
383+
string containing database password. Can also be set. Use ``None** for no password.
384+
385+
**filename**
386+
387+
string containing path to database. Can also be set
336388
337389
**keyfile**
338390
@@ -350,15 +402,32 @@ string containing algorithm used to encrypt database. Possible values are ``aes
350402
351403
create a new database at ``filename`` with supplied credentials. Returns ``PyKeePass`` object
352404
353-
**trash_group** (group)
405+
**tree**
354406
355-
move a group to the recycle bin. The recycle bin is created if it does not exit. ``group`` must be an empty Group.
407+
database lxml tree
356408
357-
**empty_group** (group)
409+
**xml**
358410
359-
delete all entries and subgroups of a group. ``group`` is an instance of ``Group``.
411+
get database XML data as string
360412
361-
Tests
362-
-------------
413+
**dump_xml** (filename)
414+
415+
pretty print database XML to file
416+
417+
418+
Tests and Debugging
419+
-------------------
420+
421+
Run tests with :code:`python tests/tests.py` or :code:`python tests/tests.py SomeSpecificTest`
422+
423+
Enable debugging when doing tests in console:
363424
364-
To run them issue :code:`python tests/tests.py`
425+
>>> from pykeepass.pykeepass import debug_setup
426+
>>> debug_setup()
427+
>>> kp.entries[0]
428+
DEBUG:pykeepass.pykeepass:xpath query: //Entry
429+
DEBUG:pykeepass.pykeepass:xpath query: (ancestor::Group)[last()]
430+
DEBUG:pykeepass.pykeepass:xpath query: (ancestor::Group)[last()]
431+
DEBUG:pykeepass.pykeepass:xpath query: String/Key[text()="Title"]/../Value
432+
DEBUG:pykeepass.pykeepass:xpath query: String/Key[text()="UserName"]/../Value
433+
Entry: "root_entry (foobar_user)"

doc/Makefile

Lines changed: 0 additions & 20 deletions
This file was deleted.

doc/make.bat

Lines changed: 0 additions & 35 deletions
This file was deleted.

doc/source/attachment.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.

doc/source/baseelement.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)