Skip to content

Commit

Permalink
adding Dons package
Browse files Browse the repository at this point in the history
  • Loading branch information
RomiP committed Aug 22, 2024
1 parent 7df2298 commit 3d6051f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
12 changes: 12 additions & 0 deletions book/tutorials/nb-to-package/simple_eggsample/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "eggsample"
version = "0.1.0"
description = "The eggsample from an eggsellent cook"
requires-python = ">= 3.10"

[project.scripts]
eggsample = "eggsample.cli:main"
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from eggsample.eggsellent_cook import EggsellentCook

def main():
cook = EggsellentCook()
cook.add_ingredients()
cook.prepare_the_food()
cook.serve_the_food()
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import random

condiments_tray = ["pickled walnuts", "steak sauce", "mushy peas"]

class EggsellentCook:
FAVORITE_INGREDIENTS = ("egg", "egg", "egg")

def __init__(self):
self.ingredients = None

def _add_ingredients(self, ingredients):
spices = ["salt", "pepper"]
you_can_never_have_enough_eggs = ["egg", "egg"]
spam = ["lovely spam", "wonderous spam"]
more_spam = ["splendiferous spam", "magnificent spam"]
ingredients = spices + you_can_never_have_enough_eggs + spam + more_spam
return ingredients

def _prep_condiments(self, condiments):
condiments.append("mint sauce")
return ("Now this is what I call a condiments tray!",)

def add_ingredients(self):
results = self._add_ingredients(
ingredients=self.FAVORITE_INGREDIENTS
)
my_ingredients = list(self.FAVORITE_INGREDIENTS)
self.ingredients = my_ingredients + results

def prepare_the_food(self):
random.shuffle(self.ingredients)

def serve_the_food(self):
condiment_comments = self._prep_condiments(
condiments=condiments_tray
)
print(f"Your food. Enjoy some {', '.join(self.ingredients)}")
print(f"Some condiments? We have {', '.join(condiments_tray)}")
if any(condiment_comments):
print("\n".join(condiment_comments))

0 comments on commit 3d6051f

Please sign in to comment.