# Path: dftimewolf/lib/errors.py
# class DFTimewolfError(Exception):
# class BadConfigurationError(DFTimewolfError):
# class RecipeParseError(DFTimewolfError):
# class CommandLineParseError(DFTimewolfError):
# class CriticalError(DFTimewolfError):
#   def __init__(self,
#                message: Optional[str]=None,
#                name: Optional[str]=None,
#                stacktrace: Optional[str]=None,
#                critical: bool=False,
#                unexpected: bool=False) -> None:
# 
# Path: dftimewolf/lib/resources.py
# class Recipe(object):
#   def __init__(self,
#                description: str,
#                contents: Dict[str, Any],
#                args: List[Tuple[str, str, Any]]) -> None:
#   def GetHelpString(self) -> str:
# 
# Path: dftimewolf/lib/resources.py
# class Recipe(object):
#   """Recipe.
# 
#   Attributes:
#     args (list[tuple[str, str, object]]): command line arguments of
#         the recipe.
#     contents (dict[str, object]): recipe contents.
#     description (str): description.
#     name (str): name that identifies the recipe.
#   """
# 
#   def __init__(self,
#                description: str,
#                contents: Dict[str, Any],
#                args: List[Tuple[str, str, Any]]) -> None:
#     """Initializes a recipe.
# 
#     Args:
#       description (str): description.
#       contents (dict[str, object]): recipe contents.
#       args (list[tuple[str, str, object]]): command line arguments of
#           the recipe.
#     """
#     super(Recipe, self).__init__()
#     self.args = args
#     self.contents = contents
#     self.name = contents['name']  # type: str
#     self.description = description
# 
#   def GetHelpString(self) -> str:
#     """Generates a description for argparse help.
# 
#     Returns:
#       str: help text.
#     """
#     short_description = self.contents.get(
#         'short_description', 'No description')
#     return ' {0:<35s}{1:s}\n'.format(self.name, short_description)


import glob
import io
import json
import os
from io import StringIO, TextIOWrapper
from typing import List, Union, Dict
from dftimewolf.lib import errors, resources
from dftimewolf.lib.resources import Recipe


class RecipesManager(object):
  """Recipes manager."""

  # Allow a previously registered recipe to be overridden.
  ALLOW_RECIPE_OVERRIDE = False

  _recipes = {}  # type: Dict[str, Recipe]

  def _ReadRecipeFromFileObject(
      self, file_object: Union[StringIO, TextIOWrapper]) -> Recipe:
    """Reads a recipe from a JSON file-like object.

    Args:
      file_object (file): JSON file-like object that contains the recipe.

    Returns:
      Recipe: recipe.
    """
    json_dict = json.load(file_object)

    description = json_dict['description']
    del json_dict['description']

    args = json_dict['args']
    del json_dict['args']

    return resources.Recipe(description, json_dict, args)


# Path: dftimewolf/lib/errors.py
# class DFTimewolfError(Exception):
# class BadConfigurationError(DFTimewolfError):
# class RecipeParseError(DFTimewolfError):
# class CommandLineParseError(DFTimewolfError):
# class CriticalError(DFTimewolfError):
#   def __init__(self,
#                message: Optional[str]=None,
#                name: Optional[str]=None,
#                stacktrace: Optional[str]=None,
#                critical: bool=False,
#                unexpected: bool=False) -> None:
# 
# Path: dftimewolf/lib/resources.py
# class Recipe(object):
#   def __init__(self,
#                description: str,
#                contents: Dict[str, Any],
#                args: List[Tuple[str, str, Any]]) -> None:
#   def GetHelpString(self) -> str:
# 
# Path: dftimewolf/lib/resources.py
# class Recipe(object):
#   """Recipe.
# 
#   Attributes:
#     args (list[tuple[str, str, object]]): command line arguments of
#         the recipe.
#     contents (dict[str, object]): recipe contents.
#     description (str): description.
#     name (str): name that identifies the recipe.
#   """
# 
#   def __init__(self,
#                description: str,
#                contents: Dict[str, Any],
#                args: List[Tuple[str, str, Any]]) -> None:
#     """Initializes a recipe.
# 
#     Args:
#       description (str): description.
#       contents (dict[str, object]): recipe contents.
#       args (list[tuple[str, str, object]]): command line arguments of
#           the recipe.
#     """
#     super(Recipe, self).__init__()
#     self.args = args
#     self.contents = contents
#     self.name = contents['name']  # type: str
#     self.description = description
# 
#   def GetHelpString(self) -> str:
#     """Generates a description for argparse help.
# 
#     Returns:
#       str: help text.
#     """
#     short_description = self.contents.get(
#         'short_description', 'No description')
#     return ' {0:<35s}{1:s}\n'.format(self.name, short_description)


# Path: dftimewolf/lib/recipes/manager.py
import glob
import io
import json
import os
from io import StringIO, TextIOWrapper
from typing import List, Union, Dict
from dftimewolf.lib import errors, resources
from dftimewolf.lib.resources import Recipe



class RecipesManager(object):
  """Recipes manager."""

  # Allow a previously registered recipe to be overridden.
  ALLOW_RECIPE_OVERRIDE = False

  _recipes = {}  # type: Dict[str, Recipe]

  def _ReadRecipeFromFileObject(
      self, file_object: Union[StringIO, TextIOWrapper]) -> Recipe:
    """Reads a recipe from a JSON file-like object.

    Args:
      file_object (file): JSON file-like object that contains the recipe.

    Returns:
      Recipe: recipe.
    """
    json_dict = json.load(file_object)

    description = json_dict['description']
    del json_dict['description']

    args = json_dict['args']
    del json_dict['args']

    return resources.Recipe(description, json_dict, args)


  def DeregisterRecipe(self, recipe: Recipe) -> None: