
    AhK                     t    d Z dZdZedd ZdZedd ZdZedd d	z   Zedd Z G d
 de	      Z
defdZdefdZy)zeConvert strings to numbers and numbers to strings.

Gustavo Picon
https://tabo.pe/projects/numconv/

z2.1.1zU0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~N    ABCDEFGHIJKLMNOPQRSTUVWXYZ234567    z@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/>   z-_c                   (    e Zd ZdZdefdZd Zd Zy)NumConvae  Class to create converter objects.

        :param radix: The base that will be used in the conversions.
           The default value is 10 for decimal conversions.
        :param alphabet: A string that will be used as a encoding alphabet.
           The length of the alphabet can be longer than the radix. In this
           case the alphabet will be internally truncated.

           The default value is :data:`numconv.BASE85`

        :raise TypeError: when *radix* isn't an integer
        :raise ValueError: when *radix* is invalid
        :raise ValueError: when *alphabet* has duplicated characters
    
   c           
         t        |      |k7  rt        d      d|cxk  rt        |      k  sn t        dt        |      fz        || _        || _        t        t        | j
                  t        t        | j
                                          | _	        t        | j                        t        | j
                        k7  rt        d| j
                  d      y)z'basic validation and cached_map storagezradix must be an integer   zradix must be >= 2 and <= %dzduplicate characters found in ''N)
int	TypeErrorlen
ValueErrorradixalphabetdictziprange
cached_map)selfr   r   s      A/home/dcms/DCMS/lib/python3.12/site-packages/treebeard/numconv.py__init__zNumConv.__init__*   s    u:677E*S]*;H?! ! " "
 s4==%DMM8J2KLMt3t}}#55! " " 6    c                 N   t        |      |k7  rt        d      |dk  rt        d      | j                  | j                  }}|dv rE|d| j                         t        d| j                         k(  rdddd|   |z  j                         S d	}	 |||z     |z   }||k  r	 |S ||z  })
a  Converts an integer into a string.

        :param num: A numeric value to be converted to another base as a
                    string.

        :rtype: string

        :raise TypeError: when *num* isn't an integer
        :raise ValueError: when *num* isn't positive
        znumber must be an integer    znumber must be positive)   r   r   Nz%oz%dz%x )r   r   r   r   r   lowerBASE85upper)r   numr   r   rets        r   int2strzNumConv.int2str8   s     s8s?7887677**dmmxK% &&(F6EN,@,@,BB$D1%83>EEGG3;'#-CU{
 EMC	 r   c                    | j                   | j                  }}|dk  r7|d| j                         t        d| j                         k(  rt	        ||      S d}|d| }|D ]+  }||vrt        d||fz        ||z  | j                  |   z   }- |S )a  Converts a string into an integer.

        If possible, the built-in python conversion will be used for speed
        purposes.

        :param num: A string that will be converted to an integer.

        :rtype: integer

        :raise ValueError: when *num* is invalid
        $   Nr   z3invalid literal for radix2int() with radix %d: '%s')r   r   r   r   r   r   r   )r   r!   r   r   r"   	lalphabetchars          r   str2intzNumConv.str2intS   s     **dmmxB;8FU+113vfu~7K7K7MMsE?"Ve$	 	6D9$  ",/4cl"; < <+ 55C		6
 
r   N)__name__
__module____qualname____doc__r   r   r#   r(    r   r   r   r      s      & "6r   r   r   c                 8    t        ||      j                  |       S )zChelper function for quick base conversions from integers to strings)r   r#   r!   r   r   s      r   r#   r#   l       5(#++C00r   c                 8    t        ||      j                  |       S )zChelper function for quick base conversions from strings to integers)r   r(   r/   s      r   r(   r(   q   r0   r   )r,   __version__r   BASE16BASE32	BASE32HEXBASE64	BASE64URLBASE62objectr   r#   r(   r-   r   r   <module>r:      s~    
# 
	+3BK		K3BK$	 
Of Od F 1
 F 1r   