From 70b7064e5c4f3eff9c296c00156724bc0cdaa64f Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Mon, 31 Oct 2016 14:28:08 +0100 Subject: [PATCH] python: Improve constants module. * lang/python/gpg/constants/__init__.py: Import all modules below 'constants/'. Interface hygiene: delete 'util'. * lang/python/gpg/constants/data/encoding.py: Delete 'util'. * lang/python/gpg/constants/event.py: Likewise. * lang/python/gpg/constants/import.py: Likewise. * lang/python/gpg/constants/keylist/mode.py: Likewise. * lang/python/gpg/constants/md.py: Likewise. * lang/python/gpg/constants/pk.py: Likewise. * lang/python/gpg/constants/protocol.py: Likewise. * lang/python/gpg/constants/sig/mode.py: Likewise. * lang/python/gpg/constants/sigsum.py: Likewise. * lang/python/gpg/constants/validity.py: Likewise. * lang/python/gpg/errors.py: Likewise. Signed-off-by: Justus Winter --- lang/python/gpg/constants/__init__.py | 28 ++++++++++++++++++++++ lang/python/gpg/constants/data/encoding.py | 1 + lang/python/gpg/constants/event.py | 1 + lang/python/gpg/constants/import.py | 1 + lang/python/gpg/constants/keylist/mode.py | 1 + lang/python/gpg/constants/md.py | 1 + lang/python/gpg/constants/pk.py | 1 + lang/python/gpg/constants/protocol.py | 1 + lang/python/gpg/constants/sig/mode.py | 1 + lang/python/gpg/constants/sigsum.py | 1 + lang/python/gpg/constants/validity.py | 1 + lang/python/gpg/errors.py | 1 + 12 files changed, 39 insertions(+) diff --git a/lang/python/gpg/constants/__init__.py b/lang/python/gpg/constants/__init__.py index c6fa102e..4fb3d6f9 100644 --- a/lang/python/gpg/constants/__init__.py +++ b/lang/python/gpg/constants/__init__.py @@ -1,9 +1,37 @@ +# Constants. +# +# Copyright (C) 2016 g10 Code GmbH +# +# This file is part of GPGME. +# +# GPGME is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2.1 of the +# License, or (at your option) any later version. +# +# GPGME is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General +# Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, see . from __future__ import absolute_import, print_function, unicode_literals del absolute_import, print_function, unicode_literals from gpg import util util.process_constants('GPGME_', globals()) +del util + +# For convenience, we import the modules here. +from . import data, event, keylist, md, pk +from . import protocol, sig, sigsum, status, validity + +# A complication arises because 'import' is a reserved keyword. +# Import it as 'Import' instead. +globals()['Import'] = getattr(__import__('', globals(), locals(), + [str('import')], 1), "import") __all__ = ['data', 'event', 'import', 'keylist', 'md', 'pk', 'protocol', 'sig', 'sigsum', 'status', 'validity'] diff --git a/lang/python/gpg/constants/data/encoding.py b/lang/python/gpg/constants/data/encoding.py index fc7c6b22..e76a22ee 100644 --- a/lang/python/gpg/constants/data/encoding.py +++ b/lang/python/gpg/constants/data/encoding.py @@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals from gpg import util util.process_constants('GPGME_DATA_ENCODING_', globals()) +del util diff --git a/lang/python/gpg/constants/event.py b/lang/python/gpg/constants/event.py index 11e63f09..1b14d1d1 100644 --- a/lang/python/gpg/constants/event.py +++ b/lang/python/gpg/constants/event.py @@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals from gpg import util util.process_constants('GPGME_EVENT_', globals()) +del util diff --git a/lang/python/gpg/constants/import.py b/lang/python/gpg/constants/import.py index 4a65a306..47c296cb 100644 --- a/lang/python/gpg/constants/import.py +++ b/lang/python/gpg/constants/import.py @@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals from gpg import util util.process_constants('GPGME_IMPORT_', globals()) +del util diff --git a/lang/python/gpg/constants/keylist/mode.py b/lang/python/gpg/constants/keylist/mode.py index 0939c6ca..39e1819d 100644 --- a/lang/python/gpg/constants/keylist/mode.py +++ b/lang/python/gpg/constants/keylist/mode.py @@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals from gpg import util util.process_constants('GPGME_KEYLIST_MODE_', globals()) +del util diff --git a/lang/python/gpg/constants/md.py b/lang/python/gpg/constants/md.py index 7a04849e..f3e8bbdb 100644 --- a/lang/python/gpg/constants/md.py +++ b/lang/python/gpg/constants/md.py @@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals from gpg import util util.process_constants('GPGME_MD_', globals()) +del util diff --git a/lang/python/gpg/constants/pk.py b/lang/python/gpg/constants/pk.py index b2ece88d..6bf2a215 100644 --- a/lang/python/gpg/constants/pk.py +++ b/lang/python/gpg/constants/pk.py @@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals from gpg import util util.process_constants('GPGME_PK_', globals()) +del util diff --git a/lang/python/gpg/constants/protocol.py b/lang/python/gpg/constants/protocol.py index 562042e9..d086bbde 100644 --- a/lang/python/gpg/constants/protocol.py +++ b/lang/python/gpg/constants/protocol.py @@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals from gpg import util util.process_constants('GPGME_PROTOCOL_', globals()) +del util diff --git a/lang/python/gpg/constants/sig/mode.py b/lang/python/gpg/constants/sig/mode.py index f53d7ed0..0f4f0efc 100644 --- a/lang/python/gpg/constants/sig/mode.py +++ b/lang/python/gpg/constants/sig/mode.py @@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals from gpg import util util.process_constants('GPGME_SIG_MODE_', globals()) +del util diff --git a/lang/python/gpg/constants/sigsum.py b/lang/python/gpg/constants/sigsum.py index 2a7f2c06..09ef9d78 100644 --- a/lang/python/gpg/constants/sigsum.py +++ b/lang/python/gpg/constants/sigsum.py @@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals from gpg import util util.process_constants('GPGME_SIGSUM_', globals()) +del util diff --git a/lang/python/gpg/constants/validity.py b/lang/python/gpg/constants/validity.py index da14ca42..d3c53458 100644 --- a/lang/python/gpg/constants/validity.py +++ b/lang/python/gpg/constants/validity.py @@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals from gpg import util util.process_constants('GPGME_VALIDITY_', globals()) +del util diff --git a/lang/python/gpg/errors.py b/lang/python/gpg/errors.py index 7f037f0a..1ce139e8 100644 --- a/lang/python/gpg/errors.py +++ b/lang/python/gpg/errors.py @@ -27,6 +27,7 @@ NO_ERROR = None EOF = None util.process_constants('GPG_ERR_', globals()) +del util class GpgError(Exception): pass