File: dh_python2.py

package info (click to toggle)
python-defaults 2.7.16-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 856 kB
  • sloc: python: 2,342; makefile: 564; sh: 203; perl: 7
file content (36 lines) | stat: -rwxr-xr-x 1,056 bytes parent folder | download | duplicates (3)
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
32
33
34
35
36
#! /usr/bin/python

from os.path import exists
from subprocess import call
from sys import argv
from re import compile

OLD = '/usr/share/python/dh_python2'
NEW = '/usr/share/dh-python/dh_python2'
has_dhpython = compile(r'(^|:|\s|,)dh-python($|\s|,|\()').search

binary = OLD
if exists(NEW) and exists('debian/control'):
    with open('debian/control', 'r') as fp:
        inside = False
        for line in fp:
            if not line:
                break
            line_lower = line.lower()
            if inside:
                if line.startswith((' ', "\t")):
                    if has_dhpython(line):
                        binary = NEW
                        break
                    continue
                elif line.startswith('#'):
                    continue
                inside = False
            if line_lower.startswith(('build-depends:', 'build-depends-indep:')):
                if has_dhpython(line):
                    binary = NEW
                    break
                inside = True

argv[0] = binary
exit(call(argv))