B >:H@sHdZddlZddlmZddlmZddZddZd d Zd d Z dS) z Escape the `body` part of .chm source file to 7-bit ASCII, to fix visual effect on some MBCS Windows systems. https://bugs.python.org/issue32174 N)codepoint2name) getLoggercCsdd}td||S)NcSs4t|d}t|}|dkr(d|Sd|SdS)Nrz&#%d;z&%s;)ordgrouprget)ZmatchobjZ codepointnamerD/opt/alt/python37/lib64/python3.7/Doc/tools/extensions/escape4chm.pyescapes  z_process..escapez [^\x00-\x7F])resub)stringr rrr _processs rcCs8t|jdddkrdS|d}|dk r4t||d<dS)Nrhtmlhelpbody)getattrbuilderrr)appZpagenameZ templatenamecontextZdoctreerrrr escape_for_chms  rc Cst|jdddks|rdSttd|jj}|jjj}|j||dd}| }WdQRX|j||dd}| | dd WdQRXdS) Nrrrz'fixing HTML escapes in keywords file...z.hhkrwz'z') rrr__name__infooutdirZconfigZhtmlhelp_basenameZ open_filereadwritereplace)rZ exceptionrZoutnamefindexrrr fixup_keywords$s r!cCs"|dt|dtdddS)Nzhtml-page-contextzbuild-finishedz1.0T)versionZparallel_read_safe)Zconnectrr!)rrrr setup1s  r#) __doc__r Z html.entitiesrZsphinx.util.loggingrrrr!r#rrrr s