~mitya57/ubuntu/raring/python-defaults/resync

« back to all changes in this revision

Viewing changes to debpython/pydist.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2011-09-27 18:21:42 UTC
  • mfrom: (10.2.26 experimental)
  • Revision ID: package-import@ubuntu.com-20110927182142-8ssgwxgvtfhv9fnn
Tags: 2.7.2-7
* Adjust version numbers for upload to unstable.
* python: Break update-manager (<= 0.200.5-1).

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
    ''', re.VERBOSE)
58
58
 
59
59
 
60
 
def validate(fpath, exit_on_error=False):
 
60
def validate(fpath):
61
61
    """Check if pydist file looks good."""
62
62
    with open(fpath) as fp:
63
63
        for line in fp:
67
67
            if not PYDIST_RE.match(line):
68
68
                log.error('invalid pydist data in file %s: %s', \
69
69
                          fpath.rsplit('/', 1)[-1], line)
70
 
                if exit_on_error:
71
 
                    exit(3)
72
70
                return False
73
71
    return True
74
72
 
95
93
                    continue
96
94
                dist = PYDIST_RE.search(line)
97
95
                if not dist:
98
 
                    log.error('%s file has a broken line: %s', fpath, line)
99
 
                    exit(9)
 
96
                    raise Exception('invalid pydist line: %s (in %s)' % (line, fpath))
100
97
                dist = dist.groupdict()
101
98
                name = safe_name(dist['name'])
102
99
                dist['versions'] = get_requested_versions(dist['vrange'])
122
119
    data = load()
123
120
    req_dict = REQUIRES_RE.match(req)
124
121
    if not req_dict:
125
 
        log.error('requirement is not valid: %s', req)
126
122
        log.info('please ask dh_python2 author to fix REQUIRES_RE '
127
123
                 'or your upstream author to fix requires.txt')
128
 
        exit(8)
 
124
        raise Exception('requirement is not valid: %s' % req)
129
125
    req_dict = req_dict.groupdict()
130
126
    name = req_dict['name']
131
127
    details = data.get(name.lower())
174
170
 
175
171
    # fall back to python-distname
176
172
    pname = sensible_pname(name)
177
 
    log.warn('Cannot find package that provides %s. '
 
173
    log.warn('Cannot find installed package that provides %s. '
178
174
             'Using %s as package name. Please add "%s correct_package_name" '
179
 
             'line to debian/pydist-overrides to override it if needed.',
 
175
             'line to debian/pydist-overrides to override it if this is incorrect.',
180
176
             name, pname, safe_name(name))
181
177
    return pname
182
178