biip.sscc
Serial Shipping Container Code (SSCC).
SSCCs are used to identify logistic units, e.g. a pallet shipped between two parties.
If you only want to parse SSCCs, you can import the SSCC parser directly
instead of using biip.parse()
.
>>> from biip.sscc import Sscc
If parsing succeeds, it returns a Sscc
object.
>>> sscc = Sscc.parse("157035381410375177")
>>> sscc
Sscc(value='157035381410375177', prefix=GS1Prefix(value='570', usage='GS1
Denmark'), company_prefix=GS1CompanyPrefix(value='5703538'),
extension_digit=1, payload='15703538141037517', check_digit=7)
Biip can format the SSCC in HRI format for printing on a label.
>>> sscc.as_hri()
'1 5703538 141037517 7'
If the detected GS1 Company Prefix length is wrong, it can be overridden:
>>> sscc.as_hri(company_prefix_length=9)
'1 570353814 1037517 7'
- class biip.sscc.Sscc(value, prefix, company_prefix, extension_digit, payload, check_digit)
Data class containing an SSCC.
-
value:
str
Raw unprocessed value.
-
prefix:
Optional
[GS1Prefix
] The GS1 Prefix, indicating what GS1 country organization that assigned code range.
-
company_prefix:
Optional
[GS1CompanyPrefix
] The GS1 Company Prefix, identifying the company that issued the SSCC.
-
extension_digit:
int
Extension digit used to increase the capacity of the serial reference.
-
payload:
str
The actual payload, including extension digit, company prefix, and item reference. Excludes the check digit.
-
check_digit:
int
Check digit used to check if the SSCC as a whole is valid.
- classmethod parse(value)
Parse the given value into a
Sscc
object.- Parameters:
value (
str
) – The value to parse.- Return type:
- Returns:
SSCC data structure with the successfully extracted data. The checksum is guaranteed to be valid if an SSCC object is returned.
- Raises:
ParseError – If the parsing fails.
- as_hri(*, company_prefix_length=None)
Render as a human readable interpretation (HRI).
The HRI is often printed directly below barcodes.
The GS1 Company Prefix length will be detected and used to render the Company Prefix and the Serial Reference as two separate groups. If the GS1 Company Prefix length cannot be found, the Company Prefix and the Serial Reference are rendered as a single group.
- Parameters:
company_prefix_length (
Optional
[int
]) – Override the detected GS1 Company Prefix length. 7-10 characters. If not specified, the GS1 Company Prefix is automatically detected.- Raises:
ValueError – If an illegal company prefix length is given.
- Return type:
str
- Returns:
A human-readable string where the logic parts are separated by whitespace.
-
value: