Advertisement
Vermiculus

the accredited chef - a documented outline

Mar 22nd, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def readRecipe(filepath):
  2.     """Loads the given *.chef file and does initial parsing.
  3.    
  4. This method will parse the given filename
  5.  
  6. See http://docs.python.org/library/doctest.html#module-doctest
  7. So much awesome.
  8. >>> print hw.chef
  9. ["Hello World Souffle", "...", "...", "..."]
  10.     """
  11.     pass
  12.  
  13. # takes the instruction string from earlier and splits it into statements
  14. def preheat(method):
  15.     """Takes all of the statements (as a single string) under Method and begins the parsing process.
  16.    
  17. This method returns a list of simple tuples where the first element is the command
  18. and the second element is the source string. The output of this method is intended
  19. for calling Mom.
  20.     """
  21.     pass
  22.  
  23. def gather(ingredients):
  24.     """Return a dictionary of ingredients from the given string.
  25.    
  26. The dictionary returned will contain the ingredient as a string
  27. mapped to a tuple, where the first element indicates if it is dry or wet
  28. and the second element denotes its numeric value.
  29.  
  30. Example:
  31.     {'apple':('dry', 96), 'oil':('wet', 59), etc.}
  32.     """
  33.     pass
  34.  
  35. # Because we all know her handwriting is horrid.
  36. # we may be able to make this fun by using advanced features of functions in Python
  37. def callMom(method):
  38.     """Takes a list of command-string tuples and returns a list of pure command-tuples.
  39.    
  40. Following is a list of commands and descriptions, following the pattern
  41. (<command>,  <arguments>)   - execute <command> with <arguments>
  42. where the default value of ## is exactly 1 (signifying the mixing bowl index
  43. and where # is a plain number
  44.  
  45. For overloaded commands, use hasattr() for type checking
  46.  
  47. ('take',    'ingredient')                 - get one character from the user and place its numeric value into ingredient
  48. ('put',     'ingredient', ##)             - push the ingredient onto the ##th mixing bowl
  49. ('fold',    'ingredient', ##)             - pop the ##th mixing bowl into the ingredient
  50. ('add',     'ingredient', ##)             - peek at the ##th mixing bowl and add (numerically) ingredient to it
  51. ('remove',  'ingredient', ##)             - peek at the ##th mixing bowl and subtract (numerically) ingredient from it
  52. ('combine', 'ingredient', ##)             - peek at the ##th mixing bowl and multiply (numerically) ingredient with it
  53. ('divide',  'ingredient', ##)             - peek at the ##th mixing bowl and divide (numerically) ingredient from it
  54. ('add', ##)                               - takes all of the dry ingredients and places the sum into the #th mixing bowl
  55. ('liquefy', 'ingredient')                 - transform the ingredient into its Unicode equivalent
  56. ('liquefy',  ##)                          - transform the contents of the ##th mixing bowl into their Unicode equivalents
  57. ('stir',     ##,           #)             -
  58. ('stir',    'ingredient',  ##)            -
  59. ('mix',       ##)                         - randomize the order of the ##th mixing bowl
  60. ('clean',     ##)                         - pop the ##th mixing bowl until empty
  61. ('loop',     'verb',      'ingredient')   - See after.
  62. ('next',     'verb',      'ingredient')   - See after.
  63. ('exit')                                  - Continues execution after the next 'next'
  64. ('serve',    'recipe')                    - Invokes the execution of another recipe
  65. ('fridge')                                - Ends execution immediately and returns the first mixing bowl
  66. ('fridge, #)                              - Print out the first # baking dishes before calling ('fridge')
  67.  
  68. ('serves', #)                             - Pops and prints each baking dish in succession. This is the last command.
  69.  
  70. Note that everything that follows the 'serve' command is an auxiliary recipe.
  71.  
  72. Looping:
  73.   With the 'loop' command, if the ingredient is non-zero, continue execution until reaching the 'next' command. If the ingredient is zero, continue execution after a matching 'next'.
  74.   At the 'next' command, if an ingredient is given (defaulting to the ingredient given by 'loop'), continue execution at the previous 'loop' if the given ingredient is non-zero. If the ingredient is zero, simply continue.
  75.  
  76. The output of this method is intended for cooking.
  77.     """
  78.    
  79.     pass
  80.  
  81. def loadVerbs(path):
  82.     """Return a list verbs and their past-tense form read from a file with the given path.
  83.        
  84. The return will be a list of tuples containing two strings:
  85. the first being the infinite stem, the second being the simple past.
  86.  
  87. Example:
  88.    [("sift","sifted"),("boil","boiled"), ...]
  89.     """
  90.     pass
  91.  
  92. def loadFoods(path):
  93.     """ Returns a simple list of foods read from a file with the given path.
  94.     """
  95.     pass
  96.  
  97. # executes a list of commands
  98. def cook(ingredients, method):
  99.     """Execute the list of commands given using the ingredients provided.
  100.    
  101. Execute the given list of commands in the format given by calling Mom.
  102. It is an error if a given command does not exist.
  103.     """
  104.    
  105.     ###################################################
  106.    
  107.     # iterate through the commands with complete control over position
  108.     #   (python's for-each loop does not give you any control)
  109.     cmd_index = 0
  110.     while cmd_index < len(method):
  111.         cmd_index += 1
  112.         pass
  113.    
  114.     pass
  115.  
  116. print callMom.__doc__
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement