Skip to content

Commit

Permalink
docs: add docstrings to reindex and index
Browse files Browse the repository at this point in the history
  • Loading branch information
pwall2222 committed Nov 10, 2023
1 parent 97095af commit b400b62
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pykeepass/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,19 @@ def _get_string_field_keys(self, exclude_reserved=False):

@property
def index(self):
"""int: get index of a entry within a group"""
group = self.group._element
children = group.getchildren()
first_index = self.group._first_entry
index = children.index(self._element)
return index - first_index

def reindex(self, new_index):
group = self.group._element
first_index = self.group._first_entry
group.remove(self._element)
group.insert(new_index+first_index, self._element)
"""Move entry to a new index within a group
Args:
new_index (int): new index for the entry starting at 0
"""

@property
def attachments(self):
Expand Down

0 comments on commit b400b62

Please sign in to comment.