# ----------------------------------------------------------
# ---- Inventory Pipeline
# ----------------------------------------------------------
from dataclasses import dataclass
# ----------------------------------------------------------
# ---- class definitions
# ----------------------------------------------------------
# ---- pipeline class
class Pipeline():
# ---- initialize pipeline with inventory object
def __init__(self,iven):
self.iven = iven
# ---- returns a new (modified) inventory object
def bind(self,func):
return Pipeline(func(self.iven))
# ---- inventory data class
@dataclass
class Inventory():
'''Maintain a count of existing inventory.'''
def __init__(self,inventory file_file):
self.file = inventory_file_name
self.items = []
# ----------------------------------------------------------
# ---- pipeline functions
# ----------------------------------------------------------
pipeline functions could go here
They should be stored in separate files and imported
a. This keeps the functions as independent as possible
b. This keeps file sizes smaller
c. Allows the functions to be modified
quickly and simply
d. Allows them to be tested independently
e. Does not disturb other functions
# ----------------------------------------------------------
# ---- main
# ----------------------------------------------------------
if __name__ == '__main__':
# ---- inventory CSV file name and
# ---- last date it was modified/created (yyyymmdd)
filename = '20231014_inventory.csv'
# ---- create inventory data object
inventory = Inventory(filename)
# ---- create pipeline object
pipe = Pipeline(inventory)
# ---- pipeline
pipeline code goes here