Skip to content

Commit

Permalink
Merge pull request #54 from pelson/moving_ahead
Browse files Browse the repository at this point in the history
Support recipe linting of Jinja based recipes
  • Loading branch information
pelson committed Feb 9, 2016
2 parents 9fee7d8 + 6d8e2bc commit a96146c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion conda_smithy/lint_recipe.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import os

import jinja2
import ruamel.yaml


EXPECTED_SECTION_ORDER = ['package', 'source', 'build', 'requirements', 'test', 'app', 'about', 'extra']


class NullUndefined(jinja2.Undefined):
def __unicode__(self):
return unicode(self._undefined_name)


def lintify(meta):
lints = []

Expand Down Expand Up @@ -40,7 +46,11 @@ def main(recipe_dir):
recipe_meta = os.path.join(recipe_dir, 'meta.yaml')
if not os.path.exists(recipe_dir):
raise IOError('Feedstock has no recipe/meta.yaml.')

env = jinja2.Environment(undefined=NullUndefined)

with open(recipe_meta, 'r') as fh:
meta = ruamel.yaml.load(fh, ruamel.yaml.RoundTripLoader)
content = env.from_string(''.join(fh)).render()
meta = ruamel.yaml.load(content, ruamel.yaml.RoundTripLoader)
results = lintify(meta)
return results

0 comments on commit a96146c

Please sign in to comment.