Back to index

obnam  1.1
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
obnamlib.encryption.Keyring Class Reference
Inheritance diagram for obnamlib.encryption.Keyring:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def keyids
def __str__
def __contains__
def add
def remove
def gpg

Private Member Functions

def _setup
def _cleanup
def _keyring
def _real_keyids
def _reread_keyring

Private Attributes

 _encoded
 _gpghome
 _keyids

Static Private Attributes

string _keyring_name = 'pubring.gpg'

Detailed Description

A simplistic representation of GnuPG keyrings.

Just enough functionality for obnam's purposes.

Definition at line 138 of file encryption.py.


Constructor & Destructor Documentation

def obnamlib.encryption.Keyring.__init__ (   self,
  encoded = '' 
)

Definition at line 148 of file encryption.py.

00148 
00149     def __init__(self, encoded=''):
00150         self._encoded = encoded
00151         self._gpghome = None
00152         self._keyids = None
        

Member Function Documentation

def obnamlib.encryption.Keyring.__contains__ (   self,
  keyid 
)

Definition at line 185 of file encryption.py.

00185 
00186     def __contains__(self, keyid):
00187         return keyid in self.keyids()
        

Here is the call graph for this function:

Definition at line 182 of file encryption.py.

00182 
00183     def __str__(self):
00184         return self._encoded
        
def obnamlib.encryption.Keyring._cleanup (   self) [private]

Definition at line 159 of file encryption.py.

00159 
00160     def _cleanup(self):
00161         shutil.rmtree(self._gpghome)
00162         self._gpghome = None
        

Here is the caller graph for this function:

def obnamlib.encryption.Keyring._keyring (   self) [private]

Definition at line 164 of file encryption.py.

00164 
00165     def _keyring(self):
00166         return os.path.join(self._gpghome, self._keyring_name)
        

Here is the caller graph for this function:

def obnamlib.encryption.Keyring._real_keyids (   self) [private]

Reimplemented in obnamlib.encryption.SecretKeyring.

Definition at line 167 of file encryption.py.

00167 
00168     def _real_keyids(self):
00169         output = self.gpg(False, ['--list-keys', '--with-colons'])
00170 
00171         keyids = []
00172         for line in output.splitlines():
00173             fields = line.split(':')
00174             if len(fields) >= 5 and fields[0] == 'pub':
00175                 keyids.append(fields[4])
00176         return keyids
        

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 188 of file encryption.py.

00188 
00189     def _reread_keyring(self):
00190         f = open(self._keyring, 'rb')
00191         self._encoded = f.read()
00192         f.close()
00193         self._keyids = None
        

Here is the call graph for this function:

Here is the caller graph for this function:

def obnamlib.encryption.Keyring._setup (   self) [private]

Definition at line 153 of file encryption.py.

00153 
00154     def _setup(self):
00155         self._gpghome = tempfile.mkdtemp()
00156         f = open(self._keyring, 'wb')
00157         f.write(self._encoded)
00158         f.close()
        

Here is the call graph for this function:

Here is the caller graph for this function:

def obnamlib.encryption.Keyring.add (   self,
  key 
)

Definition at line 194 of file encryption.py.

00194 
00195     def add(self, key):
00196         self.gpg(True, ['--import'], stdin=key)
        

Here is the call graph for this function:

def obnamlib.encryption.Keyring.gpg (   self,
  reread,
  args,
  kwargs 
)

Definition at line 200 of file encryption.py.

00200 
00201     def gpg(self, reread, *args, **kwargs):
00202         self._setup()
00203         kwargs['gpghome'] = self._gpghome
00204         try:
00205             result = _gpg(*args, **kwargs)
00206         except BaseException: # pragma: no cover
00207             self._cleanup()
00208             raise
00209         else:
00210             if reread:
00211                 self._reread_keyring()
00212             self._cleanup()
00213             return result
00214 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 177 of file encryption.py.

00177 
00178     def keyids(self):
00179         if self._keyids is None:
00180             self._keyids = self._real_keyids()
00181         return self._keyids
        

Here is the call graph for this function:

Here is the caller graph for this function:

def obnamlib.encryption.Keyring.remove (   self,
  keyid 
)

Definition at line 197 of file encryption.py.

00197 
00198     def remove(self, keyid):
00199         self.gpg(True, ['--delete-key', '--yes', keyid])

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 149 of file encryption.py.

Definition at line 150 of file encryption.py.

Definition at line 151 of file encryption.py.

string obnamlib.encryption.Keyring._keyring_name = 'pubring.gpg' [static, private]

Reimplemented in obnamlib.encryption.SecretKeyring.

Definition at line 146 of file encryption.py.


The documentation for this class was generated from the following file: