Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3
2øªjü ã @ sÄ d Z djdƒZedd„ eddƒD ƒ7 Zeedƒg7 Zdjƒ jdƒZed jƒ jdƒ7 Zd
ZG dd„ deƒZ g d
d
fdd„Z
g d
d
fdd„Zg d
d
fdd„Ze
dkrÀddlZddlZejejƒ jƒ dS )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 `_
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 `_
by Tal Leming and is copyright (c) 2005-2016, The RoboFab Developers:
- Erik van Blokland
- Tal Leming
- Just van Rossum
z\" * + / : < > ? [ \ ] | \0ú c C s g | ]}t |ƒ‘qS © )Úchr)Ú.0Úir r ú=/tmp/pip-build-_d5lkt3n/fonttools/fontTools/misc/filenames.pyú
s r é é é z!CON PRN AUX CLOCK$ NUL A:-Z: COM1zLPT1 LPT2 LPT3 COM2 COM3 COM4éÿ c @ s e Zd ZdS )ÚNameTranslationErrorN)Ú__name__Ú
__module__Ú__qualname__r r r r r s r Ú c C s t | tƒstdƒ‚t|ƒ}t|ƒ}| rD| d dkrDd| dd… } g }x8| D ]0}|tkr`d}n||jƒ krt|d7 }|j|ƒ qNW dj|ƒ} t| | }| d|… } g } x0| j dƒD ]"}
|
jƒ t
krÌd|
}
| j|
ƒ q´W dj| ƒ} || | }|jƒ |k�rt| |||ƒ}|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 Nr )Ú
isinstanceÚstrÚ
ValueErrorÚlenÚillegalCharactersÚlowerÚappendÚjoinÚmaxFileNameLengthÚsplitÚreservedFileNamesÚhandleClash1)ÚuserNameÚexistingÚprefixÚsuffixÚprefixLengthÚsuffixLengthZfilteredUserNameÚ characterÚsliceLengthÚpartsÚpartÚfullNamer r r ÚuserNameToFileName! s4 B
r+ c C s t |ƒ}t |ƒ}|t | ƒ | d tkrP|t | ƒ | d }t| }| d|… } d}d} xP|dkr¨| t| ƒjdƒ }
||
| }|jƒ |kr”|}P n| d7 } | dkrZP qZW |dkr¾t|||ƒ}|S )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* r r r r ˆ s(
r c C s€ t t|ƒ t|ƒ }td| ƒ}d}d}xB|dkrj|t|ƒ | }|jƒ | krV|}P n|d7 }||kr*P q*W |dkr|tdƒ‚|S )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 zNo unique name could be found.)r r Úintr r r )r! r" r# Z maxLengthZmaxValuer0 r1 r* r r r r. À s
r. Ú__main__r N)Ú__doc__r r Úranger r r r Ú Exceptionr r+ r r. r
ÚdoctestÚsysÚexitÚtestmodÚfailedr r r r Ú s
g8/