File: //var/opt/nydus/ops/shortuuid/__pycache__/main.cpython-39.pyc
a
�,�hP � @ s� d Z ddlZddlZddlZddlmZ ddlmZ d
eee ee e d�dd�Z
e ee ed�d d
�ZG dd� de�Z
e
� ZejZejZejZejZejZejZdS )zConcise UUID generation.� N)�List)�Optional)�number�alphabet�padding�returnc C s` d}t |�}| r,t| |�\} }||| 7 }q|rRt|t |� d�}||d | }|ddd� S )zw
Convert a number to a string, using the given alphabet.
The output has the most significant digit first.
� r N���)�len�divmod�max)r r r �output� alpha_len�digit� remainder� r �?/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/shortuuid/main.py�
int_to_string
s r )�stringr r c C s, d}t |�}| D ]}|| |�|� }q|S )z�
Convert a string to a number, using the given alphabet.
The input is assumed to have the most significant digit first.
r )r
�index)r r r r �charr r r �
string_to_int s
r c @ s� e Zd Zdee dd�dd�Zeed�dd��Zde j
ee ed�d d
�Zdeee j
d�d
d�Z
d ee ee ed�dd�Zd!ee ed�dd�Zed�dd�Zedd�dd�Zd"eed�dd�ZdS )#� ShortUUIDN)r r c C s |d u rd}| � |� d S )NZ923456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz)�set_alphabet)�selfr r r r �__init__+ s zShortUUID.__init__)r c C s t t�t�dd | j���S )zNReturn the necessary length to fit the entire UUID given the current alphabet.� � )�int�math�ceil�log�
_alpha_len�r r r r �_length1 s zShortUUID._length)�uuid�
pad_lengthr c C s4 t |tj�std��|du r"| j}t|j| j|d�S )z�
Encode a UUID into a string (LSB first) according to the alphabet.
If leftmost (MSB) bits are 0, the string might be shorter.
z#Input `uuid` must be a UUID object.N)r )�
isinstance�_uu�UUID�
ValueErrorr$ r r � _alphabet)r r% r&