aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/gpgme-h-clean.py
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-07-11 14:38:37 +0000
committerJustus Winter <[email protected]>2016-07-11 16:09:54 +0000
commit007382ce94a6318557370c440f7d609a030a119e (patch)
tree45875e9d7566290ef77c086b513338a9458624ca /lang/python/gpgme-h-clean.py
parentpython: Do not depend on access to internal data structures. (diff)
downloadgpgme-007382ce94a6318557370c440f7d609a030a119e.tar.gz
gpgme-007382ce94a6318557370c440f7d609a030a119e.zip
python: Enable out-of-tree build of pyme bindings.
* lang/python/MANIFEST.in: Update manifest template. * lang/python/Makefile.am: Copy more files, move generation of files to Python build script, add 'sdist' target to build a Python source distribution. * lang/python/gpgme-h-clean.py: Add code to build 'errors.i'. * lang/python/setup.py.in: Generate files, enable out-of-tree builds. Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to '')
-rwxr-xr-xlang/python/gpgme-h-clean.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/lang/python/gpgme-h-clean.py b/lang/python/gpgme-h-clean.py
index b7052ff6..b29b2e15 100755
--- a/lang/python/gpgme-h-clean.py
+++ b/lang/python/gpgme-h-clean.py
@@ -19,8 +19,8 @@
import sys, re
-if len(sys.argv) < 2:
- sys.stderr.write("Usage: %s gpgme.h\n" % sys.argv[0])
+if len(sys.argv) != 2:
+ sys.stderr.write("Usage: %s path/to/[gpgme|gpg-error].h\n" % sys.argv[0])
sys.exit(1)
deprec_func = re.compile(r'^(.*typedef.*|.*\(.*\)|[^#]+\s+.+)'
@@ -28,7 +28,7 @@ deprec_func = re.compile(r'^(.*typedef.*|.*\(.*\)|[^#]+\s+.+)'
re.S)
line_break = re.compile(';|\\$|\\x0c|^\s*#|{');
-try:
+if 'gpgme.h' in sys.argv[1]:
gpgme = open(sys.argv[1])
tmp = gpgme.readline()
text = ''
@@ -41,6 +41,10 @@ try:
tmp = gpgme.readline()
sys.stdout.write(text)
gpgme.close()
-except IOError as errmsg:
- sys.stderr.write("%s: %s\n" % (sys.argv[0], errmsg))
- sys.exit(1)
+else:
+ filter_re = re.compile(r'GPG_ERR_[^ ]* =')
+ rewrite_re = re.compile(r' *(.*) = .*')
+ for line in open(sys.argv[1]):
+ if not filter_re.search(line):
+ continue
+ print(rewrite_re.sub(r'%constant long \1 = \1;', line.strip()))