~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/gpg.py

(jelmer) Switch the commit code over to use config stacks. (Bazaar
 Developers)

Show diffs side-by-side

added added

removed removed

Lines of Context:
159
159
 
160
160
    acceptable_keys = None
161
161
 
 
162
    def __init__(self, config_stack):
 
163
        self._config_stack = config_stack
 
164
        try:
 
165
            import gpgme
 
166
            self.context = gpgme.Context()
 
167
        except ImportError, error:
 
168
            pass # can't use verify()
 
169
 
162
170
    @staticmethod
163
171
    def verify_signatures_available():
164
172
        """
173
181
            return False
174
182
 
175
183
    def _command_line(self):
176
 
        
177
 
        return [self._config.gpg_signing_command(), '--clearsign', '-u',
178
 
                                                self._config.gpg_signing_key()]
179
 
 
180
 
    def __init__(self, config):
181
 
        self._config = config
182
 
        try:
183
 
            import gpgme
184
 
            self.context = gpgme.Context()
185
 
        except ImportError, error:
186
 
            pass # can't use verify()
 
184
        return [self._config_stack.get('gpg_signing_command'), '--clearsign',
 
185
                '-u', self._config_stack.get('gpg_signing_key')]
187
186
 
188
187
    def sign(self, content):
189
188
        if isinstance(content, unicode):
301
300
                                                 "verification result")
302
301
 
303
302
    def set_acceptable_keys(self, command_line_input):
304
 
        """sets the acceptable keys for verifying with this GPGStrategy
 
303
        """Set the acceptable keys for verifying with this GPGStrategy.
305
304
        
306
305
        :param command_line_input: comma separated list of patterns from
307
306
                                command line
308
307
        :return: nothing
309
308
        """
310
309
        key_patterns = None
311
 
        acceptable_keys_config = self._config.acceptable_keys()
 
310
        acceptable_keys_config = self._config_stack.get('acceptable_keys')
312
311
        try:
313
312
            if isinstance(acceptable_keys_config, unicode):
314
313
                acceptable_keys_config = str(acceptable_keys_config)