in dh_virtualenv/debhelper.py [0:0]
def save_autoscripts(self):
for package, settings in self.packages.items():
autoscripts = settings.get('autoscripts')
if not autoscripts:
continue
for when, templates in autoscripts.items():
fn = "debian/%s.%s.debhelper" % (package, when)
if exists(fn):
data = open(fn, 'r').read()
else:
data = ''
new_data = ''
for tpl_name, args in templates.items():
for i in args:
# try local one first (useful while testing dh_python2)
fpath = join(dirname(__file__), '..',
"autoscripts/%s" % tpl_name)
if not exists(fpath):
fpath = "/usr/share/debhelper/autoscripts/%s" % tpl_name
tpl = open(fpath, 'r').read()
if self.options.compile_all and args:
# TODO: should args be checked to contain dir name?
tpl = tpl.replace('#PACKAGE#', '')
else:
tpl = tpl.replace('#PACKAGE#', package)
tpl = tpl.replace('#ARGS#', i)
if tpl not in data and tpl not in new_data:
new_data += "\n%s" % tpl
if new_data:
data += "\n# Automatically added by dh_python2:" +\
"%s\n# End automatically added section\n" % new_data
fp = open(fn, 'w')
fp.write(data)
fp.close()