aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/src/util.py
diff options
context:
space:
mode:
authorBen McGinnes <[email protected]>2018-08-10 01:25:01 +0000
committerBen McGinnes <[email protected]>2018-08-10 01:25:01 +0000
commit94bf13e78e65e1d1bc2e5d6b2311f9c9657bfe5f (patch)
treeea23101d276096ece7c4eb656fe1c70611953c6d /lang/python/src/util.py
parentLink fixes (diff)
downloadgpgme-94bf13e78e65e1d1bc2e5d6b2311f9c9657bfe5f.tar.gz
gpgme-94bf13e78e65e1d1bc2e5d6b2311f9c9657bfe5f.zip
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 <[email protected]>
Diffstat (limited to '')
-rw-r--r--lang/python/src/util.py17
1 files changed, 10 insertions, 7 deletions
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: