diff options
author | Jacek Konieczny <jajcus@jajcus.net> | 2004-10-26 01:18:22 +0400 |
---|---|---|
committer | Jacek Konieczny <jajcus@jajcus.net> | 2004-10-26 01:18:22 +0400 |
commit | 41f3fb7bc3b4624e3bcd6fb90f91f32040986afb (patch) | |
tree | 4019d9f2235c778514ce3a3f87769bc655146cb6 /utils | |
parent | d5d90a380b7ccf1334e67387f4a961fd8027db6e (diff) |
- directory cleanup
Diffstat (limited to 'utils')
-rw-r--r-- | utils/migrate-0_5-0_6.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/utils/migrate-0_5-0_6.py b/utils/migrate-0_5-0_6.py new file mode 100644 index 0000000..6feaf18 --- /dev/null +++ b/utils/migrate-0_5-0_6.py @@ -0,0 +1,48 @@ +#!/usr/bin/python + +import sys +import re +import os + +args=sys.argv[1:] +if not args or "-h" in args or "--help" in args: + print "PyXMPP 0.5 to 0.6 code updater." + print "Usage:" + print " %s file..." % (sys.argv[0],) + print + print "This script will try to update your code for the recent changes" + print "in the PyXMPP package. But this updates are just simple regexp" + print "substitutions which may _break_ your code. Always check the result." + sys.exit(0) + + +in_par=r"(?:\([^)]*\)|[^()])" + + +updates=[ + (r"(\b(?:Muc)?(?:Stanza|Message|Iq|Presence)\("+in_par+r"*)\bfr=("+in_par+r"+\))",r"\1from_jid=\2"), + (r"(\b(?:Muc)?(?:Stanza|Message|Iq|Presence)\("+in_par+r"*)\bto=("+in_par+r"+\))",r"\1to_jid=\2"), + (r"(\b(?:Muc)?(?:Stanza|Message|Iq|Presence)\("+in_par+r"*)\btype?=("+in_par+r"+\))",r"\1stanza_type=\2"), + (r"(\b(?:Muc)?(?:Stanza|Message|Iq|Presence)\("+in_par+r"*)\bs?id=("+in_par+r"+\))",r"\1stanza_id=\2"), + ] + +updates=[(re.compile(u_re,re.MULTILINE|re.DOTALL),u_repl) + for u_re,u_repl in updates] + +for fn in args: + print fn+":", + orig_code=file(fn).read() + changes_made=0 + code=orig_code + for u_re,u_repl in updates: + (code,cm)=u_re.subn(u_repl,code) + changes_made+=cm + if changes_made: + print changes_made,"changes" + os.rename(fn,fn+".bak") + file(fn,"w").write(code) + else: + print "no changes" + + +# vi: sts=4 et sw=4 |