Ñò ¢ÔëJc@sÛdZddkZddkZddkZdZdZdd„Zdefd„ƒYZ de fd „ƒYZ d e fd „ƒYZ d e fd „ƒYZ edjo0ddkZeieiZeideƒndS(sn 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 StringIO >>> infile = StringIO.StringIO('Hello *{author}*') >>> outfile = StringIO.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 = StringIO.StringIO('Hello _{author}_') >>> outfile = StringIO.StringIO() >>> asciidoc.execute(infile, outfile, backend='docbook') >>> print outfile.getvalue() Hello Bill Smith 2. Check error handling: >>> import StringIO >>> asciidoc = AsciiDocAPI() >>> infile = StringIO.StringIO('---------') >>> outfile = StringIO.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). iÿÿÿÿNs0.1.1s8.4.1cCsx|djotiiddƒ}nxK|itiƒD]3}tii||ƒ}tii|ƒo|Sq9WdSdS(s= Find file fname in paths. Return None if not found. tPATHtN( tNonetostenvirontgettsplittpathseptpathtjointisfile(tfnameRtdirtfpath((sF/Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyt find_in_path=s  t AsciiDocErrorcBseZRS((t__name__t __module__(((sF/Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyRKstOptionscBs2eZdZgd„Zdd„Zdd„ZRS(s- Stores asciidoc(1) command options. cCs||_dS(N(tvalues(tselfR((sF/Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyt__init__SscCs|i||ƒdS(sShortcut for append method.N(tappend(Rtnametvalue((sF/Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyt__call__UscCsCt|ƒttfjot|ƒ}n|ii||fƒdS(N(ttypetinttfloattstrRR(RRR((sF/Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyRXsN(RRt__doc__RRRR(((sF/Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyROs  tVersioncBs eZdZd„Zd„ZRS(s÷ 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' cCs ||_tid|iƒ}|ptd|iƒ‚n|iƒ}t|dƒ|_t|dƒ|_t|dpdƒ|_|dpd|_ dS( Ns#^(\d+)\.(\d+)(\.(\d+))?\s*(.*?)\s*$sinvalid version number: %siiit0iR( tstringtretmatcht ValueErrortgroupsRtmajortminortmicrotsuffix(RtversiontreoR%((sF/Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyR}s  cCset|i|iƒ}|djo?t|i|iƒ}|djot|i|iƒ}qan|S(Ni(tcmpR&R'R((Rtothertresult((sF/Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyt__cmp__‡s   (RRRRR/(((sF/Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyR^s t AsciiDocAPIcBs)eZdZdd„Zddd„ZRS(s AsciiDoc API class. cCsütƒ|_h|_g|_tiidƒ}|o+tii|ƒpt d|ƒ‚q n©|o1|}tii|ƒpt d|ƒ‚q nqxmdddgD]}t |ƒ}|oPqªqªWx;dddgD]}tii|ƒoPqÜqÜWt dƒ‚tii |ƒ}tii |ƒddjot d |ƒ‚nt iid tii|ƒƒz6yd dk}Wntj ot dƒ‚nXWdt id =Xt|iƒttƒjot dttfƒ‚n||_||_dS(sX Locate and import asciidoc.py. Initialize instance attributes. t ASCIIDOC_PYsmissing ASCIIDOC_PY file: %ssmissing file: %ss asciidoc.pys asciidoc.pyctasciidocsfailed to locate asciidoc.py[c]is.pys.pycsinvalid Python module name: %siiÿÿÿÿNsfailed to import asciidocs-asciidocapi %s requires asciidoc %s or better(s.pys.pyc(Rtoptionst attributestmessagesRRRRR RRtrealpathtsplitexttsystinserttdirnameR2t ImportErrorRtVERSIONtMIN_ASCIIDOC_VERSIONt API_VERSIONtcmd(Rt asciidoc_pyR?R R2((sF/Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyR”sJ         c Cs–g|_t|iiƒ}|d j o|d|ƒn|d j o|d|ƒnx}|iiƒD]l\}}|djp|ddjo |}n,|d jo|d}nd||f}|d|ƒqgW|g}tii d t ii |i ƒƒzt |iƒWd tid =Xy8z |ii|i |i|ƒWd |ii|_XWn6tj o*} | iot|idƒ‚q’nXd S( s‹ Compile infile to outfile using backend format. infile can outfile can be file path strings or file like objects. s --out-files --backendRiÿÿÿÿs!@t!s%s=%ss --attributeiN(R5RR3RRR4titemsR8RR9RR:R?treloadR2texecutet SystemExittcodeR( Rtinfiletoutfiletbackendtoptstktvtstargste((sF/Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyRDÄs4       "   N(RRRRRRD(((sF/Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyR0s 0t__main__t optionflags(RR8RR"R>R=RRt ExceptionRtobjectRRR0RtdoctesttNORMALIZE_WHITESPACEtELLIPSISR3ttestmod(((sF/Users/chris/Projects/github_markup/lib/github/commands/asciidocapi.pyt5s$ 2Z