contrib/tmplrewrite.py
author Jim Hague <jim.hague@acm.org>
Thu, 01 Mar 2012 15:27:24 +0000
changeset 16223 ac4fd3238ead
parent 8432 94ef2c8ce683
permissions -rwxr-xr-x
bugzilla: allow change comment to mark bugs fixed Add a second regular expression used when scanning change comments. Bugs matched by this new regular expression have the bug comments and optionally hours updated as with the first regular expression, but they are also marked as fixed. The bug status and resolution to set to mark a bug as fixed can be configured. By default status is set to RESOLVED and resolution to FIXED, the default Bugzilla settings. For example, a change comment containing 'Fixes 1234 h1.5' will be added to bug 1234, the bug will have its working time increased by 1.65 hours, and the bug will be marked RESOLVED/FIXED. Change comments may contain both bug update and fix instructions. If the same bug ID occurs in both, the last instruction found takes precedence. The patch adds new bug states 'bug_status' and 'resolution' and actions to update them to the XMLRPC and XMLRPC/email access methods. XMLRPC does not support marking bugs as fixed when used with Bugzilla versions prior to 4.0. When used with an earlier Bugzilla version, a warning is issued and only comment and hours updated.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8432
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     1
#!/usr/bin/python
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     2
import sys, os, re
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     3
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     4
IGNORE = ['.css', '.py']
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     5
oldre = re.compile('#([\w\|%]+)#')
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     6
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     7
def rewrite(fn):
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     8
    f = open(fn)
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     9
    new = open(fn + '.new', 'wb')
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    10
    for ln in f:
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    11
        new.write(oldre.sub('{\\1}', ln))
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    12
    new.close()
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    13
    f.close()
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    14
    os.rename(new.name, f.name)
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    15
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    16
if __name__ == '__main__':
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    17
    if len(sys.argv) < 2:
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    18
        print 'usage: python tmplrewrite.py [file [file [file]]]'
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    19
    for fn in sys.argv[1:]:
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    20
        if os.path.splitext(fn) in IGNORE:
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    21
            continue
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    22
        print 'rewriting %s...' % fn
94ef2c8ce683 contrib: add tmplrewrite.py script to help rewrite old templater syntax
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    23
        rewrite(fn)