| |
- builtins.object
-
- KPDBv1
class KPDBv1(builtins.object) |
|
KPDBv1 represents the KeePass 1.x database.
Attributes:
- groups holds all groups of the database. (list of v1Groups)
- entries holds all entries of the database (list of v1Entries)
- root_group is the root of the group tree (v1Group;
should not accessed directly but the object could be used as a
reference)
- read_only declares if the file should be read-only or not (bool)
- filepath holds the path of the database (string)
- password is the passphrase to encrypt and decrypt the database (string)
- keyfile is the path to a keyfile (string)
Usage:
You can load a KeePass database by the filename and the passphrase or
create an empty database. It's also possible to open the database read-only
and to create a new one.
Example:
from kppy.database import KPDBv1
from kppy.exceptions import KPError
try;
db = KPDBv1(filepath, passphrase)
except KPError as e:
print(e) |
|
Methods defined here:
- __init__(self, filepath=None, password=None, keyfile=None, read_only=False, new=False)
- Initialize a new or an existing database.
If a 'filepath' and a 'masterkey' is passed 'load' will try to open
a database. If 'True' is passed to 'read_only' the database will open
read-only. It's also possible to create a new one, just pass 'True' to
new. This will be ignored if a filepath and a masterkey is given this
will be ignored.
- close(self)
- This method closes the database correctly.
- create_entry(self, group=None, title='', image=1, url='', username='', password='', comment='', y=2999, mon=12, d=28, h=23, min_=59, s=59)
- This method creates a new entry.
The group which should hold the entry is needed.
image must be an unsigned int >0, group a v1Group.
It is possible to give an expire date in the following way:
- y is the year between 1 and 9999 inclusive
- mon is the month between 1 and 12
- d is a day in the given month
- h is a hour between 0 and 23
- min_ is a minute between 0 and 59
- s is a second between 0 and 59
The special date 2999-12-28 23:59:59 means that entry expires never.
- create_group(self, title=None, parent=None, image=1, y=2999, mon=12, d=28, h=23, min_=59, s=59)
- This method creates a new group.
A group title is needed or no group will be created.
If a parent is given, the group will be created as a sub-group.
title must be a string, image an unsigned int >0 and parent a v1Group.
With y, mon, d, h, min_ and s you can set an expiration date like on
entries.
- load(self, buf=None)
- This method opens an existing database.
self.password/self.keyfile and self.filepath must be set.
- lock(self)
- This method locks the database.
- move_entry(self, entry=None, group=None)
- Move an entry to another group.
A v1Group group and a v1Entry entry are needed.
- move_entry_in_group(self, entry=None, index=None)
- Move entry to another position inside a group.
An entry and a valid index to insert the entry in the
entry list of the holding group is needed. 0 means
that the entry is moved to the first position 1 to
the second and so on.
- move_group(self, group=None, parent=None)
- Append group to a new parent.
group and parent must be v1Group-instances.
- move_group_in_parent(self, group=None, index=None)
- Move group to another position in group's parent.
index must be a valid index of group.parent.groups
- read_buf(self)
- Read database file
- remove_entry(self, entry=None)
- This method can remove entries.
The v1Entry-object entry is needed.
- remove_group(self, group=None)
- This method removes a group.
The group needed to remove the group.
group must be a v1Group.
- save(self, filepath=None, password=None, keyfile=None)
- This method saves the database.
It's possible to parse a data path to an alternative file.
- unlock(self, password=None, keyfile=None, buf=None)
- Unlock the database.
masterkey is needed.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |