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 <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-10-31 14:28:08 +01:00
parent 2fac017618
commit 70b7064e5c
12 changed files with 39 additions and 0 deletions

View File

@ -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 <http://www.gnu.org/licenses/>.
from __future__ import absolute_import, print_function, unicode_literals from __future__ import absolute_import, print_function, unicode_literals
del absolute_import, print_function, unicode_literals del absolute_import, print_function, unicode_literals
from gpg import util from gpg import util
util.process_constants('GPGME_', globals()) 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', __all__ = ['data', 'event', 'import', 'keylist', 'md', 'pk',
'protocol', 'sig', 'sigsum', 'status', 'validity'] 'protocol', 'sig', 'sigsum', 'status', 'validity']

View File

@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals
from gpg import util from gpg import util
util.process_constants('GPGME_DATA_ENCODING_', globals()) util.process_constants('GPGME_DATA_ENCODING_', globals())
del util

View File

@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals
from gpg import util from gpg import util
util.process_constants('GPGME_EVENT_', globals()) util.process_constants('GPGME_EVENT_', globals())
del util

View File

@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals
from gpg import util from gpg import util
util.process_constants('GPGME_IMPORT_', globals()) util.process_constants('GPGME_IMPORT_', globals())
del util

View File

@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals
from gpg import util from gpg import util
util.process_constants('GPGME_KEYLIST_MODE_', globals()) util.process_constants('GPGME_KEYLIST_MODE_', globals())
del util

View File

@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals
from gpg import util from gpg import util
util.process_constants('GPGME_MD_', globals()) util.process_constants('GPGME_MD_', globals())
del util

View File

@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals
from gpg import util from gpg import util
util.process_constants('GPGME_PK_', globals()) util.process_constants('GPGME_PK_', globals())
del util

View File

@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals
from gpg import util from gpg import util
util.process_constants('GPGME_PROTOCOL_', globals()) util.process_constants('GPGME_PROTOCOL_', globals())
del util

View File

@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals
from gpg import util from gpg import util
util.process_constants('GPGME_SIG_MODE_', globals()) util.process_constants('GPGME_SIG_MODE_', globals())
del util

View File

@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals
from gpg import util from gpg import util
util.process_constants('GPGME_SIGSUM_', globals()) util.process_constants('GPGME_SIGSUM_', globals())
del util

View File

@ -20,3 +20,4 @@ del absolute_import, print_function, unicode_literals
from gpg import util from gpg import util
util.process_constants('GPGME_VALIDITY_', globals()) util.process_constants('GPGME_VALIDITY_', globals())
del util

View File

@ -27,6 +27,7 @@ NO_ERROR = None
EOF = None EOF = None
util.process_constants('GPG_ERR_', globals()) util.process_constants('GPG_ERR_', globals())
del util
class GpgError(Exception): class GpgError(Exception):
pass pass