Mercurial > pidgin
diff src/dbus-analyze-types.py @ 11331:64fadbf3810f
[gaim-migrate @ 13544]
General polishing of DBus code, improving examples, removing obsolete files.
committer: Tailor Script <tailor@pidgin.im>
author | Piotr Zielinski <zielaj> |
---|---|
date | Wed, 24 Aug 2005 02:34:40 +0000 |
parents | ebb02ea3c789 |
children |
line wrap: on
line diff
--- a/src/dbus-analyze-types.py Tue Aug 23 20:51:13 2005 +0000 +++ b/src/dbus-analyze-types.py Wed Aug 24 02:34:40 2005 +0000 @@ -18,45 +18,54 @@ import re import sys -keyword = "struct" -pattern = "%s" +options = {} + +def toprint(match, line): + if verbatim: + return line + else: + return pattern % match for arg in sys.argv[1:]: if arg[0:2] == "--": mylist = arg[2:].split("=",1) command = mylist[0] if len(mylist) > 1: - value = mylist[1] + options[command] = mylist[1] else: - value = None - - if command == "pattern": - pattern = value - if command == "keyword": - keyword = value - + options[command] = None + +keyword = options.get("keyword", "struct") +pattern = options.get("pattern", "%s") +verbatim = options.has_key("verbatim") structregexp1 = re.compile(r"^(typedef\s+)?%s\s+\w+\s+(\w+)\s*;" % keyword) structregexp2 = re.compile(r"^(typedef\s+)?%s" % keyword) structregexp3 = re.compile(r"^}\s+(\w+)\s*;") +print "/* Generated by %s. Do not edit! */" % sys.argv[0] + myinput = iter(sys.stdin) for line in myinput: match = structregexp1.match(line) if match is not None: - print pattern % match.group(2) + print toprint(match.group(2), line) continue match = structregexp2.match(line) if match is not None: while True: + if verbatim: + print line.rstrip() line = myinput.next() match = structregexp3.match(line) if match is not None: - print pattern % match.group(1) + print toprint(match.group(1), line) break if line[0] not in [" ", "\t", "{", "\n"]: + if verbatim: + print line break