§
    ¢”jž)  ã                  óÒ   — U d dl mZ d dlmZ 	 h d£Zded<   h d£Zded<   dZd	ed
<    G d„ de¦  «        Z		 ddd„Z
g ddfdd„Zg ddfdd„Zedk    rd dlZ ej        ¦   «          dS dS )é    )Úannotations)ÚIterable>/   Ú*ú úúúúúúúúú	ú
úúúúúúúúúúúúúúúúúúúúúú"ú(ú)ú+ú/ú:ú<ú>ú?ú[ú\ú]ú|úzset[str]ÚillegalCharacters>   úclock$ÚauxÚconÚnulÚprnÚcom1Úcom2Úcom3Úcom4Úcom5Úcom6Úcom7Úcom8Úcom9Úlpt1Úlpt2Úlpt3Úlpt4Úlpt5Úlpt6Úlpt7Úlpt8Úlpt9ÚreservedFileNameséÿ   ÚintÚmaxFileNameLengthc                  ó   — e Zd ZdS )ÚNameTranslationErrorN)Ú__name__Ú
__module__Ú__qualname__© ó    úi/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/fontTools/ufoLib/filenames.pyrQ   rQ   o   s   € € € € € Ø€DrV   rQ   rU   Ú ÚuserNameÚstrÚexistingúIterable[str]ÚprefixÚsuffixÚreturnc                óÊ  — t          | t          ¦  «        st          d¦  «        ‚t          |¦  «        }t          |¦  «        }|s| d         dk    rd| dd…         z   } g }| D ]@}|t          v rd}n||                     ¦   «         k    r|dz  }|                     |¦  «         ŒAd                     |¦  «        } t          |z
  |z
  }| d|…         } g }	|  	                    d¦  «        D ]7}
|
                     ¦   «         t          v rd|
z   }
|	                     |
¦  «         Œ8d                     |	¦  «        } || z   |z   }|                     ¦   «         |v rt          | |||¦  «        }|S )aŒ  Converts from a user name to a file name.

    Takes care to avoid illegal characters, reserved file names, ambiguity between
    upper- and lower-case characters, and clashes with existing files.

    Args:
            userName (str): The input file name.
            existing: A case-insensitive list of all existing file names.
            prefix: Prefix to be prepended to the file name.
            suffix: Suffix to be appended to the file name.

    Returns:
            A suitable filename.

    Raises:
            NameTranslationError: If no suitable name could be generated.

    Examples::

            >>> userNameToFileName("a") == "a"
            True
            >>> userNameToFileName("A") == "A_"
            True
            >>> userNameToFileName("AE") == "A_E_"
            True
            >>> userNameToFileName("Ae") == "A_e"
            True
            >>> userNameToFileName("ae") == "ae"
            True
            >>> userNameToFileName("aE") == "aE_"
            True
            >>> userNameToFileName("a.alt") == "a.alt"
            True
            >>> userNameToFileName("A.alt") == "A_.alt"
            True
            >>> userNameToFileName("A.Alt") == "A_.A_lt"
            True
            >>> userNameToFileName("A.aLt") == "A_.aL_t"
            True
            >>> userNameToFileName(u"A.alT") == "A_.alT_"
            True
            >>> userNameToFileName("T_H") == "T__H_"
            True
            >>> userNameToFileName("T_h") == "T__h"
            True
            >>> userNameToFileName("t_h") == "t_h"
            True
            >>> userNameToFileName("F_F_I") == "F__F__I_"
            True
            >>> userNameToFileName("f_f_i") == "f_f_i"
            True
            >>> userNameToFileName("Aacute_V.swash") == "A_acute_V_.swash"
            True
            >>> userNameToFileName(".notdef") == "_notdef"
            True
            >>> userNameToFileName("con") == "_con"
            True
            >>> userNameToFileName("CON") == "C_O_N_"
            True
            >>> userNameToFileName("con.alt") == "_con.alt"
            True
            >>> userNameToFileName("alt.con") == "alt._con"
            True
    z(The value for userName must be a string.r   ú.Ú_é   NrX   )Ú
isinstancerZ   Ú
ValueErrorÚlenr4   ÚlowerÚappendÚjoinrO   ÚsplitrL   ÚhandleClash1)rY   r[   r]   r^   ÚprefixLengthÚsuffixLengthÚfilteredUserNameÚ	characterÚsliceLengthÚpartsÚpartÚfullNames               rW   ÚuserNameToFileNamert   s   s‘  € õH �h¥Ñ$Ô$ð EÝÐCÑDÔDÐDå�v‘;”;€LÝ�v‘;”;€Lð ð &�h˜q”k SÒ(Ð(Ø˜ ! " "œÑ%ˆàÐØð +ð +ˆ	àÕ)Ð)Ð)ØˆIˆIà˜)Ÿ/š/Ñ+Ô+Ò+Ð+Ø˜ÑˆIØ×Ò 	Ñ*Ô*Ð*Ð*Ø�wŠwÐ'Ñ(Ô(€Hå# lÑ2°\ÑA€KØ˜˜˜Ô%€Hà€EØ—’˜sÑ#Ô#ð ð ˆØ�:Š:‰<Œ<Õ,Ð,Ð,Ø˜‘:ˆDØ�Š�TÑÔÐÐØ�xŠx˜‰Œ€Hà˜Ñ  6Ñ)€HØ‡~‚~ÑÔ˜8Ð#Ð#Ý ¨(°F¸FÑCÔCˆà€OrV   c                ó¶  — t          |¦  «        }t          |¦  «        }|t          | ¦  «        z   |z   dz   t          k    r,|t          | ¦  «        z   |z   dz   }t          |z
  }| d|…         } d}d}	|€T| t          |	¦  «                             d¦  «        z   }
