Sindbad~EG File Manager

Current Path : /usr/lib/python3.6/site-packages/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/__pycache__/asciidocapi.cpython-36.pyc

3

���]�$�@s�dZddlZddlZddlZdZdZddd�ZGdd�de�ZGd	d
�d
e	�Z
Gdd�de	�ZGd
d�de	�Ze
dkr�ddlZejejZejed�Zee�ejejdk�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())
   <p>Hello <strong>Joe Bloggs</strong></p>

   >>> asciidoc.attributes['author'] = 'Bill Smith'
   >>> infile = io.StringIO('Hello _{author}_')
   >>> outfile = io.StringIO()
   >>> asciidoc.execute(infile, outfile, backend='docbook')
   >>> print(outfile.getvalue())
   <simpara>Hello <emphasis>Bill Smith</emphasis></simpara>

2. Check error handling:

   >>> import io
   >>> asciidoc = AsciiDocAPI()
   >>> infile = io.StringIO('---------')
   >>> outfile = io.StringIO()
   >>> asciidoc.execute(infile, outfile)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "asciidocapi.py", line 189, in execute
       raise AsciiDocError(self.messages[-1])
   AsciiDocError: ERROR: <stdin>: 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|jtj�D]"}tjj||�}tjj|�r$|Sq$WdSdS)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.6/asciidocapi.py�find_in_path<src@seZdZdS)�
AsciiDocErrorN)�__name__�
__module__�__qualname__rrrrrJsrc@s0eZdZdZgfdd�Zd	dd�Zd
dd�ZdS)�Optionsz-
    Stores asciidoc(1) command options.
    cCs|dd�|_dS)N)�values)�selfrrrr�__init__RszOptions.__init__NcCs|j||�dS)zShortcut for append method.N)�append)r�name�valuerrr�__call__TszOptions.__call__cCs,t|�ttfkrt|�}|jj||f�dS)N)�type�int�float�strrr)rrrrrrrWszOptions.append)N)N)rrr�__doc__rrrrrrrrNs
rc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�Versiona�
    Parse and compare AsciiDoc version numbers. Instance attributes:

    string: String version number '<major>.<minor>[.<micro>][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: %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-r.)r�otherrrr�__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
dd�Zddd�Zddd	�ZdS)
�AsciiDocAPIz
    AsciiDoc API class.
    NcCs�t�|_i|_g|_tjjd�}|r>tjj|�s�t	d|��nb|r`|}tjj|�s�t	d|��n@x>d	D]}t
|�}|rfPqfWx"d
D]}tjj|�r�Pq�Wt	d��tjj|�|_|j
�dS)zX
        Locate and import asciidoc.py.
        Initialize instance attributes.
        ZASCIIDOC_PYzmissing ASCIIDOC_PY file: %szmissing file: %s�asciidoc.py�asciidoc.pyc�asciidoczfailed to locate asciidocN)r6r7r8)r6r7r8)r�options�
attributes�messagesrrrr	rrr�realpath�cmd�_AsciiDocAPI__import_asciidoc)rZasciidoc_pyr=rrrrr�s*

zAsciiDocAPI.__init__FcCs@tjj|j�dd
kr�tjjdtjj|j��zTy,|rLddl}|j|j	�nddl	}||_	Wn"t
k
r~td|j��YnXWdtjd=Xn�y`tjddkr�ddl
}|jd|j�}n0ddl}|jjd|j�}|jj|�}|jj|�||_	Wn$t
k
�rtd|j��YnXt|j	j�tt�k�r<td	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#�.py�.pycrNzfailed to import �r8z-asciidocapi %s requires asciidoc %s or better)r?r@)rr	�splitextr=�sys�insert�dirname�	importlib�reloadr8�ImportErrorr�version_info�impZload_source�importlib.util�util�spec_from_file_location�module_from_spec�loader�exec_moduler"�VERSION�MIN_ASCIIDOC_VERSION�API_VERSION)rrGrFr8rJ�module�specrrrZ__import_asciidoc�s6

zAsciiDocAPI.__import_asciidocc
Csg|_t|jj�}|dk	r$|d|�|dk	r6|d|�xX|jj�D]J\}}|dks^|ddkrd|}n|dkrv|d}nd||f}|d	|�qBW|g}|jd
d�y2z|jj|j	|j|�Wd|jjdd�|_XWn:t
k
�r}	z|	j�r�t|jd
��WYdd}	~	XnXdS)z�
        Compile infile to outfile using backend format.
        infile can outfile can be file path strings or file like objects.
        Nz
--out-filez	--backendrr#z!@�!z%s=%sz--attributeT)rG���rW)
r;rr9rr:�itemsr>r8�executer=�
SystemExit�coder)
rZinfileZoutfileZbackendZopts�k�v�s�args�errrrY�s,


zAsciiDocAPI.execute)N)F)NN)rrrr!rr>rYrrrrr5�s
!
+r5�__main__)Zoptionflags)N)r!rCrr(rSrRr�	Exceptionr�objectrr"r5rZdoctestZNORMALIZE_WHITESPACE�ELLIPSISr9ZtestmodZtest_result�print�exitZfailedrrrr�<module>4s
Jr

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists