~click-hackers/click/trunk

« back to all changes in this revision

Viewing changes to click/build.py

  • Committer: Colin Watson
  • Date: 2014-05-08 13:06:40 UTC
  • mfrom: (418.2.2 mvo)
  • Revision ID: cjwatson@canonical.com-20140508130640-iw0q2r0h14brxbt9
mergeĀ lp:~mvo/click/multiple-frameworks

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
from click.preinst import static_preinst
51
51
from click.versions import spec_version
52
52
 
 
53
from click.framework import (
 
54
    validate_framework,
 
55
    ClickFrameworkInvalid,
 
56
)
 
57
 
53
58
 
54
59
@contextlib.contextmanager
55
60
def make_temp_dir():
196
201
            package.add_file("control.tar.gz", control_tar_path)
197
202
            package.add_file("data.tar.gz", data_tar_path)
198
203
 
199
 
    def _validate_framework(self, framework):
 
204
    def _validate_framework(self, framework_string):
200
205
        """Apply policy checks to framework declarations."""
201
206
        try:
202
 
            apt_pkg
203
 
        except NameError:
204
 
            return
205
 
 
206
 
        try:
207
 
            parsed_framework = apt_pkg.parse_depends(framework)
208
 
        except ValueError:
209
 
            raise ClickBuildError('Could not parse framework "%s"' % framework)
210
 
        if len(parsed_framework) > 1:
211
 
            raise ClickBuildError(
212
 
                'Multiple dependencies in framework "%s" not yet allowed' %
213
 
                framework)
214
 
        for or_dep in parsed_framework:
215
 
            if len(or_dep) > 1:
216
 
                raise ClickBuildError(
217
 
                    'Alternative dependencies in framework "%s" not yet '
218
 
                    'allowed' % framework)
219
 
            if or_dep[0][1] or or_dep[0][2]:
220
 
                raise ClickBuildError(
221
 
                    'Version relationship in framework "%s" not yet allowed' %
222
 
                    framework)
 
207
            validate_framework(
 
208
                framework_string, ignore_missing_frameworks=True)
 
209
        except ClickFrameworkInvalid as e:
 
210
            raise ClickBuildError(str(e))
223
211
 
224
212
    def build(self, dest_dir, manifest_path="manifest.json"):
225
213
        with make_temp_dir() as temp_dir: