B
    Åû_«/  ã               @   sÞ   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z
dddddddd	d
dœ	ZejdejdejdejdejdejdejdiZddddddœZdZdd„ Ze d¡ZG dd„ dejƒZe eƒ ¡ dS )é    NzO(?mx)
          ^(?P<match>
          @include\s+
           (?P<filename>\S+))z¾(?smx)
          ^[^\n]*?(?!@c\s+)[^\n]*?
          (?P<match>
          @lilypond\s*(
          \[
           \s*(?P<options>.*?)\s*
          \])?\s*{
           (?P<code>.*?)
          })z­(?msx)
          ^(?P<match>
          @lilypond\s*(
          \[
           \s*(?P<options>.*?)\s*
          \])?\s+?
          ^(?P<code>.*?)
          ^@end\s+lilypond)\sz£(?mx)
          ^(?P<match>
          @lilypondfile\s*(
          \[
           \s*(?P<options>.*?)\s*
          \])?\s*{
           (?P<filename>\S+)
          })zs(?smx)
          ^(?P<match>
           (?P<code>
           @ignore\s
            .*?
           @end\s+ignore))\sz£(?mx)
          ^(?P<match>
          @musicxmlfile\s*(
          \[
           \s*(?P<options>.*?)\s*
          \])?\s*{
           (?P<filename>\S+)
          })z](?mx)
          ^.*
          (?P<match>
           (?P<code>
           @c([ \t][^\n]*|)\n))zs(?sx)
          (?P<match>
           (?P<code>
           @example
            \s.*?
           @end\s+example\s))zB(?mx)
         [^@](?P<match>
          @lilypondversion)[^a-zA-Z])	ZincludeZlilypondZlilypond_blockZlilypond_fileZmultiline_commentZmusicxml_fileZsingleline_commentZverbatimZlilypondversionz,@lilypond[%(options)s]
%(code)s@end lilypondz2
@iftex
@include %(base)s-systems.texi
@end iftex
zÕ@noindent
@ifinfo
@image{%(info_image_path)s,,,%(alt)s,}
@end ifinfo
@html
<p>
 <a href="%(base)s%(ext)s">
  <img align="middle"
       border="0"
       src="%(image)s"
       alt="%(alt)s">
 </a>
</p>
@end html
zY
@html
<a href="%(base)s%(ext)s">
@end html
@file{%(filename)s}
@html
</a>
@end html
    z!@quotation
%(str)s@end quotation
z @verbatim
%(verb)s@end verbatim
z%(program_version)sz160\mmz6.5\inz150\mmz5\inz6\in)z@afourpaperz
@afourwidez@afourlatexz
@smallbookz@letterpaperz°
\input texinfo
@setfilename Texinfo_width_test
@settitle Texinfo width test
%(preamble)s

@message{Global: textwidth=@the@hsize,exampleindent=@the@lispnarrowing}

dummy

@bye
c             C   s®  d }d}t  || ¡}|r"| d¡}d}t  || ¡}|rB| d|¡ d |¡}td|i }t d¡\}}	t	j
 |	¡d d }
t|d	d
d}| |¡ | ¡  t tdƒ|	 ¡ d|j|
|	f }t d| ¡ t	j ¡ }d|d< d}tjdkrZd}t ¡ }t	j
 |d¡}|d| 7 }t	 |¡}t|d
d ¡ }|dkrDt tdƒ¡ t	 |¡ t	 |¡ nDtj|||dtj tj d}| !¡ \}}|j"dkržt tdƒ| ¡ t	 #|	¡ t	j
 $|
¡rÀt	 #|
¡ d}t  d|¡}|rt%| d¡ƒd }|r| &d¡rdt'|d dƒ }ndt'|dƒ }nt( )|d ¡}d}t  d!|¡}|rˆt%| d¡ƒd }|rx| &d¡rxdt'|d dƒ }ndt'|dƒ }nd"}t*j+|t*j,|i}t d#| ¡ |S )$NzG(@(?:afourpaper|afourwide|afourlatex|afivepaper|smallbook|letterpaper))é   z9(@(?:fonttextsize|pagesizes|cropmarks|exampleindent).*)\nr   Ú
Úpreamblez.texiz.pdfÚwÚutf8)Úencodingz=Running texi2pdf on file %s to detect default page settings.
z%s --batch -c -o %s %szExecuting: %s
ÚCÚLC_ALLTZmingw32Fz
output.txtz > %sz(Unable to auto-detect default settings:
)ÚenvÚuniversal_newlinesÚshellÚstdoutÚstderrz*Unable to auto-detect default settings:
%sztextwidth=([0-9.]+)ptgáz®GR@z@afourz%g\mmgffffff9@é   z%g\inz6\inzexampleindent=([0-9.]+)ptz0.4\inzAuto-detected values are: %s
)-ÚreÚsearchÚgroupÚfindallÚinsertÚjoinÚTEXINFO_INSPECTION_DOCUMENTÚtempfileZmkstempÚosÚpathÚsplitextÚopenÚwriteÚcloseÚlyZprogressÚ_Ztexinfo_programZdebug_outputÚenvironÚcopyÚsysÚplatformZmkdtempÚsystemÚreadZwarningÚremoveÚrmdirÚ
subprocessÚPopenÚPIPEZcommunicateÚ
returncodeÚunlinkÚexistsÚfloatÚ
startswithÚroundÚtexinfo_line_widthsÚgetÚbook_snippetsZ
LINE_WIDTHZEXAMPLEINDENT)ÚsourceÚglobal_optionsZpagesizeZtexinfo_paper_size_regexpÚmZrelevant_settings_regexpr   Ztexinfo_documentZhandleZtmpfileZoutfileZ
tmp_handleÚcmdZrun_envr   Ú
output_dirZoutput_filenamer+   Zparameter_stringÚprocZerror_stringZ	textwidthÚvalZexampleindentZretval© r;   ún/home/gub/NewGub/gub/target/mingw/src/lilypond-git.sv.gnu.org--lilypond.git-stable-2.22/python/book_texinfo.pyÚget_texinfo_width_indentÁ   s†    










