Allow group updates
This commit is contained in:
@ -359,16 +359,26 @@ class AdminBackend:
|
||||
self,
|
||||
group_filter: str | None = None,
|
||||
regex: bool = True,
|
||||
flat: bool = False,
|
||||
) -> ClientSecretGroupList:
|
||||
"""Get secret groups.
|
||||
|
||||
The starting group can be filtered with the group_name argument, which
|
||||
may be a regular expression.
|
||||
|
||||
Groups are returned in a tree, unless flat is True.
|
||||
"""
|
||||
all_secrets = await self.backend.get_detailed_secrets()
|
||||
secrets_mapping = {secret.name: secret for secret in all_secrets}
|
||||
with self.password_manager() as password_manager:
|
||||
all_groups = password_manager.get_secret_groups(group_filter, regex=regex)
|
||||
if flat:
|
||||
all_groups = password_manager.get_secret_group_list(
|
||||
group_filter, regex=regex
|
||||
)
|
||||
else:
|
||||
all_groups = password_manager.get_secret_groups(
|
||||
group_filter, regex=regex
|
||||
)
|
||||
ungrouped = password_manager.get_ungrouped_secrets()
|
||||
|
||||
group_result: list[ClientSecretGroup] = []
|
||||
|
||||
@ -160,6 +160,16 @@ class PasswordContext:
|
||||
secret_groups = [_kp_group_to_secret_group(group) for group in groups]
|
||||
return secret_groups
|
||||
|
||||
def get_secret_group_list(self, pattern: str | None = None, regex: bool = True) -> list[SecretGroup]:
|
||||
"""Get a flat list of groups."""
|
||||
if pattern:
|
||||
return self.get_secret_groups(pattern, regex)
|
||||
|
||||
groups = [ group for group in self.keepass.groups if not group.is_root_group ]
|
||||
secret_groups = [_kp_group_to_secret_group(group) for group in groups]
|
||||
return secret_groups
|
||||
|
||||
|
||||
def get_ungrouped_secrets(self) -> list[str]:
|
||||
"""Get secrets without groups."""
|
||||
entries: list[str] = []
|
||||
|
||||
Reference in New Issue
Block a user