Ë
    ÚÍ: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                  «        yy)é    )Ú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y)ÚNameTranslationErrorN)Ú__name__Ú
__module__Ú__qualname__© ó    úo/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/fontTools/ufoLib/filenames.pyrQ   rQ   o   s   „ ØrV   rQ   Ú c                óD  — t        | t        «      st        d«      ‚t        |«      }t        |«      }|s| d   dk(  rd| dd z   } g }| D ]6  }|t        v rd}n||j                  «       k7  r|dz  }|j                  |«       Œ8 dj                  |«      } t        |z
  |z
  }| d| } g }	| j                  d«      D ].  }
|
j                  «       t        v rd|
z   }
|	j                  |
«       Œ0 dj                  |	«      } || z   |z   }|j                  «       |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   )Ú
isinstanceÚstrÚ
ValueErrorÚlenr4   ÚlowerÚappendÚjoinrO   ÚsplitrL   ÚhandleClash1)ÚuserNameÚexistingÚprefixÚsuffixÚprefixLengthÚsuffixLengthÚfilteredUserNameÚ	characterÚsliceLengthÚpartsÚpartÚfullNames               rW   ÚuserNameToFileNamerr   s   sF  € ôH �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¸FÓCˆà€OrV   c                óf  — t        |«      }t        |«      }|t        | «      z   |z   dz   t        kD  r"|t        | «      z   |z   dz   }t        |z
  }| d| } d}d}	|€H| t        |	«      j                  d«      z   }
||
z   |z   }|j	                  «       |vr|}n|	dz  }	|	dk\  rn|€ŒH|€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
    é   Nr\   l   ÿŒIú5 )r`   rO   r^   Úzfillra   ÚhandleClash2)rf   rg   rh   ri   rj   rk   Úlrn   Ú	finalNameÚcounterÚnamerq   s               rW   re   re   Ý   sç   € ôT �v“;€LÜ�v“;€LØ”c˜(“mÑ# lÑ2°RÑ7Ô:KÒKØœ3˜x›=Ñ(¨<Ñ7¸"Ñ<ˆÜ'¨!Ñ+ˆØ˜L˜[Ð)ˆØ€Ià€GØ
Ð
Øœ#˜g›,×,Ñ,¨RÓ0Ñ0ˆØ˜D‘= 6Ñ)ˆØ�>‰>Ó 8Ñ+Ø ˆIØà�q‰LˆGØ�oÒ%Øð Ñ
ð ÐÜ  ¨6°6Ó:ˆ	àÐrV   c                óì   — t         t        |«      z
  t        |«      z
  }t        d|z  «      }d}d}|€4|t        |«      z   |z   }|j	                  «       | vr|}n|dz  }||k\  rn|€Œ4|€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
    Ú9Nr\   zNo unique name could be found.)rO   r`   rN   r^   ra   rQ   )rg   rh   ri   Ú	maxLengthÚmaxValuerx   ry   rq   s           rW   rv   rv   !  sš   € ôV "¤C¨£KÑ/´#°f³+Ñ=€IÜ�3˜‘?Ó#€Hà€IØ€GØ
Ð
ØœC ›LÑ(¨6Ñ1ˆØ�>‰>Ó 8Ñ+Ø ˆIØà�q‰LˆGØ�hÒØð Ñ
ð ÐÜ"Ð#CÓDÐDàÐrV   Ú__main__N)rU   rX   rX   )
rf   r^   rg   úIterable[str]rh   r^   ri   r^   Úreturnr^   )rg   r€   rh   r^   ri   r^   r�   r^   )Ú
__future__r   Úcollections.abcr   r4   Ú__annotations__rL   rO   Ú	ExceptionrQ   rr   re   rv   rR   ÚdoctestÚtestmodrU   rV   rW   ú<module>rˆ      s  ðÞ "å $ðò:0Ð �8ó 0òbÐ �8ó ð2 Ð �3Ó ô	˜9ô 	ð
 RTðgØðgØ*ðgØ9<ðgØKNðgàógðV .0¸rÐQSðAØðAØ*ðAØ9<ðAØKNðAàóAðJ !°À"ð=Øð=Ø*-ð=Ø<?ð=àó=ð@ ˆzÒÛà€G‡O�OÕð rV   