[Pkg-gnupg-commit] [gpgme] 248/412: python: Drop superfluous imports and trim public interface.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Thu Sep 22 21:26:56 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gpgme.
commit 2ff58fcbd5c060dac3a7feec478819d2c5a164ec
Author: Justus Winter <justus at g10code.com>
Date: Thu Jul 28 16:29:05 2016 +0200
python: Drop superfluous imports and trim public interface.
* lang/python/pyme/__init__.py: Avoid leaking low-level 'gpgme', make
sure the main module looks nice and tidy, appease pyflakes.
* lang/python/pyme/errors.py: Appease pyflakes.
* lang/python/pyme/util.py: Avoid leaking low-level 'gpgme' into the
module namespace.
* lang/python/pyme/version.py.in: Likewise.
* lang/python/tests/t-keylist.py: Drop superfluous imports.
* lang/python/tests/t-sig-notation.py: Likewise.
* lang/python/tests/t-sign.py: Likewise.
* lang/python/tests/t-signers.py: Likewise.
Signed-off-by: Justus Winter <justus at g10code.com>
---
lang/python/pyme/__init__.py | 21 +++++++++++++++++++--
lang/python/pyme/errors.py | 3 +++
lang/python/pyme/util.py | 3 +--
lang/python/pyme/version.py.in | 3 +++
lang/python/tests/t-keylist.py | 2 --
lang/python/tests/t-sig-notation.py | 2 +-
lang/python/tests/t-sign.py | 1 -
lang/python/tests/t-signers.py | 1 -
8 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/lang/python/pyme/__init__.py b/lang/python/pyme/__init__.py
index c42f794..f9e12d0 100644
--- a/lang/python/pyme/__init__.py
+++ b/lang/python/pyme/__init__.py
@@ -99,7 +99,24 @@ GPGME documentation: https://www.gnupg.org/documentation/manuals/gpgme/
"""
-__all__ = ['core', 'errors', 'constants', 'util', 'callbacks', 'version']
-
+from . import core
+from . import errors
+from . import constants
+from . import util
+from . import callbacks
+from . import version
from .core import Context
from .core import Data
+
+# Interface hygiene.
+
+# Drop the low-level gpgme that creeps in for some reason.
+gpgme = None
+del gpgme
+
+# This is a white-list of symbols. Any other will alert pyflakes.
+_ = [Context, Data, core, errors, constants, util, callbacks, version]
+del _
+
+__all__ = ["Context", "Data",
+ "core", "errors", "constants", "util", "callbacks", "version"]
diff --git a/lang/python/pyme/errors.py b/lang/python/pyme/errors.py
index 1e6e4ab..9c58207 100644
--- a/lang/python/pyme/errors.py
+++ b/lang/python/pyme/errors.py
@@ -20,6 +20,9 @@ from . import util
util.process_constants('GPG_ERR_', globals())
+# To appease static analysis tools, we define some constants here:
+NO_ERROR = 0
+
class PymeError(Exception):
pass
diff --git a/lang/python/pyme/util.py b/lang/python/pyme/util.py
index ef0bd65..c4c9e18 100644
--- a/lang/python/pyme/util.py
+++ b/lang/python/pyme/util.py
@@ -16,8 +16,6 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from . import gpgme
-
def process_constants(prefix, scope):
"""Called by the constant modules to load up the constants from the C
library starting with PREFIX. Matching constants will be inserted
@@ -25,6 +23,7 @@ def process_constants(prefix, scope):
of inserted constants.
"""
+ from . import gpgme
index = len(prefix)
constants = {identifier[index:]: getattr(gpgme, identifier)
for identifier in dir(gpgme)
diff --git a/lang/python/pyme/version.py.in b/lang/python/pyme/version.py.in
index a8ab0ca..a40e02d 100644
--- a/lang/python/pyme/version.py.in
+++ b/lang/python/pyme/version.py.in
@@ -59,3 +59,6 @@ Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"""
+
+# Interface hygiene. Keep this at the end.
+del gpgme
diff --git a/lang/python/tests/t-keylist.py b/lang/python/tests/t-keylist.py
index 64fec27..fb59321 100755
--- a/lang/python/tests/t-keylist.py
+++ b/lang/python/tests/t-keylist.py
@@ -17,8 +17,6 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, see <http://www.gnu.org/licenses/>.
-import sys
-import pyme
from pyme import core, constants
import support
diff --git a/lang/python/tests/t-sig-notation.py b/lang/python/tests/t-sig-notation.py
index cb4a48e..0f77e37 100755
--- a/lang/python/tests/t-sig-notation.py
+++ b/lang/python/tests/t-sig-notation.py
@@ -18,7 +18,7 @@
# License along with this program; if not, see <http://www.gnu.org/licenses/>.
import os
-from pyme import core, constants, errors
+from pyme import core, constants
import support
expected_notations = {
diff --git a/lang/python/tests/t-sign.py b/lang/python/tests/t-sign.py
index 802a32d..e066a29 100755
--- a/lang/python/tests/t-sign.py
+++ b/lang/python/tests/t-sign.py
@@ -17,7 +17,6 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, see <http://www.gnu.org/licenses/>.
-import sys
import os
import pyme
from pyme import core, constants
diff --git a/lang/python/tests/t-signers.py b/lang/python/tests/t-signers.py
index 15e8011..9d2cbdc 100755
--- a/lang/python/tests/t-signers.py
+++ b/lang/python/tests/t-signers.py
@@ -17,7 +17,6 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, see <http://www.gnu.org/licenses/>.
-import sys
import pyme
from pyme import core, constants
import support
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git
More information about the Pkg-gnupg-commit
mailing list