r=   z!(?m)^@documentlanguage (.*?)( |$)c               @   sT   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ ZdS )ÚBookTexinfoOutputFormatc             C   s<   t j | ¡ d| _d| _t| _t| _ddddg| _	d| _
d S )NZtexinfoz.texiz.itelyz.telyz.texinfoz\s*,\s*)Ú	book_baseÚBookOutputFormatÚ__init__ÚformatZdefault_extensionÚTexInfo_snippet_resZsnippet_resÚTexInfo_outputÚoutputZhandled_extensionsZsnippet_option_separator)Úselfr;   r;   r<   rA   +  s    z BookTexinfoOutputFormat.__init__c             C   s   t j | |¡p|dkS )N)z	texi-htmlZtexi)r?   r@   Úcan_handle_format)rF   rB   r;   r;   r<   rG   4  s    z)BookTexinfoOutputFormat.can_handle_formatc             C   s   |   |¡ d S )N)Zprocess_options_pdfnotdefault)rF   r5   r;   r;   r<   Úprocess_options8  s    z'BookTexinfoOutputFormat.process_optionsc             C   s0   t  |¡}|r(| d¡ d¡s(| d¡S dS d S )Nr   ZenÚ )Útexinfo_lang_rer   r   r/   )rF   r4   r6   r;   r;   r<   Úget_document_language;  s    

z-BookTexinfoOutputFormat.get_document_languagec             C   s*   t || jƒ}| j |¡ tj | |¡ d S )N)r=   r5   Zdefault_snippet_optionsÚupdater?   r@   Úinit_default_snippet_options)rF   r4   Ztexinfo_defaultsr;   r;   r<   rM   B  s    
z4BookTexinfoOutputFormat.init_default_snippet_optionsc             C   s   d|kr|d S |S d S )Nz	--formatsz --formats=png r;   )rF   r7   r;   r;   r<   Úadjust_snippet_commandH  s    z.BookTexinfoOutputFormat.adjust_snippet_commandc             C   s¾   d}|  ¡ }||d< tj |j¡|d< |j|d< xt| ¡ D ]h}t |¡}tj |¡d |d< ||d< |j	t
j |d< tj | jj|d ¡|d< || jt
j | 7 }q:W || jt
j | 7 }|S )	NrI   ÚbaseÚfilenameÚextr   ÚimageZaltZinfo_image_path)Úget_replacementsr   r   ÚbasenamerP   rQ   Z
get_imagesr!   r   Úoption_dictr3   ZALTr   r5   Zinfo_images_dirrE   ÚOUTPUTIMAGEÚOUTPUT)rF   rT   ÚsnippetÚsÚreprR   Zrep1r;   r;   r<   Úoutput_infoN  s    

z#BookTexinfoOutputFormat.output_infoc                sJ  ‡ fdd„}d}|}t j|jkrt|d }|ˆ j }x@||gD ]4}||ƒ}	|	r<|dt |	dd¡ ¡  dd	¡ 7 }P q<W t j|jkr¾|d
 }
|
ˆ j }x*||
gD ]}||ƒ}	|	rœ|d| 7 }P qœW |ˆ  	||¡7 }d}| 
¡ }t j|jkr| ¡ |d< ˆ jt j | }|ˆ  ||¡7 }t j|jkr6ˆ jt j d|i }||7 }|d7 }|S )Nc                s&   t j ˆ jj| ¡}t j |¡r"|S dS )NrI   )r   r   r   r5   r8   r-   )ÚfnÚp)rF   r;   r<   Úfinda  s    z4BookTexinfoOutputFormat.snippet_output.<locals>.findrI   z	.doctitlez
@lydoctitle %s

Úrzutf-8ú,z@comma{}z.texidocz@include %s

ZverbÚstrr   )r3   ZDOCTITLErU   Zdocument_languageÚcodecsr   r%   ÚreplaceZTEXIDOCZoutput_print_filenamerS   ÚVERBATIMZverb_lyrE   r[   ÚQUOTE)rF   rT   rX   r^   rY   rO   ZdoctitleZtranslated_doctitleÚtZfullpathZtexidocZtranslated_texidocZsubstrrZ   r;   )rF   r<   Úsnippet_output`  s@    

z&BookTexinfoOutputFormat.snippet_outputc             C   s   |   ||||¡S )N)Zrequired_files_png)rF   rX   rO   ZfullÚrequired_filesr;   r;   r<   rh     s    z&BookTexinfoOutputFormat.required_filesN)Ú__name__Ú
__module__Ú__qualname__rA   rG   rH   rK   rM   rN   r[   rg   rh   r;   r;   r;   r<   r>   *  s   	-r>   )rb   r!   r   r   r(   r"   r   r?   r3   Zlilylibr   rC   ZFILTERrW   rV   ZPRINTFILENAMEre   rd   ZVERSIONrD   r1   r   r=   ÚcompilerJ   r@   r>   Zregister_formatr;   r;   r;   r<   Ú<module>   sR   
			

f
g