||
z   |z   }|                     ¦   «         |vr|}n|	dz  }	|	dk    rn|®T|€t          |||¦  «        }|S )aC  A helper function that resolves collisions with existing names when choosing a filename.

    This function attempts to append an unused integer counter to the filename.

        Args:
                userName (str): The input file name.
                existing: A case-insensitive list of all existing file names.
                prefix: Prefix to be prepended to the file name.
                suffix: Suffix to be appended to the file name.

        Returns:
                A suitable filename.

        >>> prefix = ("0" * 5) + "."
        >>> suffix = "." + ("0" * 10)
        >>> existing = ["a" * 5]

        >>> e = list(existing)
        >>> handleClash1(userName="A" * 5, existing=e,
        ...		prefix=prefix, suffix=suffix) == (
        ... 	'00000.AAAAA000000000000001.0000000000')
        True

        >>> e = list(existing)
        >>> e.append(prefix + "aaaaa" + "1".zfill(15) + suffix)
        >>> handleClash1(userName="A" * 5, existing=e,
        ...		prefix=prefix, suffix=suffix) == (
        ... 	'00000.AAAAA000000000000002.0000000000')
        True

        >>> e = list(existing)
        >>> e.append(prefix + "AAAAA" + "2".zfill(15) + suffix)
        >>> handleClash1(userName="A" * 5, existing=e,
        ...		prefix=prefix, suffix=suffix) == (
        ... 	'00000.AAAAA000000000000001.0000000000')
        True
    é   Nrc   l   ÿŒIú5 )rf   rO   rZ   Úzfillrg   ÚhandleClash2)rY   r[   r]   r^   rl   rm   Úlrp   Ú	finalNameÚcounterÚnamers   s               rW   rk   rk   Ý   s  € õT �v‘;”;€LÝ�v‘;”;€LØ•c˜(‘m”mÑ# lÑ2°RÑ7Õ:KÒKÐKØ�3˜x™=œ=Ñ(¨<Ñ7¸"Ñ<ˆÝ'¨!Ñ+ˆØ˜L˜[˜LÔ)ˆØ€Ià€GØ
Ð
Ø�#˜g™,œ,×,Ò,¨RÑ0Ô0Ñ0ˆØ˜D‘= 6Ñ)ˆØ�>Š>ÑÔ 8Ð+Ð+Ø ˆIØà�q‰LˆGØ�oÒ%Ð%Øð Ð
ð ÐÝ  ¨6°6Ñ:Ô:ˆ	àÐrV   c                ó  — t           t          |¦  «        z
  t          |¦  «        z
  }t          d|z  ¦  «        }d}d}|€<|t          |¦  «        z   |z   }|                     ¦   «         | vr|}n|dz  }||k    rn|®<|€t          d¦  «        ‚|S )ak  A helper function that resolves collisions with existing names when choosing a filename.

    This function is a fallback to :func:`handleClash1`. It attempts to append an unused integer counter to the filename.

        Args:
                userName (str): The input file name.
                existing: A case-insensitive list of all existing file names.
                prefix: Prefix to be prepended to the file name.
                suffix: Suffix to be appended to the file name.

        Returns:
                A suitable filename.

        Raises:
                NameTranslationError: If no suitable name could be generated.

        Examples::

          >>> prefix = ("0" * 5) + "."
          >>> suffix = "." + ("0" * 10)
          >>> existing = [prefix + str(i) + suffix for i in range(100)]

          >>> e = list(existing)
          >>> handleClash2(existing=e, prefix=prefix, suffix=suffix) == (
          ... 	'00000.100.0000000000')
          True

          >>> e = list(existing)
          >>> e.remove(prefix + "1" + suffix)
          >>> handleClash2(existing=e, prefix=prefix, suffix=suffix) == (
          ... 	'00000.1.0000000000')
          True

          >>> e = list(existing)
          >>> e.remove(prefix + "2" + suffix)
          >>> handleClash2(existing=e, prefix=prefix, suffix=suffix) == (
          ... 	'00000.2.0000000000')
          True
    Ú9Nrc   zNo unique name could be found.)rO   rf   rN   rZ   rg   rQ   )r[   r]   r^   Ú	maxLengthÚmaxValuerz   r{   rs   s           rW   rx   rx   !  s¯   € õV "¥C¨¡K¤KÑ/µ#°f±+´+Ñ=€IÝ�3˜‘?Ñ#Ô#€Hà€IØ€GØ
Ð
Ø�C ™LœLÑ(¨6Ñ1ˆØ�>Š>ÑÔ 8Ð+Ð+Ø ˆIØà�q‰LˆGØ�hÒÐØð Ð
ð ÐÝ"Ð#CÑDÔDÐDàÐrV   Ú__main__N)rU   rX   rX   )
rY   rZ   r[   r\   r]   rZ   r^   rZ   r_   rZ   )r[   r\   r]   rZ   r^   rZ   r_   rZ   )Ú
__future__r   Úcollections.abcr   r4   Ú__annotations__rL   rO   Ú	ExceptionrQ   rt   rk   rx   rR   ÚdoctestÚtestmodrU   rV   rW   ú<module>rˆ      sb  ðØ "Ð "Ð "Ð "Ð "Ð "Ð "à $Ð $Ð $Ð $Ð $Ð $ðð:0ð 0ð 0Ð ð 0ð 0ð 0ñ 0ðbð ð Ð ð ð ð ñ ð2 Ð Ð Ð Ð Ñ ð	ð 	ð 	ð 	ð 	˜9ñ 	ô 	ð 	ð
 RTðgð gð gð gð gðV .0¸rÐQSðAð Að Að Að AðJ !°À"ð=ð =ð =ð =ð =ð@ ˆzÒÐØ€N€N€Nà€G„OÑÔÐÐÐð ÐrV   