-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenums.py
More file actions
57 lines (47 loc) · 1.39 KB
/
Copy pathenums.py
File metadata and controls
57 lines (47 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from dataclasses import dataclass
from typing import Dict
from enum import Enum
class ProductPricing(Enum):
EACH = "per 1ea"
EACHX = "per 10ea"
EACHXX = "per 100ea"
PERKGX = "per 10kg"
PERKG = "per 1kg"
PERGXX = "per 100g"
PERGX = "per 10g"
PERG = "per 1g"
PERL = "per 1L"
PERMLXX = "per 100mL"
PERMLX = "per 10mL"
PERML = "per 1mL"
class ProductUnit(Enum):
NONE = "none"
EACH = "each" # 1 item
PACK = "pack" # idk
PIECE = "piece" # 1 item
BUNCH = "bunch" # 10 items
GRAMS = "g"
KILOGRAMS = "kg"
MILLILITRES = "mL"
LITRES = "L"
@dataclass
class Ingredient:
name: str
pricingPer: ProductPricing
pricePer: float
priceTotal: float
productSizeUnits: ProductUnit
productSize: float
productImageURL: str = ""
def serialize(self):
return {'name': self.name,
'pricingPer': self.pricingPer.value,
'pricePer': self.pricePer,
'priceTotal': self.priceTotal,
'productSizeUnits': self.productSizeUnits.value,
'productSize': self.productSize,
'productImageURL': self.productImageURL}
@staticmethod
def _fromJson(data: Dict):
return Ingredient(data['name'], data['pricingPer'], data['pricePer'],
data['priceTotal'], data['productSizeUnits'], data['productSize'])