From 9d9956b25bf2c4e8463de4d502dd1e103b68f017 Mon Sep 17 00:00:00 2001 From: Frederic Peters Date: Tue, 29 Apr 2008 12:00:40 +0000 Subject: [project @ fpeters@0d.be-20071004185258-quqzvq2tgmbt8u1j] initial work, extracting constants out of source tree Original author: Frederic Peters Date: 2007-10-04 20:52:58.486000+02:00 --- bindings/t.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 bindings/t.py (limited to 'bindings') diff --git a/bindings/t.py b/bindings/t.py new file mode 100644 index 00000000..3ba0235f --- /dev/null +++ b/bindings/t.py @@ -0,0 +1,49 @@ +#! /usr/bin/env python + +import os +import re + +constants = [] + +def parse(header_file): + in_comment = False + + content = file(header_file).read().replace('\\\n', ' ') + for line in content.splitlines(): + if in_comment: + if '*/' in line: + in_comment = False + continue + + if '/*' in line and not '*/' in line: + continue + + if line.startswith('#define'): + m = re.match(r'#define\s+([a-zA-Z0-9_]+)\s+[-\w"]', line) + if not m: + continue + constant = m.group(1) + if constant[0] == '_': + # ignore private constants + continue + constants.append(constant) + + +for base, dirnames, filenames in os.walk('../lasso/'): + if base.endswith('/.svn'): + # ignore svn directories + continue + if not 'Makefile.am' in filenames: + # not a source dir + continue + makefile_am = open(os.path.join(base, 'Makefile.am')).read() + filenames = [x for x in filenames if x.endswith('.h') if x in makefile_am] + for filename in filenames: + if filename == 'lasso_config.h': + continue + parse(os.path.join(base, filename)) + + +import pprint +pprint.pprint(constants) + -- cgit