biip.gs1_application_identifiers
Support for GS1 Application Identifiers (AI).
Application identifiers are used to identify the type of data that follows in a GS1 element string.
All application identifier data is bundled with Biip. No network access is required.
Examples:
>>> from biip.gs1_application_identifiers import GS1ApplicationIdentifier
>>> ai = GS1ApplicationIdentifier.extract("01")
>>> pprint(ai)
GS1ApplicationIdentifier(
ai='01',
description='Global Trade Item Number (GTIN)',
data_title='GTIN',
separator_required=False,
format='N2+N14'
)
>>> ai.pattern
'^01(\\d{14})$'
GS1ApplicationIdentifier
dataclass
GS1 Application Identifier (AI).
AIs are data field prefixes used in several types of barcodes, including GS1-128. The AI defines what semantical meaning and format of the following data field.
AIs standardize how to include e.g. product weight, expiration dates, and lot numbers in barcodes.
Source code in src/biip/gs1_application_identifiers/__init__.py
pattern
class-attribute
instance-attribute
Regular expression for parsing the AIs element string.
separator_required
instance-attribute
Whether a separator character is required after element strings of this type.
This is the case for all AIs that have a variable length.
extract
classmethod
Extract the GS1 Application Identifier (AI) from the given value.
Parameters:
-
value
(str
) –The string to extract an AI from.
Returns:
-
GS1ApplicationIdentifier
–Metadata about the extracted AI.
Raises:
-
ParseError
–If the parsing fails.
Examples:
>>> from biip.gs1_application_identifiers import GS1ApplicationIdentifier
>>> ai = GS1ApplicationIdentifier.extract("010703206980498815210526100329")
>>> pprint(ai)
GS1ApplicationIdentifier(
ai='01',
description='Global Trade Item Number (GTIN)',
data_title='GTIN',
separator_required=False,
format='N2+N14'
)