Skip to content

Commit

Permalink
Add further database properties
Browse files Browse the repository at this point in the history
Add database name, database description and default user name property.
  • Loading branch information
janbrummer committed Apr 4, 2024
1 parent e43ca6c commit ea96525
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pykeepass/pykeepass.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,42 @@ def entries(self):
excluding history"""
return self.find_entries()

@property
def database_name(self):
"""Name of database"""
elem = self._xpath('/KeePassFile/Meta/DatabaseName', first=True)
return elem.text

@database_name.setter
def database_name(self, name):
path = '/KeePassFile/Meta/DatabaseName'
item = self._xpath(path, first=True)
item.text = str(name)

@property
def database_description(self):
"""Description of database"""
elem = self._xpath('/KeePassFile/Meta/DatabaseDescription', first=True)
return elem.text

@database_description.setter
def database_description(self, name):
path = '/KeePassFile/Meta/DatabaseDescription'
item = self._xpath(path, first=True)
item.text = str(name)

@property
def default_username(self):
"""Default Username"""
elem = self._xpath('/KeePassFile/Meta/DefaultUserName', first=True)
return elem.text

@default_username.setter
def default_username(self, name):
path = '/KeePassFile/Meta/DefaultUserName'
item = self._xpath(path, first=True)
item.text = str(name)

def xml(self):
"""Get XML part of database as string
Expand Down

0 comments on commit ea96525

Please sign in to comment.