black format
This commit is contained in:
parent
247fd37560
commit
238319b9e1
5 changed files with 23 additions and 4 deletions
|
@ -1,2 +1,3 @@
|
|||
import comfyrecipes.cli
|
||||
|
||||
comfyrecipes.cli.main()
|
||||
|
|
|
@ -12,6 +12,7 @@ import comfyrecipes.parsing as parsing
|
|||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
class Builder:
|
||||
def __init__(self) -> None:
|
||||
self.jinjaenv = jinja2.Environment(
|
||||
|
@ -140,6 +141,7 @@ class Builder:
|
|||
for ing in rec.ingredients:
|
||||
results.append(ing.unit.name)
|
||||
return results
|
||||
|
||||
unitnamelists = self.foreach_recipe(collect_unitnames)
|
||||
unitnamesset: Set[str] = set()
|
||||
for unitnamelst in unitnamelists:
|
||||
|
@ -163,6 +165,7 @@ class Builder:
|
|||
for ing in rec.ingredients:
|
||||
results.append(ing.name)
|
||||
return results
|
||||
|
||||
ingredientnamelists = self.foreach_recipe(collect_ingnames)
|
||||
ingredientnamesset: Set[str] = set()
|
||||
for ingredientnamelst in ingredientnamelists:
|
||||
|
|
|
@ -27,7 +27,9 @@ def main() -> None:
|
|||
|
||||
parser_generate_ingredients = subparsers.add_parser("generate-ingredients")
|
||||
parser_generate_ingredients.add_argument("directory", type=str)
|
||||
parser_generate_ingredients.add_argument("--force", dest="force", action="store_true")
|
||||
parser_generate_ingredients.add_argument(
|
||||
"--force", dest="force", action="store_true"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
@ -48,13 +50,19 @@ def main() -> None:
|
|||
pass
|
||||
elif args.subcommand == "generate-units":
|
||||
if not args.force and os.path.isfile(args.directory + "/units.yaml"):
|
||||
print("units.yaml already exists, pass --force if you want to overwrite it", file=sys.stderr)
|
||||
print(
|
||||
"units.yaml already exists, pass --force if you want to overwrite it",
|
||||
file=sys.stderr,
|
||||
)
|
||||
ret = 1
|
||||
else:
|
||||
builder.generate_units()
|
||||
elif args.subcommand == "generate-ingredients":
|
||||
if not args.force and os.path.isfile(args.directory + "/ingredients.yaml"):
|
||||
print("ingredients.yaml already exists, pass --force if you want to overwrite it", file=sys.stderr)
|
||||
print(
|
||||
"ingredients.yaml already exists, pass --force if you want to overwrite it",
|
||||
file=sys.stderr,
|
||||
)
|
||||
ret = 1
|
||||
else:
|
||||
builder.generate_ingredients()
|
||||
|
|
|
@ -6,6 +6,7 @@ ISSUE_DUPLICATE_UNITS = "duplicate-units"
|
|||
ISSUE_KNOWN_PRICE_UNKNOWN_CONVERSION = "known-price-unknown-conversion"
|
||||
ISSUE_UNKNOWN_UNIT = "unknown-unit"
|
||||
|
||||
|
||||
class Issue:
|
||||
def __init__(self, id: str, msg: str) -> None:
|
||||
self.id = id
|
||||
|
|
|
@ -68,6 +68,7 @@ class Context:
|
|||
jsonschema.validate(instance=settingsdct, schema=settingsschema)
|
||||
self.settings.load(settingsdct)
|
||||
|
||||
|
||||
class Element:
|
||||
def __init__(self, ctx: Context) -> None:
|
||||
self.ctx = ctx
|
||||
|
@ -76,6 +77,7 @@ class Element:
|
|||
def from_dict(cls, ctx: Context, dct: Dict[str, Any]) -> Self:
|
||||
return cls(ctx)
|
||||
|
||||
|
||||
class Unit(Element):
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -119,7 +121,6 @@ class Unit(Element):
|
|||
self.conversions = conversions
|
||||
|
||||
|
||||
|
||||
class AUnits:
|
||||
def __init__(self, ctx: Context) -> None:
|
||||
self.ctx = ctx
|
||||
|
@ -171,6 +172,7 @@ class Units(AUnits):
|
|||
f"units.yaml: {unitname} should only have one entry, found {num}",
|
||||
)
|
||||
|
||||
|
||||
class IngredientInstance(Element):
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -236,6 +238,7 @@ class IngredientInstance(Element):
|
|||
price=price,
|
||||
)
|
||||
|
||||
|
||||
class StepSection(Element):
|
||||
def __init__(self, ctx: Context, title: str, steps: List[str]) -> None:
|
||||
self.title = title
|
||||
|
@ -245,6 +248,7 @@ class StepSection(Element):
|
|||
def from_dict(cls, ctx: Context, dct: Dict[str, Any]) -> Self:
|
||||
return cls(ctx, dct["section"], dct["steps"])
|
||||
|
||||
|
||||
class Recipe(Element):
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -334,6 +338,7 @@ class Recipe(Element):
|
|||
stepsections=stepsections,
|
||||
)
|
||||
|
||||
|
||||
class Conversion(Element):
|
||||
def __init__(
|
||||
self, ctx: Context, fromunit: Unit, tounit: Unit, ratio: float
|
||||
|
@ -354,6 +359,7 @@ class Conversion(Element):
|
|||
raise RuntimeError(f"unit {dct['to']} doesn't exist")
|
||||
return cls(ctx, fromunit, tounit, dct["ratio"])
|
||||
|
||||
|
||||
class Ingredient(Element):
|
||||
def __init__(
|
||||
self,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue