Skip to content

Commit

Permalink
Handled Jinja based recipes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pelson committed Feb 9, 2016
1 parent 9fee7d8 commit 6d8e2bc
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 6d8e2bc

Please sign in to comment.