othr
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
from abc import abstractmethod, ABC
|
||||
|
||||
from .article_attribute_writer import ArticleAttributeWriter
|
||||
from .name_attribute_writer import NameAttributeWriter
|
||||
from ..barcode import Barcode
|
||||
|
||||
|
||||
class BaseAttributeWriter(ABC):
|
||||
@abstractmethod
|
||||
def write(self, barcode: Barcode):
|
||||
pass
|
||||
|
||||
|
||||
class AttributeWriterFactory:
|
||||
@staticmethod
|
||||
def get_writer(key: str):
|
||||
match key:
|
||||
case 'name':
|
||||
return NameAttributeWriter()
|
||||
case 'article':
|
||||
return ArticleAttributeWriter()
|
||||
# from abc import abstractmethod, ABC
|
||||
#
|
||||
# from .article_attribute_writer import ArticleAttributeWriter
|
||||
# from .name_attribute_writer import NameAttributeWriter
|
||||
# from ..barcode import Barcode
|
||||
#
|
||||
#
|
||||
# class BaseAttributeWriter(ABC):
|
||||
# @abstractmethod
|
||||
# def write(self, barcode: Barcode):
|
||||
# pass
|
||||
#
|
||||
#
|
||||
# class AttributeWriterFactory:
|
||||
# @staticmethod
|
||||
# def get_writer(key: str):
|
||||
# match key:
|
||||
# case 'name':
|
||||
# return NameAttributeWriter()
|
||||
# case 'article':
|
||||
# return ArticleAttributeWriter()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from barcodes.attributes import BaseAttributeWriter
|
||||
from barcodes.barcode import Barcode
|
||||
|
||||
|
||||
class ArticleAttributeWriter(BaseAttributeWriter):
|
||||
def write(self, barcode: Barcode):
|
||||
pass
|
||||
# from barcodes.attributes import BaseAttributeWriter
|
||||
# from barcodes.barcode import Barcode
|
||||
#
|
||||
#
|
||||
# class ArticleAttributeWriter(BaseAttributeWriter):
|
||||
# def write(self, barcode: Barcode):
|
||||
# pass
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from barcodes.attributes import BaseAttributeWriter
|
||||
from barcodes.barcode import Barcode
|
||||
|
||||
|
||||
class NameAttributeWriter(BaseAttributeWriter):
|
||||
def write(self, barcode: Barcode):
|
||||
pass
|
||||
# from barcodes.attributes import BaseAttributeWriter
|
||||
# from barcodes.barcode import Barcode
|
||||
#
|
||||
#
|
||||
# class NameAttributeWriter(BaseAttributeWriter):
|
||||
# def write(self, barcode: Barcode):
|
||||
# pass
|
||||
@@ -1,15 +1,15 @@
|
||||
from .attributes import AttributeWriterFactory
|
||||
from models import ProductBarcode, BarcodeTemplate, BarcodeTemplateAttribute
|
||||
|
||||
|
||||
class Barcode:
|
||||
def __init__(self, session, barcode: ProductBarcode):
|
||||
self.session = session
|
||||
self.barcode = barcode
|
||||
|
||||
def render(self, template: BarcodeTemplate):
|
||||
for attribute in template.attributes:
|
||||
attribute: BarcodeTemplateAttribute
|
||||
writer = AttributeWriterFactory.get_writer(attribute.key)
|
||||
writer.write(self)
|
||||
|
||||
# from .attributes import AttributeWriterFactory
|
||||
# from models import ProductBarcode, BarcodeTemplate, BarcodeTemplateAttribute
|
||||
#
|
||||
#
|
||||
# class Barcode:
|
||||
# def __init__(self, session, barcode: ProductBarcode):
|
||||
# self.session = session
|
||||
# self.barcode = barcode
|
||||
#
|
||||
# def render(self, template: BarcodeTemplate):
|
||||
# for attribute in template.attributes:
|
||||
# attribute: BarcodeTemplateAttribute
|
||||
# writer = AttributeWriterFactory.get_writer(attribute.key)
|
||||
# writer.write(self)
|
||||
#
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from models import ProductBarcode
|
||||
|
||||
|
||||
class BarcodeGenerator:
|
||||
def __init__(self, barcode: ProductBarcode):
|
||||
self.barcode = barcode
|
||||
# from models import ProductBarcode
|
||||
#
|
||||
#
|
||||
# class BarcodeGenerator:
|
||||
# def __init__(self, barcode: ProductBarcode):
|
||||
# self.barcode = barcode
|
||||
|
||||
Reference in New Issue
Block a user