コード例 #1
0
    def request_action(self, action, data):
        changed = False
        recipe_before_modification = Snapshot(
            self.context, providing=providedBy(self.context))

        recipe_text = data.pop('recipe_text')
        parser = RecipeParser(recipe_text)
        recipe = parser.parse()
        if self.context.builder_recipe != recipe:
            try:
                self.error_handler(self.context.setRecipeText, recipe_text)
                changed = True
            except ErrorHandled:
                return

        distros = data.pop('distroseries')
        if distros != self.context.distroseries:
            self.context.distroseries.clear()
            for distroseries_item in distros:
                self.context.distroseries.add(distroseries_item)
            changed = True

        if self.updateContextFromData(data, notify_modified=False):
            changed = True

        if changed:
            field_names = [
                form_field.__name__ for form_field in self.form_fields]
            notify(ObjectModifiedEvent(
                self.context, recipe_before_modification, field_names))

        self.next_url = canonical_url(self.context)
コード例 #2
0
    def request_action(self, action, data):
        changed = False
        recipe_before_modification = Snapshot(self.context,
                                              providing=providedBy(
                                                  self.context))

        recipe_text = data.pop('recipe_text')
        parser = RecipeParser(recipe_text)
        recipe = parser.parse()
        if self.context.builder_recipe != recipe:
            try:
                self.error_handler(self.context.setRecipeText, recipe_text)
                changed = True
            except ErrorHandled:
                return

        distros = data.pop('distroseries')
        if distros != self.context.distroseries:
            self.context.distroseries.clear()
            for distroseries_item in distros:
                self.context.distroseries.add(distroseries_item)
            changed = True

        if self.updateContextFromData(data, notify_modified=False):
            changed = True

        if changed:
            field_names = [
                form_field.__name__ for form_field in self.form_fields
            ]
            notify(
                ObjectModifiedEvent(self.context, recipe_before_modification,
                                    field_names))

        self.next_url = canonical_url(self.context)
コード例 #3
0
 def validate(self, data):
     if data['build_daily']:
         if len(data['distroseries']) == 0:
             self.setFieldError(
                 'distroseries',
                 'You must specify at least one series for daily builds.')
     try:
         parser = RecipeParser(data['recipe_text'])
         parser.parse()
     except RecipeParseError as error:
         self.setFieldError('recipe_text', str(error))
コード例 #4
0
 def validate(self, data):
     if data['build_daily']:
         if len(data['distroseries']) == 0:
             self.setFieldError(
                 'distroseries',
                 'You must specify at least one series for daily builds.')
     try:
         parser = RecipeParser(data['recipe_text'])
         parser.parse()
     except RecipeParseError as error:
         self.setFieldError('recipe_text', str(error))
コード例 #5
0
 def getParsedRecipe(recipe_text):
     """See `IRecipeBranchSource`."""
     # We're using bzr-builder to parse the recipe text.  While the
     # formats are mostly compatible, the header line must say
     # "bzr-builder" even though git-build-recipe also supports its own
     # name there.
     recipe_text, git_substitutions = re.subn(r"^(#\s*)git-build-recipe",
                                              r"\1bzr-builder", recipe_text)
     recipe_branch_type = (RecipeBranchType.GIT
                           if git_substitutions else RecipeBranchType.BZR)
     parser = RecipeParser(recipe_text)
     recipe_branch = parser.parse(permitted_instructions=SAFE_INSTRUCTIONS)
     return recipe_branch, recipe_branch_type
コード例 #6
0
 def setManifestText(self, text):
     if text is None:
         if self.manifest is not None:
             IStore(self.manifest).remove(self.manifest)
     elif self.manifest is None:
         SourcePackageRecipeData.createManifestFromText(text, self)
     else:
         from bzrlib.plugins.builder.recipe import RecipeParser
         self.manifest.setRecipe(RecipeParser(text).parse())
コード例 #7
0
 def getParsedRecipe(recipe_text):
     parser = RecipeParser(recipe_text)
     return parser.parse(permitted_instructions=SAFE_INSTRUCTIONS)