WhyNotHugo / python-barcode

㊙️ Create standard barcodes with Python. No external dependencies. 100% Organic Python.
http://python-barcode.rtfd.io/
MIT License
572 stars 123 forks source link

Basic support for MSI / Plessey #191

Open petaflot opened 1 year ago

petaflot commented 1 year ago

also allows encoding of strings and bytestrings (allows encoding any symbol) by converting them to int ; in this case, string representation is shown in human-readable string

petaflot commented 1 year ago

190

codecov[bot] commented 1 year ago

Codecov Report

Base: 80.63% // Head: 79.36% // Decreases project coverage by -1.26% :warning:

Coverage data is based on head (ba6ce09) compared to base (f3a7046). Patch coverage: 39.28% of modified lines in pull request are covered.

:exclamation: Current head ba6ce09 differs from pull request most recent head 943acae. Consider uploading reports for the commit 943acae to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #191 +/- ## ========================================== - Coverage 80.63% 79.36% -1.27% ========================================== Files 17 17 Lines 888 916 +28 ========================================== + Hits 716 727 +11 - Misses 172 189 +17 ``` | [Impacted Files](https://codecov.io/gh/WhyNotHugo/python-barcode/pull/191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Hugo+Osvaldo+Barrera) | Coverage Δ | | |---|---|---| | [barcode/codex.py](https://codecov.io/gh/WhyNotHugo/python-barcode/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Hugo+Osvaldo+Barrera#diff-YmFyY29kZS9jb2RleC5weQ==) | `77.18% <37.03%> (-6.06%)` | :arrow_down: | | [barcode/\_\_init\_\_.py](https://codecov.io/gh/WhyNotHugo/python-barcode/pull/191/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Hugo+Osvaldo+Barrera#diff-YmFyY29kZS9fX2luaXRfXy5weQ==) | `96.00% <100.00%> (+0.08%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Hugo+Osvaldo+Barrera). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Hugo+Osvaldo+Barrera)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

petaflot commented 1 year ago

it's not standard at all (hence the new defaults). it's a workaround because no 1D barcode that I know of can encode arbitrary bytes (at most a variant of extended ASCII)

the MSI barcode will encode just an int (hence the new default values for "byteorder" and "encoding" : the user must force this workaround, otherwise an exception will be raised at init. I specifically chose to use MSI for this purpose, because since it normally allows only integer encoding the risk of confusion is minimal (user has to explicitly force the conversion : the same approach with ie. Code128 would get very confusing)

does this seem like a reasonable approach? it's a quite inefficient method of encoding data (mostly because of BCD being inefficient in itself) but if the purpose is just to encode short strings it's acceptable. the code could be extended to split longer strings on multiple lines (sort-of like DataBar does) that could be read sequentially.

petaflot commented 1 year ago

also, from https://www.dynamsoft.com/blog/insights/the-comprehensive-guide-to-1d-and-2d-barcodes/ :

MSI Codes are used in inventory management to mark shelves and containers to identify storage locations.

Industry

    Inventory
    Warehousing

This basically means that MSI codes are used "internally" by organizations, so it is unlikely that any "consumer" will stumble on such a code (those codes are used in a specific context) ; this is - again - less chance for confusion

printing the decoded string under the barcode lessens even more the risk of confusion

FIY, for displaying bytestrings that cannot be decoded (I have a great deal of those), I wrote https://github.com/petaflot/bytes_as_braille ; I am likely to add a "label" argument to MSI.init() to let the user specify the label - I didn't want to make bytes_as_braille a dependency of python-barcode

petaflot commented 1 year ago
rmkane commented 1 year ago

The JsBarcode project includes multiple implementations of MSI:

petaflot commented 1 year ago

The JsBarcode project includes multiple implementations of MSI:

* MSI

* MSI10

* MSI1010

* MSI11

* MSI1110

isn't that javascript?

rmkane commented 1 year ago

The JsBarcode project includes multiple implementations of MSI:

* MSI

* MSI10

* MSI1010

* MSI11

* MSI1110

isn't that javascript?

It is, but porting the code over to Python would be an easy task. I was just citing it as an implementation of MSI.