o
0iF) @ s d Z g dZddlZdZdZdZee ZdZed d Zd
Z dZ
ee e
e Zddd
Zddl
ZddlmZ i ZG dd dZe G dd dZdS )an A collection of string constants.
Public module variables:
whitespace -- a string containing all ASCII whitespace
ascii_lowercase -- a string containing all ASCII lowercase letters
ascii_uppercase -- a string containing all ASCII uppercase letters
ascii_letters -- a string containing all ASCII letters
digits -- a string containing all ASCII decimal digits
hexdigits -- a string containing all ASCII hexadecimal digits
octdigits -- a string containing all ASCII octal digits
punctuation -- a string containing all ASCII punctuation characters
printable -- a string containing all ASCII characters considered printable
)
ascii_lettersascii_lowercaseascii_uppercasecapwordsdigits hexdigits octdigits printablepunctuation
whitespace FormatterTemplate Nz
ZabcdefghijklmnopqrstuvwxyzZABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789ZabcdefZABCDEFZ01234567z !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~c C s |pd dd | |D S )a capwords(s [,sep]) -> string
Split the argument into words using split, capitalize each
word using capitalize, and join the capitalized words using
join. If the optional second argument sep is absent or None,
runs of whitespace characters are replaced by a single space
and leading and trailing whitespace are removed, otherwise
sep is used to split and join the words.
c s s | ]}| V qd S N)
capitalize).0x r -/opt/alt/python310/lib64/python3.10/string.py 0 s zcapwords..)joinsplit)ssepr r r r % s r )ChainMapc sZ e Zd ZdZdZdZdZejZ fddZ
dd Zd d
Ze
fddZe
fd
dZ ZS )r z.A string class for supporting $-substitutions.$z(?a:[_a-z][_a-z0-9]*)Nc sr t d| jv r| j}nt| j}| j}| jp| j}d| d| d| d| d }t || j
tjB | _d S )Npatternz
z(?:
(?PzC) | # Escape sequence of two delimiters
(?PzJ) | # delimiter and a Python identifier
{(?Pz)} | # delimiter and a braced identifier
(?P) # Other ill-formed delimiter exprs
)
)super__init_subclass____dict__r _reescape delimiter idpatternbraceidpatterncompileflagsVERBOSE)clsr ZdelimidZbid __class__r r r E s
zTemplate.__init_subclass__c C s
|| _ d S r )template)selfr- r r r __init__W
zTemplate.__init__c C s` | d}| jd | jdd}|sd}d}n|td|d d }t|}td||f )NinvalidT)keepends z.Invalid placeholder in string: line %d, col %d)startr-
splitlineslenr
ValueError)r. moilinescolnolinenor r r _invalid\ s
zTemplate._invalidc : t u r| n|rt| fdd}j|jS )Nc s` | dp | d}|d urt | S | dd urjS | dd ur*| tdjNnamedZbracedZescapedr1 z#Unrecognized named group in pattern)groupstrr# r? r9 r r: rB mappingr. r r convertn s
z$Template.substitute..convert_sentinel_dict _ChainMapr subr- r. rG ZkwsrH r rF r
substituteh s
zTemplate.substitutec r@ )Nc s| | dp | d}|d ur#zt | W S ty" | Y S w | dd ur-jS | dd ur8| S tdjrA )rC rD KeyErrorr# r9 r rE rF r r rH s z)Template.safe_substitute..convertrI rM r rF r safe_substitute{ s
zTemplate.safe_substitute)__name__
__module____qualname____doc__r# r$ r% r!
IGNORECASEr' r r/ r? rJ rN rP
__classcell__r r r+ r r 9 s r c @ sX e Zd Zdd Zdd Z dddZdd Zd
d Zdd
Zdd Z dd Z
dd ZdS )r c O s | |||S r )vformat)r.
format_stringargskwargsr r r format s zFormatter.formatc C s. t }| ||||d\}}| ||| |S )N )set_vformatcheck_unused_args)r. rX rY rZ used_argsresult_r r r rW s zFormatter.vformatr
c C s |dk rt dg }| |D ]^\}} }
}|r|| | d urm| dkr5|du r,t dt|} |d7 }n| rA|r?t dd}| | ||\}}
||
| ||}| j|
||||d |d\}
}|| ||
qd
||fS )Nr
zMax string recursion exceededr4 FzJcannot switch from manual field specification to automatic field numberingr3 )auto_arg_index)r9 parseappendrD isdigit get_fieldadd
convert_fieldr^ format_fieldr )r. rX rY rZ r` Zrecursion_depthrc ra Zliteral_text
field_nameformat_spec
conversionobjZarg_usedr r r r^ s8
zFormatter._vformatc C s t |tr || S || S r )
isinstanceint)r. keyrY rZ r r r get_value s
zFormatter.get_valuec C s d S r r )r. r` rY rZ r r r r_ s zFormatter.check_unused_argsc C s
t ||S r )r[ )r. valuerl r r r rj r0 zFormatter.format_fieldc C sJ |d u r|S |dkrt |S |dkrt|S |dkrt|S td|)Nr raz"Unknown conversion specifier {0!s})rD reprasciir9 r[ )r. rs rm r r r ri s zFormatter.convert_fieldc C s
t |S r )_stringZformatter_parser)r. rX r r r rd r0 zFormatter.parsec C sJ t |\}}| |||}|D ]\}}|rt||}q|| }q||fS r )rx Zformatter_field_name_splitrr getattr) r. rk rY rZ firstrestrn Zis_attrr; r r r rg s
zFormatter.get_fieldN)r
)rQ rR rS r[ rW r^ rr r_ rj ri rd rg r r r r r s
6 r r )rT __all__rx r
r r r r r r r r r rer! collectionsr rK rJ r r r r r r r s&