gpf.common.guids module¶
This module contains the Guid
class, which inherits from Pythons built-in UUID
class.
It helps validating existing GUIDs (e.g. GlobalID’s) and can generate new ones. It also helps formatting the GUID
for use in SQL queries.
-
class
gpf.common.guids.
Guid
(value=None, allow_new: bool = False)[source]¶ Bases:
uuid.UUID
Takes a UUID-like string or object as input and validates it. Can also be used to generate a new GUID. The Guid class inherits from the Python built-in UUID.
Params:
value (object):
The value to parse as a GUID. Must be set if allow_new is
True
.allow_new (bool):
If set to
True
and value isNone
, a new GUID will be generated. The default isFalse
, which means that an exception will be raised if value is not set.
Raises: - gpf.tools.Guid.MissingGuidError – This exception is raised when allow_new is
False
and value isNone
. - gpf.tools.Guid.BadGuidError – This exception is raised when value cannot be parsed to a GUID.
Examples:
>>> Guid(allow_new=True) Guid('459b46ce-6370-48ae-b3cc-220026d49ec2') >>> guid = Guid('{459b46ce-6370-48ae-b3cc-220026d49ec2}') >>> str(guid) # this returns the GUID for Esri SQL expressions '{459B46CE-6370-48AE-B3CC-220026D49EC2}'