Returns the Recipe with the given name, if it exists.
(cls, name, ctx)
| 724 | |
| 725 | @classmethod |
| 726 | def get_recipe(cls, name, ctx): |
| 727 | '''Returns the Recipe with the given name, if it exists.''' |
| 728 | name = name.lower() |
| 729 | if not hasattr(cls, "recipes"): |
| 730 | cls.recipes = {} |
| 731 | if name in cls.recipes: |
| 732 | return cls.recipes[name] |
| 733 | |
| 734 | recipe_file = None |
| 735 | for recipes_dir in cls.recipe_dirs(ctx): |
| 736 | if not exists(recipes_dir): |
| 737 | continue |
| 738 | # Find matching folder (may differ in case): |
| 739 | for subfolder in listdir(recipes_dir): |
| 740 | if subfolder.lower() == name: |
| 741 | recipe_file = join(recipes_dir, subfolder, '__init__.py') |
| 742 | if exists(recipe_file): |
| 743 | name = subfolder # adapt to actual spelling |
| 744 | break |
| 745 | recipe_file = None |
| 746 | if recipe_file is not None: |
| 747 | break |
| 748 | |
| 749 | else: |
| 750 | raise ValueError('Recipe does not exist: {}'.format(name)) |
| 751 | |
| 752 | mod = import_recipe('pythonforandroid.recipes.{}'.format(name), recipe_file) |
| 753 | if len(logger.handlers) > 1: |
| 754 | logger.removeHandler(logger.handlers[1]) |
| 755 | recipe = mod.recipe |
| 756 | recipe.ctx = ctx |
| 757 | cls.recipes[name.lower()] = recipe |
| 758 | return recipe |
| 759 | |
| 760 | |
| 761 | class IncludedFilesBehaviour(object): |