asda?‰PNG  IHDR ? f ??C1 sRGB ??é gAMA ±? üa pHYs ? ??o¨d GIDATx^íüL”÷e÷Y?a?("Bh?_ò???¢§?q5k?*:t0A-o??¥]VkJ¢M??f?±8\k2íll£1]q?ù???T 3 ]$@sdZddlZddlZddlZdZdZdddZGdddeZGd d d e Z Gd d d e Z Gd dde Z e dkrddlZejejZejedZeeejejdkdS)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) 2009 Stuart Rackham. Free use of this software is granted under the terms of the GNU General Public License (GPL). Nz0.1.2z8.4.1cCsR|dkrtjjdd}x6|jtjD]"}tjj||}tjj|r$|Sq$WdSdS)z= Find file fname in paths. Return None if not found. NPATH)osenvirongetsplitpathseppathjoinisfile)fnamer dirZfpathr!/usr/lib/python3.6/asciidocapi.py find_in_path<s rc@s eZdZdS) AsciiDocErrorN)__name__ __module__ __qualname__rrrrrJsrc@s0eZdZdZgfddZd ddZd ddZdS) Optionsz- Stores asciidoc(1) command options. cCs|dd|_dS)N)values)selfrrrr__init__RszOptions.__init__NcCs|j||dS)zShortcut for append method.N)append)rnamevaluerrr__call__TszOptions.__call__cCs,t|ttfkrt|}|jj||fdS)N)typeintfloatstrrr)rrrrrrrWszOptions.append)N)N)rrr__doc__rrrrrrrrNs  rc@s0eZdZdZddZddZddZdd 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||_tjd|j}|s&td|j|j}t|d|_t|d|_t|dpVd|_|dpfd|_ dS) Nz#^(\d+)\.(\d+)(\.(\d+))?\s*(.*?)\s*$zinvalid version number: %sr0r) stringrematch ValueErrorgroupsrmajorminormicrosuffix)rversionZreor+rrrr|szVersion.__init__cCsL|j|jkrdS|j|jkrH|j|jkr,dS|j|jkrH|j|jkrHdSdS)NTF)r,r-r.)rotherrrr__lt__s     zVersion.__lt__cCsL|j|jkrdS|j|jkrH|j|jkr,dS|j|jkrH|j|jkrHdSdS)NFT)r,r-r.)rr1rrr__le__s     zVersion.__le__cCs,|j|jkr(|j|jkr(|j|jkr(dSdS)NTF)r,r-r.)rr1rrr__eq__s$zVersion.__eq__N)rrrr!rr2r3r4rrrrr"]s    r"c@s.eZdZdZd ddZd ddZd dd ZdS) AsciiDocAPIz AsciiDoc API class. NcCst|_i|_g|_tjjd}|r>tjj|st d|nb|r`|}tjj|st d|n@x>d D]}t |}|rfPqfWx"d D]}tjj|rPqWt dtjj ||_ |j dS) zX Locate and import asciidoc.py. Initialize instance attributes. Z ASCIIDOC_PYzmissing ASCIIDOC_PY file: %szmissing file: %s asciidoc.py asciidoc.pycasciidoczfailed to locate asciidocN)r6r7r8)r6r7r8)roptions attributesmessagesrrrr r rrrealpathcmd_AsciiDocAPI__import_asciidoc)rZ asciidoc_pyr=r rrrrs*      zAsciiDocAPI.__init__FcCs@tjj|jdd krtjjdtjj|jzTy,|rLddl}|j|j nddl }||_ Wn"t k r~t d|jYnXWdtjd=Xny`tj ddkrddl }|jd|j}n0ddl}|jjd|j}|jj|}|jj|||_ Wn$t k rt d|jYnXt|j jttkrr8executer= SystemExitcoder) rZinfileZoutfileZbackendZoptskvsargserrrrYs,      zAsciiDocAPI.execute)N)F)NN)rrrr!rr>rYrrrrr5s ! +r5__main__)Z optionflags)N)r!rCrr(rSrRr Exceptionrobjectrr"r5rZdoctestZNORMALIZE_WHITESPACEELLIPSISr9ZtestmodZ test_resultprintexitZfailedrrrr4s Jr