Browse Source

add support for Code 128

Pi 4 tháng trước cách đây
mục cha
commit
d7e2fbcf33
1 tập tin đã thay đổi với 9 bổ sung2 xóa
  1. 9 2
      rest/bar.py

+ 9 - 2
rest/bar.py

@@ -1,6 +1,13 @@
-from barcode import EAN13
+from barcode import EAN13, Code128
+
+BARCODE_MAP = {
+  'EAN_13': EAN13,
+  'CODE_128': Code128,
+}
 
 def get_bar_code(meta):
-    if meta['format'] == 'EAN_13':
+    f = BARCODE_MAP.get(meta['format'], None)
+    if f is not None:
         return EAN13(meta['content']).render()
+
     return None