diff options
| author | Ben McGinnes <[email protected]> | 2018-08-18 05:05:34 +0000 | 
|---|---|---|
| committer | Ben McGinnes <[email protected]> | 2018-08-18 05:05:34 +0000 | 
| commit | 7962cde13c5cbdc643bbde795e2c29e638dfc186 (patch) | |
| tree | d506c41a4991e64995200c0ce9b31d6b42aee5df /lang/python/src | |
| parent | Symmetric example (diff) | |
| download | gpgme-7962cde13c5cbdc643bbde795e2c29e638dfc186.tar.gz gpgme-7962cde13c5cbdc643bbde795e2c29e638dfc186.zip  | |
Python bindings src: PEP8 compliance
* import namespace clearance for src/*.py.
* Fixed a handful of is/is not None checks as well.
Diffstat (limited to 'lang/python/src')
| -rw-r--r-- | lang/python/src/__init__.py | 3 | ||||
| -rw-r--r-- | lang/python/src/callbacks.py | 7 | ||||
| -rw-r--r-- | lang/python/src/core.py | 3 | ||||
| -rw-r--r-- | lang/python/src/errors.py | 15 | ||||
| -rw-r--r-- | lang/python/src/util.py | 3 | 
5 files changed, 18 insertions, 13 deletions
diff --git a/lang/python/src/__init__.py b/lang/python/src/__init__.py index 82c1cce1..30e638c4 100644 --- a/lang/python/src/__init__.py +++ b/lang/python/src/__init__.py @@ -95,7 +95,6 @@ GPGME documentation: https://www.gnupg.org/documentation/manuals/gpgme/  """  from __future__ import absolute_import, print_function, unicode_literals -del absolute_import, print_function, unicode_literals  from . import core  from . import errors @@ -106,6 +105,8 @@ from . import version  from .core import Context  from .core import Data +del absolute_import, print_function, unicode_literals +  # Interface hygiene.  # Drop the low-level gpgme that creeps in for some reason. diff --git a/lang/python/src/callbacks.py b/lang/python/src/callbacks.py index e8a9c432..9aacf566 100644 --- a/lang/python/src/callbacks.py +++ b/lang/python/src/callbacks.py @@ -16,17 +16,18 @@  #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA  from __future__ import absolute_import, print_function, unicode_literals -del absolute_import, print_function, unicode_literals  from getpass import getpass +del absolute_import, print_function, unicode_literals +  def passphrase_stdin(hint, desc, prev_bad, hook=None):      """This is a sample callback that will read a passphrase from      the terminal.  The hook here, if present, will be used to describe      why the passphrase is needed."""      why = '' -    if hook != None: +    if hook is not None:          why = ' ' + hook      if prev_bad:          why += ' (again)' @@ -35,7 +36,7 @@ def passphrase_stdin(hint, desc, prev_bad, hook=None):  def progress_stdout(what, type, current, total, hook=None): -    print("PROGRESS UPDATE: what = %s, type = %d, current = %d, total = %d" %\ +    print("PROGRESS UPDATE: what = %s, type = %d, current = %d, total = %d" %            (what, type, current, total)) diff --git a/lang/python/src/core.py b/lang/python/src/core.py index 7858468d..d4711317 100644 --- a/lang/python/src/core.py +++ b/lang/python/src/core.py @@ -1,7 +1,6 @@  # -*- coding: utf-8 -*-  from __future__ import absolute_import, print_function, unicode_literals -del absolute_import, print_function, unicode_literals  import re  import os @@ -14,6 +13,8 @@ from . import constants  from . import errors  from . import util +del absolute_import, print_function, unicode_literals +  # Copyright (C) 2016-2018 g10 Code GmbH  # Copyright (C) 2004, 2008 Igor Belyi <[email protected]>  # Copyright (C) 2002 John Goerzen <[email protected]> diff --git a/lang/python/src/errors.py b/lang/python/src/errors.py index 45157c5e..9c7f0378 100644 --- a/lang/python/src/errors.py +++ b/lang/python/src/errors.py @@ -17,11 +17,12 @@  #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA  from __future__ import absolute_import, print_function, unicode_literals -del absolute_import, print_function, unicode_literals  from . import gpgme  from . import util +del absolute_import, print_function, unicode_literals +  # To appease static analysis tools, we define some constants here.  # They are overwritten with the proper values by process_constants.  NO_ERROR = None @@ -64,33 +65,33 @@ class GpgError(Exception):      @property      def code(self): -        if self.error == None: +        if self.error is None:              return None          return gpgme.gpgme_err_code(self.error)      @property      def code_str(self): -        if self.error == None: +        if self.error is None:              return None          return gpgme.gpgme_strerror(self.error)      @property      def source(self): -        if self.error == None: +        if self.error is None:              return None          return gpgme.gpgme_err_source(self.error)      @property      def source_str(self): -        if self.error == None: +        if self.error is None:              return None          return gpgme.gpgme_strsource(self.error)      def __str__(self):          msgs = [] -        if self.context != None: +        if self.context is not None:              msgs.append(self.context) -        if self.error != None: +        if self.error is not None:              msgs.append(self.source_str)              msgs.append(self.code_str)          return ': '.join(msgs) diff --git a/lang/python/src/util.py b/lang/python/src/util.py index 77d14213..320a823e 100644 --- a/lang/python/src/util.py +++ b/lang/python/src/util.py @@ -17,10 +17,11 @@  #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA  from __future__ import absolute_import, print_function, unicode_literals -del absolute_import, print_function, unicode_literals  import sys +del absolute_import, print_function, unicode_literals +  def process_constants(prefix, scope):      """Called by the constant modules to load up the constants from the C  | 
