3

T'íc0&ã @sÎdZddlZddlZddlmZmZddlmZddlmZmZm	Z	m
Z
mZmZm
Z
mZddlZddlmZddlmZddlmZdd	lmZdd
lmZddlmZmZmZerÀddlm Z ej!e"ƒZ#Gd
d„deƒZ$Gdd„de$ƒZ%Gdd„dƒZ&e'ee(e'fe'dœdd„Z)ddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d*ddd-d.d/d0d1d2œZ*ej+d3d4j,e*ƒƒZ-ej.j/fee'ee'ee'd5œd6d7„Z0dAe'eee'e'd8œd9d:„Z/e'd;e'd<œd=d>„Z1e'd;e'd<œd?d@„Z2dS)Bz$Builder superclass for all builders.éN)ÚdatetimeÚtimezone)Úpath)Ú
TYPE_CHECKINGÚCallableÚ	GeneratorÚListÚ
NamedTupleÚOptionalÚTupleÚUnion)Úwrite_mo)Úread_po)ÚSphinxError)Ú__)Úlogging)ÚSEPÚ
canon_pathÚrelpath)ÚBuildEnvironmentc@seZdZUeeedS)ÚLocaleFileInfoBaseN)Ú__name__Ú
__module__Ú__qualname__ÚstrÚbase_dirÚdomainÚcharset©rrú2/tmp/pip-build-gk9425m9/sphinx/sphinx/util/i18n.pyrs
rc@sveZdZeedœdd„ƒZeedœdd„ƒZeedœdd„ƒZeedœdd	„ƒZe	dœd
d„Z
dee	d
dœdd„Zd
S)ÚCatalogInfo)ÚreturncCs
|jdS)Nz.po)r)ÚselfrrrÚpo_file!szCatalogInfo.po_filecCs
|jdS)Nz.mo)r)r"rrrÚmo_file%szCatalogInfo.mo_filecCstj|j|jƒS)N)rÚjoinrr#)r"rrrÚpo_path)szCatalogInfo.po_pathcCstj|j|jƒS)N)rr%rr$)r"rrrÚmo_path-szCatalogInfo.mo_pathcCs&tj|jƒp$tj|jƒtj|jƒkS)N)rÚexistsr'Úgetmtimer&)r"rrrÚis_outdated1szCatalogInfo.is_outdatedFN)ÚlocaleÚ	use_fuzzyr!c,CsÄt|j|jdJ}yt||ƒ}Wn4tk
rT}ztjtdƒ|j|ƒdSd}~XnXWdQRXt|jdƒN}yt	|||ƒWn6tk
r´}ztjtdƒ|j|ƒWYdd}~XnXWdQRXdS)N)Úencodingzreading error: %s, %sÚwbzwriting error: %s, %s)
Úopenr&rrÚ	ExceptionÚloggerÚwarningrr'r
)r"r+r,Zfile_poZpoÚexcZfile_morrrr
6szCatalogInfo.write_mo)F)rrrÚpropertyrr#r$r&r'Úboolr*r
rrrrr sr c@s†eZdZdZeeeeeddœdd„Zeeeddfdœdd„ƒZ	eee
eefddfdœd	d
„ƒZeeeddfdœdd„ƒZ
dS)
ÚCatalogRepositoryz"A repository for message catalogs.N)ÚbasedirÚlocale_dirsÚlanguager-r!cCs||_||_||_||_dS)N)r7Ú_locale_dirsr9r-)r"r7r8r9r-rrrÚ__init__HszCatalogRepository.__init__)r!ccs^|js
dSxN|jD]D}tj|j|ƒ}tj||jdƒ}tj|ƒrF|Vqtjtdƒ|ƒqWdS)NÚLC_MESSAGESzlocale_dir %s does not exists)	r9r:rr%r7r(r1Úverboser)r"Ú
locale_dirZlocale_pathrrrr8Os
zCatalogRepository.locale_dirsc	cs”xŽ|jD]„}tj||jdƒ}xntj|ƒD]`\}}}x |D]}|jdƒr8|j|ƒq8Wx2|D]*}|jdƒrZtj||ƒ}|t	||ƒfVqZWq(WqWdS)Nr<Ú.z.po)
r8rr%r9ÚosÚwalkÚ
startswithÚremoveÚendswithr)	r"r>r7ÚrootÚdirnamesÚ	filenamesÚdirnameÚfilenameÚfullpathrrrÚpofiles\s



zCatalogRepository.pofilesccs:x4|jD]*\}}ttj|ƒdƒ}t|||jƒVqWdS)Nr)rKrrÚsplitextr r-)r"r7rIrrrrÚcatalogskszCatalogRepository.catalogs)rrrÚ__doc__rrr;r4rr8rrKr rMrrrrr6Es"r6)ÚdocnameÚ
compactionr!cCs*t|tƒr|S|r"|jtdƒdS|SdS)z'Convert docname to domain for catalogs.érN)Ú
isinstancerÚsplitr)rOrPrrrÚdocname_to_domainrs

rTZEEEZEEEEZMMMZMMMMZmediumÚdÚddÚHZHHÚhÚhhÚDZDDDÚMZMMÚmÚmmÚaÚsÚssZWWÚeÚWZYYZyyyyZzzzZZZZú%)z%az%Az%bz%Bz%cz%-dz%dz%-Hz%Hz%-Iz%Iz%-jz%jz%-mz%mz%-Mz%Mz%pz%-Sz%Sz%Uz%wz%-Wz%Wz%xz%Xz%yz%Yz%Zz%zz%%z(%s)ú|)ÚdateÚformatr+Ú	formatterr!cCsz|dkrd}t|dƒstjj}y||||dSttjjfk
rR|||ddStk
rttj	t
dƒ|ƒ|SXdS)NÚenÚtzinfo)r+z[Invalid date format. Quote the string by single quote if you want to output it directly: %s)ÚhasattrÚbabelÚdatesÚformat_dateÚ
ValueErrorÚcoreZUnknownLocaleErrorÚAttributeErrorr1r2r)rerfr+rgrrrÚbabel_format_date¨s

rq)rfrer9r!c	CsÂ|dkr:tjdƒ}|dk	r*tjt|ƒƒ}ntjtjƒjƒ}g}t	j
|ƒ}xn|D]f}|tkrªtj|dƒ}|dkrxt
jj}n|dkrŠt
jj}nt
jj}|jt||||dƒqN|j|ƒqNWdj|ƒS)NZSOURCE_DATE_EPOCHÚz%xz%X)r+rg)r@ÚgetenvrÚutcfromtimestampÚfloatÚnowrÚutcÚ
astimezoneÚdate_format_rerSÚdate_format_mappingsÚgetrkrlrmZformat_timeÚformat_datetimeÚappendrqr%)	rfrer9Zsource_date_epochÚresultÚtokensÚtokenZbabel_formatÚfunctionrrrrm½s&




rmr)rIÚenvr!cCsò|jjs|S|jj}tƒ}tj|ƒ\|d<|d<tj|dƒ}|rZ|jtjƒrZ|tj7}tj|j	ƒ}|r‚|jtjƒr‚|tj7}||d<tj
|dƒ|d<||d<|jj|d<y|jf|ŽStk
rì}zt
d|ƒ|‚WYdd}~XnXdS)NrEÚextrÚbasenameÚdocpathr9z$Invalid figure_language_filename: %r)Úconfigr9Zfigure_language_filenameÚdictrrLrHrDÚseprOr„rfÚKeyErrorr)rIr‚Zfilename_formatrUrHr…r3rrrÚget_image_filename_for_languageßs&

rŠcCs:|jjs|St||ƒ}|j|ƒ\}}tj|ƒr2|S|SdS)N)r†r9rŠZ
relfn2pathrr()rIr‚Z
translatedÚ_ÚabspathrrrÚsearch_image_for_languageös

r)NN)3rNr@ÚrerrrÚtypingrrrrr	r
rrZbabel.datesrkZbabel.messages.mofiler
Zbabel.messages.pofilerZ
sphinx.errorsrZ
sphinx.localerZsphinx.utilrZsphinx.util.osutilrrrZsphinx.environmentrÚ	getLoggerrr1rr r6rr5rTrzÚcompiler%ryrlrmrqrŠrrrrrÚ<module>sn(
&-""