Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pykeepass/baseelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ def uuid(self, uuid):

@property
def icon(self):
return self._get_subelement_text('IconID')
"""`str`: get or set entry icon. See `icons`"""
value = self._get_subelement_text('IconID')
if not int(value):
uuid = self._get_subelement_text('CustomIconUUID')
value = uuid if uuid is not None else value
return value

@icon.setter
def icon(self, value):
Expand Down
7 changes: 6 additions & 1 deletion pykeepass/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'URL',
'Tags',
'IconID',
'CustomIconUUID',
'Times',
'History',
'Notes',
Expand Down Expand Up @@ -238,7 +239,11 @@ def notes(self, value):
@property
def icon(self):
"""`str`: get or set entry icon. See `icons`"""
return self._get_subelement_text('IconID')
value = self._get_subelement_text('IconID')
if not int(value):
uuid = self._get_subelement_text('CustomIconUUID')
value = uuid if uuid is not None else value
return value

@icon.setter
def icon(self, value):
Expand Down
12 changes: 12 additions & 0 deletions pykeepass/pykeepass.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,18 @@ def delete_binary(self, id):
for reference in binaries_gt:
reference.id = reference.id - 1

@property
def customIcons(self):
"""`dictionary` of `uuid(str):png(bytes)`: all attached custom icons in database."""
icons = {}
counter = 0
for elem in self._xpath('/KeePassFile/Meta/CustomIcons/Icon'):
if elem.text is not None:
counter+=1
else:
icons[elem.find('UUID').text] = base64.b64decode(elem.find('Data').text)
return icons

# ---------- Misc ----------

def deref(self, value):
Expand Down