Package: aztecglyph
Aztec GlyphContentsIntroduction and FeaturesRequirements and InstallationUsage and ExamplesAttributes and MethodsAztecGlyphField - Django ExtensionContributing and CollaborationLicense and CreditsIntroduction and FeaturesThe Python AztecGlyph package is a useful tool for generating unique and secure IDs and keys in the form of 64-bit UUIDs. The AztecGlyph class represents UUIDs that are immutable, hashable, and can be used as dictionary keys. Converting an AztecGlyph object to a string using str() yields a base58-encoded string (URL-safe) that is 11 characters long.The AztecGlyph class constructor accepts four possible forms of arguments: a string (base58 encoded), a bytes object, an integer, a hexadecimal string, or the values for counter, content type, and timestamp.The AztecGlyph UUID is divided into three parts: timestamp (41 bits), counter (11 bits), and content type (12 bits).PropertyBitsMinMaxdescriptionTimestamp4115778368000003776860055551The timestamp is the number of milliseconds elapsed since January 1, 2020.Counter1102047The counter is a number incremented each time a new AztecGlyph is created and reset to 0 each time the timestamp is incremented.Content Type1204095The content type is used to identify the type of data stored in the AztecGlyph.Requirements and InstallationTo use this package, you should have Python 3.x installed. You can install the package using pip:pipinstallaztecglyphUsage and ExamplesfromaztecglyphimportAztecGlyph# Create a new AztecGlyph from a base58-encoded string (11111111111 to jpXCZedGfVQ)glyph1=AztecGlyph(s=base58_string)# Create a new AztecGlyph from a bytes object# (b'\x00\x00\x00\x00\x00\x00\x00\x00' to b'\xff\xff\xff\xff\xff\xff\xff\xff')glyph2=AztecGlyph(b=byte_object)# Create a new AztecGlyph from an integer (0 to 18446744073709551615)glyph3=AztecGlyph(i=integer_value)# Create a new AztecGlyph from a hexadecimal stringglyph4=AztecGlyph(h=hex_string)# Create a new AztecGlyph with specific counter, content type, and timestamp valuesglyph5=AztecGlyph(counter=counter_value,content_type=content_type_value,now=timestamp_value)Attributes and MethodsThe AztecGlyph class objects have several read-only attributes and methods:NameReturn TypeDescriptionglyph.content_typeintContent Type IDglyph.strstrString 11 charactersglyph.intintIntegerglyph.bytesbytesBytes objectglyph.hexstrHexadecimal stringglyph.timestampdatetimeTimestampglyph.datetimedatetimeDatetimeglyph.counterintCounterComparing AztecGlyph ObjectsAztecGlyphobjects can be compared using standard comparison operators such as==, <, <=, >, and >=`. For example:# Equality checkifglyph1==glyph2:print("glyph1 is equal to glyph2")# Less than checkifglyph1<glyph2:print("glyph1 is less than glyph2")# Greater than or equal to checkifglyph1>=glyph2:print("glyph1 is greater than or equal to glyph2")AztecGlyphField - Django ExtensionAztecGlyphField is a Django extension that enables seamless integration of the AztecGlyph library with Django models for generating unique and reliable 64-bit identifiers.Features and UsageInherits from Django's Field class for easy integration with Django models.Generates a unique AztecGlyph UUID for each new model instance.Automatically detects ContentType.Automatically detects the current timestamp and resets the counter if the timestamp changes.One Counter per ContentType per Timestamp.Requires Python 3.8 or higher, Django 2.2 or higher, and AztecGlyph 1.0.0 or higher.To use AztecGlyphField, include it in your models.py file:fromaztecglyph.extensions.djangoimportAztecGlyphFieldfromdjango.dbimportmodelsclassMyModel(models.Model):id=AztecGlyphField(primary_key=True)Then, use it like any other Django model field:my_object=MyModel()my_object.save()print(my_object.id)# Output: 326ZtZ1QLEJContributing and CollaborationContributions to the AztecGlyph project are always welcome! If you're interested in contributing, please read theContributingfile for guidelines and best practices. Feel free to submit issues and pull requests, or join the discussion on the project's GitHub page.License and CreditsThis project is licensed under theMIT License. The AztecGlyph was created byAngelCamelot.