File: fix-cheetah-build-str.py

package info (click to toggle)
xmds2 3.0.0+dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 51,956 kB
  • sloc: python: 64,216; cpp: 3,929; ansic: 1,463; makefile: 115; sh: 54
file content (31 lines) | stat: -rw-r--r-- 1,187 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
### This script walks through all *.py that are included in the binary
### package and replaces the build-specify timestamp and build path
### generated by Cheetah.  This makes the building of the package
### reproducible.  This script is intended to be called in the
### override_dh_auto_install rule.

import os
import re
import sys
import time
import fnmatch
import fileinput
import debian.changelog as dch
from dateutil import parser

ch = dch.Changelog (open ('debian/changelog', 'r'))
dt = ch [0].date
ts = time.mktime (parser.parse (dt).timetuple ())

for dName, sdName, fList in os.walk ('debian/xmds2'):
    for fileName in fList:
        if fnmatch.fnmatch (fileName, '*.py'):
            fname = os.path.join (dName, fileName)
            for line in fileinput.input (fname, inplace = True):
                outline = line
                if re.match ("^__CHEETAH_srcLastModified__ = .*$", line):
                    outline = "__CHEETAH_srcLastModified__ = '%s'\n" % dt
                m = re.match ("^__CHEETAH_src__ = '.*/(.*)'$", line)
                if m:
                    outline = "__CHEETAH_src__ = '%s'\n" % m.group (1)
                sys.stdout.write (outline)