From 94bf13e78e65e1d1bc2e5d6b2311f9c9657bfe5f Mon Sep 17 00:00:00 2001 From: Ben McGinnes Date: Fri, 10 Aug 2018 11:25:01 +1000 Subject: PEP8 compliance and other code fixes * Ran all the .py files in src/ and below through Yapf. * Included some manual edits of core.py, this time successfully making two notorious sections a bit more pythonic than scheming. * Left the module imports as is. * This will be committed if it passes the most essential test: compiling, installing and running it. Signed-off-by: Ben McGinnes --- lang/python/src/util.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'lang/python/src/util.py') diff --git a/lang/python/src/util.py b/lang/python/src/util.py index e4fca4c1..77d14213 100644 --- a/lang/python/src/util.py +++ b/lang/python/src/util.py @@ -21,6 +21,7 @@ del absolute_import, print_function, unicode_literals import sys + 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 @@ -30,17 +31,19 @@ def process_constants(prefix, scope): """ from . import gpgme index = len(prefix) - constants = {identifier[index:]: getattr(gpgme, identifier) - for identifier in dir(gpgme) - if identifier.startswith(prefix)} + constants = { + identifier[index:]: getattr(gpgme, identifier) + for identifier in dir(gpgme) if identifier.startswith(prefix) + } scope.update(constants) return list(constants.keys()) + def percent_escape(s): - return ''.join( - '%{0:2x}'.format(ord(c)) - if c == '+' or c == '"' or c == '%' or ord(c) <= 0x20 else c - for c in s) + return ''.join('%{0:2x}'.format(ord(c)) + if c == '+' or c == '"' or c == '%' or ord(c) <= 0x20 else c + for c in s) + # Python2/3 compatibility if sys.version_info[0] == 3: -- cgit v1.2.3