~ubuntu-app-review-contributors/arb-lint/trunk

« back to all changes in this revision

Viewing changes to lint/sourcepackage.py

  • Committer: Daniel Holbach
  • Date: 2012-06-29 10:26:20 UTC
  • Revision ID: daniel.holbach@canonical.com-20120629102620-rk6rd7c32vbib7qd
check if debian/control exists, test for python-{support,central}

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
from . depends import provides, requires
4
4
from . output import error, warning
 
5
import checks
5
6
 
6
7
class SourcePackage(object):
7
8
    package_name = None
9
10
    is_lens = False
10
11
    is_distutils = False
11
12
    has_copyright = False
 
13
    has_debian_control = False
12
14
 
13
15
    @provides(['cwd', 'debian_dir'])
14
16
    def __init__(self):
74
76
    @requires('debian_dir')
75
77
    def test_has_copyright(self):
76
78
        copyright_file = os.path.join(self.debian_dir, "copyright")
77
 
        if not os.path.exists(copyright_file) or \
78
 
           len(open(copyright_file, "r").read()) == 0:
 
79
        if checks.file_is_missing_or_empty(copyright_file):
79
80
            error("debian/copyright is missing or empty. Please have a look "
80
81
                  "at http://dep.debian.net/deps/dep5/ to find out how to fix "
81
82
                  "this.")
95
96
                    "to review "
96
97
                    "http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/"
97
98
                    "to find out how to accomplish it.")
 
99
 
 
100
    @provides('has_debian_control')
 
101
    @requires('debian_dir')
 
102
    def test_has_debian_control(self):
 
103
        control_file = os.path.join(self.debian_dir, "control")
 
104
        if checks.file_is_missing_or_empty(control_file):
 
105
            error("debian/control seems to be missing or empty.")
 
106
        else:
 
107
            self.has_debian_control = True
 
108
 
 
109
    @requires('has_debian_control')
 
110
    def test_uses_deprecated_python_installation(self):
 
111
        control_file = os.path.join(self.debian_dir, "control")
 
112
        f = open(control_file, "r")
 
113
        contents = f.read()
 
114
        f.close()
 
115
        if 'python-support' in contents or \
 
116
           'python-central' in contents:
 
117
            warning("This package uses a deprecated python installation "
 
118
                    "tool. You might want to have a look at "
 
119
                    "http://wiki.debian.org/Python/TransitionToDHPython2 "
 
120
                    "to find out how to transition to dh_python2.")
 
121