grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a Îña'ã@s²dZddlZddlZddlZdZdZddd„ZGdd„deƒZGd d „d e ƒZ Gd d „d e ƒZ Gd d„de ƒZ e dkr®ddlZejejZejed�Zeeƒe ejdk¡dS)a� asciidocapi - AsciiDoc API wrapper class. The AsciiDocAPI class provides an API for executing asciidoc. Minimal example compiles `mydoc.txt` to `mydoc.html`: import asciidocapi asciidoc = asciidocapi.AsciiDocAPI() asciidoc.execute('mydoc.txt') - Full documentation in asciidocapi.txt. - See the doctests below for more examples. Doctests: 1. Check execution: >>> import io >>> infile = io.StringIO('Hello *{author}*') >>> outfile = io.StringIO() >>> asciidoc = AsciiDocAPI() >>> asciidoc.options('--no-header-footer') >>> asciidoc.attributes['author'] = 'Joe Bloggs' >>> asciidoc.execute(infile, outfile, backend='html4') >>> print(outfile.getvalue())

Hello Joe Bloggs

>>> asciidoc.attributes['author'] = 'Bill Smith' >>> infile = io.StringIO('Hello _{author}_') >>> outfile = io.StringIO() >>> asciidoc.execute(infile, outfile, backend='docbook') >>> print(outfile.getvalue()) Hello Bill Smith 2. Check error handling: >>> import io >>> asciidoc = AsciiDocAPI() >>> infile = io.StringIO('---------') >>> outfile = io.StringIO() >>> asciidoc.execute(infile, outfile) Traceback (most recent call last): File "", line 1, in File "asciidocapi.py", line 189, in execute raise AsciiDocError(self.messages[-1]) AsciiDocError: ERROR: : line 1: [blockdef-listing] missing closing delimiter Copyright (C) 2002-2013 Stuart Rackham. Copyright (C) 2013-2020 AsciiDoc Contributors. Free use of this software is granted under the terms of the GNU General Public License version 2 (GPLv2). éNz0.1.2z8.4.1cCsN|durtj dd¡}| tj¡D]&}tj ||¡}tj |¡r"|Sq"dS)z= Find file fname in paths. Return None if not found. NÚPATHÚ)ÚosÚenvironÚgetÚsplitÚpathsepÚpathÚjoinÚisfile)Úfnamer ÚdirZfpath©rú//usr/lib/python3.9/site-packages/asciidocapi.pyÚ find_in_pathAs  rc@s eZdZdS)Ú AsciiDocErrorN)Ú__name__Ú __module__Ú __qualname__rrrrrOsrc@s0eZdZdZgfdd„Zd dd„Zd dd„ZdS) ÚOptionsz- Stores asciidoc(1) command options. cCs|dd…|_dS©N)Úvalues)ÚselfrrrrÚ__init__WszOptions.__init__NcCs| ||¡dS)zShortcut for append method.N)Úappend©rÚnameÚvaluerrrÚ__call__ZszOptions.__call__cCs,t|ƒttfvrt|ƒ}|j ||f¡dSr)ÚtypeÚintÚfloatÚstrrrrrrrr^szOptions.append)N)N)rrrÚ__doc__rrrrrrrrSs  rc@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) ÚVersiona÷ Parse and compare AsciiDoc version numbers. Instance attributes: string: String version number '.[.][suffix]'. major: Integer major version number. minor: Integer minor version number. micro: Integer micro version number. suffix: Suffix (begins with non-numeric character) is ignored when comparing. Doctest examples: >>> Version('8.2.5') < Version('8.3 beta 1') True >>> Version('8.3.0') == Version('8.3. beta 1') True >>> Version('8.2.0') < Version('8.20') True >>> Version('8.20').major 8 >>> Version('8.20').minor 20 >>> Version('8.20').micro 0 >>> Version('8.20').suffix '' >>> Version('8.20 beta 1').suffix 'beta 1' cCsn||_t d|j¡}|s&td|jƒ‚| ¡}t|dƒ|_t|dƒ|_t|dpVdƒ|_|dpfd|_ dS) Nz#^(\d+)\.(\d+)(\.(\d+))?\s*(.*?)\s*$zinvalid version number: %srééÚ0ér) ÚstringÚreÚmatchÚ ValueErrorÚgroupsr ÚmajorÚminorÚmicroÚsuffix)rÚversionZreor-rrrrƒszVersion.__init__cCsL|j|jkrdS|j|jkrH|j|jkr,dS|j|jkrH|j|jkrHdSdS©NTF©r.r/r0©rÚotherrrrÚ__lt__Žs     zVersion.__lt__cCsL|j|jkrdS|j|jkrH|j|jkr,dS|j|jkrH|j|jkrHdSdS)NFTr4r5rrrÚ__le__›s     zVersion.__le__cCs,|j|jkr(|j|jkr(|j|jkr(dSdSr3r4r5rrrÚ__eq__§s  ÿ þzVersion.__eq__N)rrrr#rr7r8r9rrrrr$ds    r$c@s.eZdZdZd dd„Zd dd„Zd dd „ZdS) Ú AsciiDocAPIz AsciiDoc API class. NcCsètƒ|_i|_g|_tj d¡}|r>tj |¡sÎt d|ƒ‚n�|r`|}tj |¡sÎt d|ƒ‚nntj  tj  t ¡¡}dD]}t ||d�}|rxqÎqxdD]}t |ƒ}|r–qÎq–dD]}tj |¡r°qÎq°t dƒ‚tj  |¡|_| ¡dS)zX Locate and import asciidoc.py. Initialize instance attributes. Z ASCIIDOC_PYzmissing ASCIIDOC_PY file: %szmissing file: %s)z asciidoc.pyz asciidoc.pycÚasciidoc)r zfailed to locate asciidocN)rÚoptionsÚ attributesÚmessagesrrrr r rÚdirnameÚrealpathÚ__file__rÚcmdÚ_AsciiDocAPI__import_asciidoc)rZ asciidoc_pyrBZ this_pathr rrrr´s4     zAsciiDocAPI.__init__Fc Cs4tj |j¡ddvr–tj dtj |j¡¡zZz,|rLddl}| |j ¡nddl }||_ Wn t y|t d|jƒ‚Yn0Wtjd=n tjd=0ntzPddl m }m}ddlm}|d|jƒ}|d|ƒ}||ƒ} |j | ¡| |_ Wn"t �yt d|jƒ‚Yn0t|j jƒttƒk�r0t d ttfƒ‚dS) a  Import asciidoc module (script or compiled .pyc). See http://groups.google.com/group/asciidoc/browse_frm/thread/66e7b59d12cd2f91 for an explanation of why a seemingly straight-forward job turned out quite complicated. r%)z.pyz.pycrNzfailed to import )Úspec_from_loaderÚmodule_from_spec)ÚSourceFileLoaderr;z-asciidocapi %s requires asciidoc %s or better)rr ÚsplitextrBÚsysÚinsertr?Ú importlibÚreloadr;Ú ImportErrorrÚimportlib.utilrDrEÚimportlib.machineryrFÚloaderÚ exec_moduler$ZVERSIONÚMIN_ASCIIDOC_VERSIONÚ API_VERSION) rrKrJr;rDrErFrOÚspecÚmodulerrrZ__import_asciidocás8       ÿÿzAsciiDocAPI.__import_asciidocc Cs$g|_t|jjƒ}|dur$|d|ƒ|dur6|d|ƒ|j ¡D]J\}}|dks\|ddvrb|}n|durt|d}n d||f}|d |ƒq@|g}|jd d �zDz*|j |j |j|¡W|jjdd…|_n|jjdd…|_0Wn<t �y} z"| j �r t |jdƒ‚WYd} ~ n d} ~ 00dS) z‹ Compile infile to outfile using backend format. infile can outfile can be file path strings or file like objects. Nz --out-filez --backendréÿÿÿÿz!@ú!z%s=%sz --attributeT)rK) r>rr<rr=ÚitemsrCr;ÚexecuterBÚ SystemExitÚcoder) rZinfileZoutfileZbackendZoptsÚkÚvÚsÚargsÚerrrrX s,       ,zAsciiDocAPI.execute)N)F)NN)rrrr#rrCrXrrrrr:°s - (r:Ú__main__)Z optionflags)N)r#rHrr*rRrQrÚ ExceptionrÚobjectrr$r:rZdoctestZNORMALIZE_WHITESPACEÚELLIPSISr<ZtestmodZ test_resultÚprintÚexitZfailedrrrrÚs 8 L{