biip.gln
Global Location Number (GLN).
GLNs are used to identify physical locations, digital locations, legal entities, and organizational functions.
If you only want to parse GLNs, you can import the GLN parser directly.
>>> from biip.gln import Gln
If parsing succeeds, it returns a Gln
object.
>>> gln = Gln.parse("1234567890128")
>>> pprint(gln)
Gln(
value='1234567890128',
prefix=GS1Prefix(
value='123',
usage='GS1 US'
),
company_prefix=GS1CompanyPrefix(
value='1234567890'
),
payload='123456789012',
check_digit=8
)
As GLNs do not appear independently in barcodes, the GLN parser is not a part of
the top-level parser biip.parse()
. However, if you are parsing a
barcode with GS1 element strings including a GLN, the GLN will be parsed and
validated using the Gln
class.
>>> import biip
>>> gln = (
... biip.parse("4101234567890128")
... .gs1_message
... .element_strings.get(data_title="SHIP TO")
... .gln
... )
>>> pprint(gln)
Gln(
value='1234567890128',
prefix=GS1Prefix(
value='123',
usage='GS1 US'
),
company_prefix=GS1CompanyPrefix(
value='1234567890'
),
payload='123456789012',
check_digit=8
)
Gln
dataclass
Dataclass containing a GLN.
Source code in src/biip/gln.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
check_digit
instance-attribute
Check digit used to check if the GLN as a whole is valid.
company_prefix
instance-attribute
The GS1 Company Prefix.
Identifying the company that issued the GLN.
payload
instance-attribute
The actual payload.
Including extension digit, company prefix, and item reference. Excludes the check digit.
prefix
instance-attribute
The GS1 Prefix.
Indicating what GS1 country organization that assigned code range.
as_gln
parse
classmethod
Parse the given value into a Gln
object.
The checksum is guaranteed to be valid if a GLN object is returned.
Parameters:
-
value
(str
) –The value to parse.
-
config
(ParseConfig | None
, default:None
) –Configuration options for parsing.
Returns:
-
Gln
–GLN data structure with the successfully extracted data.
Raises:
-
ParseError
–If the parsing fails.