diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-04-12 14:18:26 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-04-12 14:18:26 +0100 |
commit | f2c3c3cf2dffc3a41735efd1aaa7916d9c40a3a5 (patch) | |
tree | 8bb1b128117935a32bf0bf6d50c29a2b12974726 | |
parent | 007258866e20a058676dc6db166324f6b4af38e6 (diff) | |
download | obnam-f2c3c3cf2dffc3a41735efd1aaa7916d9c40a3a5.tar.gz |
Add list-toplevels subcommand.
-rw-r--r-- | obnamlib/plugins/encryption_plugin.py | 16 | ||||
-rwxr-xr-x | test-encrypted-repo | 3 |
2 files changed, 19 insertions, 0 deletions
diff --git a/obnamlib/plugins/encryption_plugin.py b/obnamlib/plugins/encryption_plugin.py index 6ee4f362..eee56152 100644 --- a/obnamlib/plugins/encryption_plugin.py +++ b/obnamlib/plugins/encryption_plugin.py @@ -41,6 +41,7 @@ class EncryptionPlugin(obnamlib.ObnamPlugin): self.app.register_command('client-keys', self.client_keys) self.app.register_command('list-keys', self.list_keys) + self.app.register_command('list-toplevels', self.list_toplevels) @property def keyid(self): @@ -132,6 +133,21 @@ class EncryptionPlugin(obnamlib.ObnamPlugin): for toplevel in keys[keyid]: print ' %s' % toplevel + def list_toplevels(self, args): + repo = self.app.open_repository() + toplevels = repo.fs.listdir('.') + keys = dict() + tops = dict() + for toplevel in toplevels: + userkeys = self.read_keyring(repo, toplevel) + for keyid in userkeys.keyids(): + keys[keyid] = keys.get(keyid, []) + [toplevel] + tops[toplevel] = tops.get(toplevel, []) + [keyid] + for toplevel in tops: + print 'toplevel: %s' % toplevel + for keyid in tops[toplevel]: + print ' %s' % keyid + # def add_client(self, repo, client_public_key): # self.add_to_userkeys(repo, 'metadata', client_public_key) # self.add_to_userkeys(repo, 'clientlist', client_public_key) diff --git a/test-encrypted-repo b/test-encrypted-repo index 2193bd38..618232a2 100755 --- a/test-encrypted-repo +++ b/test-encrypted-repo @@ -24,3 +24,6 @@ $cmd client-keys echo "list-keys:" $cmd list-keys + +echo "list-toplevels:" +$cmd list-toplevels |