ó
    oñ:i   ã                   óÒ  • S r SR                  S5      r\\" SS5       V s/ s H  n \" U 5      PM     sn -  r\\" S5      /-  rSR                  5       R                  S5      r\SR                  5       R                  S5      -  rSr " S	 S
\5      r	/ SS4S jr
/ SS4S jr/ SS4S jr\S:X  a4  SSKrSSKr\R                   " \R"                  " 5       R$                  5        ggs  sn f )a  
This module implements the algorithm for converting between a "user name" -
something that a user can choose arbitrarily inside a font editor - and a file
name suitable for use in a wide range of operating systems and filesystems.

The `UFO 3 specification <http://unifiedfontobject.org/versions/ufo3/conventions/>`_
provides an example of an algorithm for such conversion, which avoids illegal
characters, reserved file names, ambiguity between upper- and lower-case
characters, and clashes with existing files.

This code was originally copied from
`ufoLib <https://github.com/unified-font-object/ufoLib/blob/8747da7/Lib/ufoLib/filenames.py>`_
by Tal Leming and is copyright (c) 2005-2016, The RoboFab Developers:

-       Erik van Blokland
-       Tal Leming
-       Just van Rossum
z\" * + / : < > ? [ \ ] | \0Ú é   é    é   z!CON PRN AUX CLOCK$ NUL A:-Z: COM1zLPT1 LPT2 LPT3 COM2 COM3 COM4éÿ   c                   ó   • \ rS rSrSrg)ÚNameTranslationErroré   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r
   ó    Ú[/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/fontTools/misc/filenames.pyr   r      s   † Úr   r   Ú c                 óh  • [        U [        5      (       d  [        S5      e[        U5      n[        U5      nU(       d  U S   S:X  a  SU SS -   n / nU  H9  nU[        ;   a  SnOXwR                  5       :w  a  US-  nUR                  U5        M;     SR                  U5      n [        U-
  U-
  nU SU n / n	U R                  S5       H1  n
U
R                  5       [        ;   a  SU
-   n
U	R                  U
5        M3     SR                  U	5      n X -   U-   nUR                  5       U;   a  [        XX#5      nU$ )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   Nr   )Ú
isinstanceÚstrÚ
ValueErrorÚlenÚillegalCharactersÚlowerÚappendÚjoinÚmaxFileNameLengthÚsplitÚreservedFileNamesÚhandleClash1)ÚuserNameÚexistingÚprefixÚsuffixÚprefixLengthÚsuffixLengthÚfilteredUserNameÚ	characterÚsliceLengthÚpartsÚpartÚfullNames               r   ÚuserNameToFileNamer/       s7  € ôD �h¤×$Ñ$ÜÐCÓDÐDä�v“;€LÜ�v“;€Lö �h˜q‘k SÓ(Ø˜ ! "˜Ñ%ˆàÐÛˆ	àÔ)Ó)Ø‰IàŸ/™/Ó+Ó+Ø˜ÑˆIØ×Ñ 	Ö*ñ ð �w‰wÐ'Ó(€Hä# lÑ2°\ÑA€KØ˜˜Ð%€Hà€EØ—‘˜sÖ#ˆØ�:‰:‹<Ô,Ó,Ø˜‘:ˆDØ�‰�TÖñ $ð �x‰x˜‹€HàÑ  6Ñ)€HØ‡~�~Ó˜8Ó#Ü °FÓCˆà€Or   c                 ór  • [        U5      n[        U5      nU[        U 5      -   U-   S-   [        :”  a"  U[        U 5      -   U-   S-   n[        U-
  nU SU n SnSn	UcL  U [        U	5      R                  S5      -   n
X*-   U-   nUR	                  5       U;  a  UnOU	S-  n	U	S:¼  a  OUc  ML  Uc  [        XU5      nU$ )a  
existing should be a case-insensitive list
of all existing file names.

>>> 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
é   Nr   l   ÿŒIú5 )r   r   r   Úzfillr   ÚhandleClash2)r#   r$   r%   r&   r'   r(   Úlr+   Ú	finalNameÚcounterÚnamer.   s               r   r"   r"   ˆ   sâ   € ô> �v“;€LÜ�v“;€LØ”c˜(“mÑ# lÑ2°RÑ7Ô:KÓKØœ3˜x›=Ñ(¨<Ñ7¸"Ñ<ˆÜ'¨!Ñ+ˆØ˜L˜[Ð)ˆØ€Ià€GØ
Ñ
Øœ#˜g›,×,Ñ,¨RÓ0Ñ0ˆØ‘= 6Ñ)ˆØ�>‰>Ó 8Ó+Ø ˆIØà�q‰LˆGØ�oÓ%Øð Ó
ð ÑÜ  °6Ó:ˆ	àÐr   c                 óø   • [         [        U5      -
  [        U5      -
  n[        SU-  5      nSnSnUc8  U[        U5      -   U-   nUR	                  5       U ;  a  UnOUS-  nXd:¼  a  OUc  M8  Uc  [        S5      eU$ )a‰  
existing should be a case-insensitive list
of all existing file names.

>>> 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
Ú9Nr   zNo unique name could be found.)r   r   Úintr   r   r   )r$   r%   r&   Ú	maxLengthÚmaxValuer5   r6   r.   s           r   r3   r3   Á   s—   € ô6 "¤C¨£KÑ/´#°f³+Ñ=€IÜ�3˜‘?Ó#€Hà€IØ€GØ
Ñ
ØœC ›LÑ(¨6Ñ1ˆØ�>‰>Ó 8Ó+Ø ˆIØà�q‰LˆGØÓØð Ó
ð ÑÜ"Ð#CÓDÐDàÐr   Ú__main__r   N)Ú__doc__r    r   ÚrangeÚchrr   r!   r   Ú	Exceptionr   r/   r"   r3   r   ÚdoctestÚsysÚexitÚtestmodÚfailed)Úis   0r   Ú<module>rH      s   ðñð& 3×8Ñ8¸Ó=Ð Ø ¡e¨A¨r¤lÓ3¢l ‘c˜!–f¡lÑ3Ñ 3Ð Ø ‘c˜$“i�[Ñ  Ð Ø7×=Ñ=Ó?×EÑEÀcÓJÐ Ø Ð4×:Ñ:Ó<×BÑBÀ3ÓGÑ GÐ ØÐ ô	˜9ô 	ð +-°RÀô eðP %'¨r¸"ô 6ðr  R°ô -ð` ˆzÓÛÛà‡H‚HˆW�_Š_Ó×%Ñ%Õ&ð	 ùòy 4s    C$