+
    f7i   c                   s   R t RP                  R4      t]]! ^^ 4       U u. uF  p ]! V 4      NK  	  up ,          t]]! ^4      .,          tRP                  4       P                  R4      t]RP                  4       P                  R4      ,          t^t ! R R]4      t	. RR3R lt
. RR3R	 lt. RR3R
 lt]R8X  d6   ^ RIt^ RIt]P                   ! ]P"                  ! 4       P$                  4       R# R# u up i )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\" * + / : < > ? [ \ ] | \0Z z!CON PRN AUX CLOCK$ NUL A:-Z: COM1zLPT1 LPT2 LPT3 COM2 COM3 COM4c                   s    ] tR t^tRtR# )NameTranslationError N)__name__Z
__module__Z__qualname__Z__firstlineno__Z__static_attributes__r       ?/usr/lib64/python3.14/site-packages/fontTools/misc/filenames.pyr    r       s    r   r     c                s   \        V \        4      '       g   \        R4      h\        V4      p\        V4      pV'       g   V ^ ,          R8X  d   RV R,          ,           p . pV  F?  pV\        9   d   RpMWwP                  4       8w  d
   VR,          pVP                  V4       KA  	  RP                  V4      p \        V,
          V,
          pV RV p . p	V P                  R4       F6  p
V
P                  4       \        9   d
   RV
,           p
V	P                  V
4       K8  	  RP                  V	4      p W ,           V,           pVP                  4       V9   d   \        WW#4      pV# )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.Z.Z_:i   NNr   N)Z
isinstancestrZ
ValueErrorlenillegalCharacterslowerZappendZjoinmaxFileNameLengthsplitreservedFileNameshandleClash1)userNameexistingprefixsuffixprefixLengthsuffixLengthZfilteredUserNameZ	charactersliceLengthZpartsZpartfullName   &&&&        r   userNameToFileNamer       s5   D h$$CDDv;Lv;L hqkS("%	))I//++I	*  ww'(H#l2\AK%HEs#::<,,:DT $ xxH 6)H~~8#FCOr   c                s   \        V4      p\        V4      pV\        V 4      ,           V,           ^,           \        8  d3   V\        V 4      ,           V,           ^,           p\        V,
          pV RV p Rp^p	Vf\   V \        V	4      P                  ^4      ,           p
W*,           V,           pVP	                  4       V9  d   TpMV	^,          p	V	R8  g   K^   Vf   \        WV4      pV# )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
Nl   I5 )r   r
   r   Zzfillr	   handleClash2)r   r   r   r   r   r   Zlr   	finalNamecounterZnamer   r   r   r   r      s    > v;Lv;Lc(m#l2R7:KK3x=(<7"<'!+L[)IG

#g,,,R00=6)>>8+ IqLGo% 6:	r   c                s*   \         \        V4      ,
          \        V4      ,
          p\        RV,          4      pRp^pVfD   V\        V4      ,           V,           pVP	                  4       V 9  d   TpMV^,          pWd8  g   KF   Vf   \        R4      hV# )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
Z9NzNo unique name could be found.)r
   r   Zintr   r	   r    )r   r   r   Z	maxLengthZmaxValuer   r   r   s   &&&     r   r   r      s    6 "CK/#f+=I3?#HIG

CL(61>>8+ IqLG"#CDDr   Z__main__N)Z__doc__r   r   ZrangeZchrr	   r   r
   Z	Exceptionr    r   r   r   r   ZdoctestZsysZexitZtestmodZfailed)Zis   0r   <module>r      s   & 388=  eArl3lc!fl3 3  c$i[   7==?EEcJ  4::<BB3G G  	9 	 +-R eP %'r" 6r R -` zHHW__%%&	 y 4s   C2