
Qc           @   sk  d  Z  d 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 m	 Z	 m
 Z
 d d l m Z d d l Z d d l m Z m Z d e	 f d     YZ d	 e	 f d
     YZ d d8 d     YZ d e
 f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d   Z d   Z d   Z d e
 f d     YZ d   Z d   Z d   Z d d  Z d   Z  d   Z! d d   Z" d!   Z# d"   Z$ d#   Z% d$   Z& d%   Z' e( d&  Z) d'   Z* d(   Z+ d)   Z, i d* d+ 6d* d, 6d- d. 6d- d/ 6d- d0 6d- d1 6Z- d2   Z. d3   Z/ d4   Z0 d5   Z1 d6 e2 f d7     YZ3 d S(9   s:   
Miscellaneous utilities for the documentation utilities.
t   reStructuredTextiN(   t   ApplicationErrort	   DataError(   t   nodes(   t   ErrorOutputt
   SafeStringt   SystemMessagec           B   s   e  Z d    Z RS(   c         C   s#   t  j |  | j    | |  _ d  S(   N(   t	   Exceptiont   __init__t   astextt   level(   t   selft   system_messageR
   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyR      s    (   t   __name__t
   __module__R   (    (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyR      s   t   SystemMessagePropagationc           B   s   e  Z RS(    (   R   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyR      s    t   Reporterc           B   s   e  Z d  Z d j   Z e d  \ Z Z Z Z	 Z
 d e d d d  Z d e d  Z d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z RS(   sq  
    Info/warning/error reporter and ``system_message`` element generator.

    Five levels of system messages are defined, along with corresponding
    methods: `debug()`, `info()`, `warning()`, `error()`, and `severe()`.

    There is typically one Reporter object per process.  A Reporter object is
    instantiated with thresholds for reporting (generating warnings) and
    halting processing (raising exceptions), a switch to turn debug output on
    or off, and an I/O stream for warnings.  These are stored as instance
    attributes.

    When a system message is generated, its level is compared to the stored
    thresholds, and a warning or error is generated as appropriate.  Debug
    messages are produced if the stored debug switch is on, independently of
    other thresholds.  Message output is sent to the stored warning stream if
    not set to ''.

    The Reporter class also employs a modified form of the "Observer" pattern
    [GoF95]_ to track system messages generated.  The `attach_observer` method
    should be called before parsing, with a bound method or function which
    accepts system messages.  The observer can be removed with
    `detach_observer`, and another added in its place.

    .. [GoF95] Gamma, Helm, Johnson, Vlissides. *Design Patterns: Elements of
       Reusable Object-Oriented Software*. Addison-Wesley, Reading, MA, USA,
       1995.
    s   DEBUG INFO WARNING ERROR SEVEREi   t   backslashreplacec         C   s   | |  _  | |  _ | |  _ | |  _ | |  _ t | t  sQ t | | |  } n  | |  _ | po t | d d  |  _	 g  |  _
 d |  _ d S(   s7  
        :Parameters:
            - `source`: The path to or description of the source data.
            - `report_level`: The level at or above which warning output will
              be sent to `stream`.
            - `halt_level`: The level at or above which `SystemMessage`
              exceptions will be raised, halting execution.
            - `debug`: Show debug (level=0) system messages?
            - `stream`: Where warning output is sent.  Can be file-like (has a
              ``.write`` method), a string (file name, opened for writing),
              '' (empty string) or `False` (for discarding all stream messages)
              or `None` (implies `sys.stderr`; default).
            - `encoding`: The output encoding.
            - `error_handler`: The error handler for stderr output encoding.
        t   encodingt   asciiiN(   t   sourcet   error_handlert
   debug_flagt   report_levelt
   halt_levelt
   isinstanceR   t   streamt   getattrR   t	   observerst	   max_level(   R   R   R   R   R   t   debugR   R   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyR   K   s    								c         C   sh   t  j d t d d | |  _ | |  _ t | t  sR t | |  j |  j  } n  | |  _	 | |  _
 d  S(   Nsh   docutils.utils.Reporter.set_conditions deprecated; set attributes via configuration settings or directlyt
   stackleveli   (   t   warningst   warnt   DeprecationWarningR   R   R   R   R   R   R   R   (   R   t   categoryR   R   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   set_conditions~   s    				c         C   s   |  j  j |  d S(   s   
        The `observer` parameter is a function or bound method which takes one
        argument, a `nodes.system_message` instance.
        N(   R   t   append(   R   t   observer(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   attach_observer   s    c         C   s   |  j  j |  d  S(   N(   R   t   remove(   R   R&   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   detach_observer   s    c         C   s"   x |  j  D] } | |  q
 Wd  S(   N(   R   (   R   t   messageR&   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   notify_observers   s    c   	      O   s  t  | t  r t |  } n  | j   } d | k r t | d  \ } } | d =| d k	 rr | j d |  n  | d k	 r | j d |  q n  d | k ry" |  j | j d   \ } } Wn t	 k
 r d \ } } n X| d k	 r | | d <n  | d k	 r| | d <qn  | j d |  j
  t j | d | d |  j | | | } |  j r| |  j k s|  j r| |  j k s| |  j k r|  j j | j   d  n  | |  j k rt | |   n  | |  j k s|  j r|  j |  n  t | |  j  |  _ | S(	   ss   
        Return a system_message object.

        Raise an exception or generate a warning if appropriate.
        t	   base_nodeR   t   lineR
   t   types   
N(   NN(   R   R   R   t   copyt   get_source_linet   Nonet
   setdefaultt   get_source_and_linet   gett   AttributeErrorR   R   R   t   levelsR   R   R   t   DEBUG_LEVELR   t   writeR	   R   R+   t   maxR   (	   R   R
   R*   t   childrent   kwargst
   attributesR   R-   t   msg(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyR      sB    "
c         O   s#   |  j  r |  j |  j | |  Sd S(   s   
        Level-0, "DEBUG": an internal reporting issue. Typically, there is no
        effect on the processing. Level-0 system messages are handled
        separately from the others.
        N(   R   R   R7   (   R   t   argsR;   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyR      s    	c         O   s   |  j  |  j | |  S(   s   
        Level-1, "INFO": a minor issue that can be ignored. Typically there is
        no effect on processing, and level-1 system messages are not reported.
        (   R   t
   INFO_LEVEL(   R   R>   R;   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   info   s    c         O   s   |  j  |  j | |  S(   s   
        Level-2, "WARNING": an issue that should be addressed. If ignored,
        there may be unpredictable problems with the output.
        (   R   t   WARNING_LEVEL(   R   R>   R;   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   warning   s    c         O   s   |  j  |  j | |  S(   sz   
        Level-3, "ERROR": an error that should be addressed. If ignored, the
        output will contain errors.
        (   R   t   ERROR_LEVEL(   R   R>   R;   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   error   s    c         O   s   |  j  |  j | |  S(   s   
        Level-4, "SEVERE": a severe error that must be addressed. If ignored,
        the output will contain severe errors. Typically level-4 system
        messages are turned into exceptions which halt processing.
        (   R   t   SEVERE_LEVEL(   R   R>   R;   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   severe   s    N(   R   R   t   __doc__t   splitR6   t   rangeR7   R?   RA   RC   RE   R1   t   FalseR   R$   R'   R)   R+   R   R   R@   RB   RD   RF   (    (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyR   "   s   3				/					t   ExtensionOptionErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyRK      s    t   BadOptionErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyRL      s    t   BadOptionDataErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyRM      s    t   DuplicateOptionErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyRN      s    c         C   s   t  |   } t | |  } | S(   sC  
    Return a dictionary mapping extension option names to converted values.

    :Parameters:
        - `field_list`: A flat field list without field arguments, where each
          field body consists of a single paragraph only.
        - `options_spec`: Dictionary mapping known option names to a
          conversion function such as `int` or `float`.

    :Exceptions:
        - `KeyError` for unknown option names.
        - `ValueError` for invalid option values (raised by the conversion
           function).
        - `TypeError` for invalid option value types (raised by conversion
           function).
        - `DuplicateOptionError` for duplicate options.
        - `BadOptionError` for invalid fields.
        - `BadOptionDataError` for invalid option data (missing name,
          missing data, bad quotes, etc.).
    (   t   extract_optionst   assemble_option_dict(   t
   field_listt   options_spect   option_listt   option_dict(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   extract_extension_options   s    c         C   s!  g  } x|  D]} t  | d j   j    d k rD t d   n  t | d j   j    } | d } t  |  d k r d } n t  |  d k s t | d t j	  s t  | d  d k s t | d d t j
  r t d |   n | d d j   } | j | | f  q W| S(   s  
    Return a list of option (name, value) pairs from field names & bodies.

    :Parameter:
        `field_list`: A flat field list, where each field name is a single
        word and each field body consists of a single paragraph only.

    :Exceptions:
        - `BadOptionError` for invalid fields.
        - `BadOptionDataError` for invalid option data (missing name,
          missing data, bad quotes, etc.).
    i    i   s:   extension option field name may not contain multiple wordssM   extension option field body may contain
a single paragraph only (option "%s")N(   t   lenR	   RH   RL   t   strt   lowerR1   R   R   t	   paragrapht   TextRM   R%   (   RQ   RS   t   fieldt   namet   bodyt   data(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyRO     s"    "
	)1c         C   s   i  } x |  D] \ } } | | } | d k r> t |   n  | | k r] t d |   n  y | |  | | <Wq t t f k
 r } | j d | | d j | j  f   q Xq W| S(   sa  
    Return a mapping of option names to values.

    :Parameters:
        - `option_list`: A list of (name, value) pairs (the output of
          `extract_options()`).
        - `options_spec`: Dictionary mapping known option names to a
          conversion function such as `int` or `float`.

    :Exceptions:
        - `KeyError` for unknown option names.
        - `DuplicateOptionError` for duplicate options.
        - `ValueError` for invalid option values (raised by conversion
           function).
        - `TypeError` for invalid option value types (raised by conversion
           function).
    s   duplicate option "%s"s   (option: "%s"; value: %r)
%st    N(   R1   t   KeyErrorRN   t
   ValueErrort	   TypeErrort	   __class__t   joinR>   (   RS   RR   t   optionsR\   t   valuet	   convertort   detail(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyRP   -  s    
	't   NameValueErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyRi   N  s    c         C   s   t  |  t  r |  Sy |  j t j   d  }  Wng t k
 rL t j |   St k
 r y |  j d d  }  Wq t k
 r |  j d d  }  q Xn Xt j |   S(   s   
    Ensure `path` is Unicode. Return `nodes.reprunicode` object.

    Decode file/path string in a failsave manner if not already done.
    t   stricts   utf-8R   t   replace(	   R   t   unicodet   decodet   syst   getfilesystemencodingR5   R   t   reprunicodet   UnicodeDecodeError(   t   path(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   decode_pathQ  s    c         C   s  g  } x|  r|  j  d  } | d k r9 t d   n  |  |  j   } | d k s\ | rk t d   n  |  | d j   }  |  s t d |   n  |  d d k rR|  j  |  d d  } | d k r t d	 | |  d f   n  t |   | d k r.|  | d j   r.t d
 | |  d f   n  |  d | !} |  | d j   }  nH |  j  d  } | d k r||  } d }  n |  |  } |  | d j   }  | j | j   | f  q	 W| S(   s   
    Return a list of (name, value) from a line of the form "name=value ...".

    :Exception:
        `NameValueError` for invalid input (missing name, missing data, bad
        quotes, etc.).
    t   =is   missing "="i    s!   missing attribute name before "="i   s   missing value after "%s="s   '"s%   attribute "%s" missing end quote (%s)s8   attribute "%s" end quote (%s) not followed by whitespaceR_   t    (   t   findRi   t   stript   lstripRV   R%   RX   (   R-   t   attlistt   equalst   attnamet   endquoteR^   t   space(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   extract_name_valuef  sB    	*	
c         C   s@   t  |  | j | j d | j d | j d | j d | j } | S(   s   
    Return a new Reporter object.

    :Parameters:
        `source` : string
            The path to or description of the source text of the document.
        `settings` : optparse.Values object
            Runtime settings.
    R   R   R   R   (   R   R   R   t   warning_streamR   t   error_encodingt   error_encoding_error_handler(   t   source_patht   settingst   reporter(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   new_reporter  s    
	c         C   sx   d d l  m } | d k r1 | j   j   } n  t |   }  t |  |  } t j | | d |  } | j	 |  d  | S(   s  
    Return a new empty document object.

    :Parameters:
        `source_path` : string
            The path to or description of the source text of the document.
        `settings` : optparse.Values object
            Runtime settings.  If none are provided, a default core set will
            be used.  If you will use the document object with any Docutils
            components, you must provide their default settings as well.  For
            example, if parsing, at least provide the parser settings,
            obtainable as follows::

                settings = docutils.frontend.OptionParser(
                    components=(docutils.parsers.rst.Parser,)
                    ).get_default_values()
    i(   t   frontendR   N(
   t   docutilsR   R1   t   OptionParsert   get_default_valuesRs   R   R   t   documentt   note_source(   R   R   R   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   new_document  s    c         C   s   t  |   d k r t |  d t j  r |  d } xO | D]D \ } } | j |  } | r9 t j | j | |   |  d <d  Sq9 Wn  d  S(   Ni   i    (   RV   R   R   RZ   t   searcht   sub(   RY   t   keyword_substitutionst   textnodet   patternt   substitutiont   match(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   clean_rcs_keywords  s    (
c         C   s   t  j j |  p t |  d   j t  j  } t  j j |  j t  j  } | d  | d  k ro d j |  S| j   | j   x8 | r | r | d | d k r | j   | j   q W| j   d g t	 |  d | } d j |  S(   s   
    Build and return a path to `target`, relative to `source` (both files).

    If there is no common prefix, return the absolute path to `target`.
    t
   dummy_filei   t   /is   ..i   (
   t   osRr   t   abspathR.   RH   t   sepRd   t   reverset   popRV   (   R   t   targett   source_partst   target_partst   parts(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   relative_path  s    $



c         C   sR   |  j  rG |  j s t d   | d k r7 |  j } n  t | |  j   S|  j Sd S(   s   
    Retrieve a stylesheet reference from the settings object.

    Deprecated. Use get_stylesheet_list() instead to
    enable specification of multiple stylesheets as a comma-separated
    list.
    s6   stylesheet and stylesheet_path are mutually exclusive.N(   t   stylesheet_patht
   stylesheett   AssertionErrorR1   t   _destinationR   (   R   t   relative_to(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   get_stylesheet_reference  s    		c         C   s   |  j  o |  j s t d   |  j p4 |  j  p4 g  } t | t  sq g  | j d  D] } | j   ^ qV } n  g  | D] } t | |  j  ^ qx S(   sJ   
    Retrieve list of stylesheet references from the settings object.
    s6   stylesheet and stylesheet_path are mutually exclusive.t   ,(	   R   R   R   R   t   listRH   Rw   t   find_file_in_dirst   stylesheet_dirs(   R   t   stylesheetsRr   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   get_stylesheet_list  s    	+c         C   s}   t  j j |   r |  Sx` | D]X } | d k r8 |  } n' t  j j |  } t  j j | |   } t  j j |  r | Sq W|  S(   s}   
    Search for `path` in the list of directories `dirs`.

    Return the first expansion that matches an existing file.
    t   .(   R   Rr   t   isabst
   expanduserRd   t   exists(   Rr   t   dirst   dt   f(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyR   	  s    	c         C   s6   |  j  d k r+ t |  d  o* |  j d k S|  j  Sd S(   s   
    Return whether or not to trim footnote space.

    If trim_footnote_reference_space is not None, return it.

    If trim_footnote_reference_space is None, return False unless the
    footnote reference style is 'superscript'.
    t   footnote_referencest   superscriptN(   t   trim_footnote_reference_spaceR1   t   hasattrR   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   get_trim_footnote_ref_space  s    	c         C   s<   x5 |  r7 |  j  s |  j r+ |  j  |  j f S|  j }  q Wd S(   sk   
    Return the "source" and "line" attributes from the `node` given or from
    its closest ancestor.
    N(   NN(   R   R-   t   parentR1   (   t   node(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyR0   *  s
    	c         C   s   g  } d } x t  r |  j d |  } | d k rQ | j |  |  d j |  S| j |  | | ! | j d |  | d | d ! | d } q Wd S(	   s;   Return a string with escape-backslashes converted to nulls.i    s   \iRu   t    i   i   N(   t   TrueRv   R%   Rd   (   t   textR   t   startt   found(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   escape2null5  s    	 c         C   sP   | r |  j  d d  Sx/ d d d g D] } d j |  j |   }  q& W|  Sd S(   sw   
    Return a string with nulls removed or restored to backslashes.
    Backslash-escaped spaces are also removed.
    R   s   \t     t    
Ru   N(   Rk   Rd   RH   (   R   t   restore_backslashesR   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   unescapeB  s
    c         C   sQ   t  |  t  r" t j d k  r" |  Sd j g  |  D] } t j |  s/ | ^ q/  S(   Ni   i    u    (   i   i    (   R   RW   Rn   t   version_infoRd   t   unicodedatat	   combining(   R   t   c(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   strip_combining_charsN  s    c         C   sT   t  |  t  r" t j d k  r" g  Sg  t |   D]! \ } } t j |  r/ | ^ q/ S(   s   Return indices of all combining chars in  Unicode string `text`.

    >>> find_combining_chars(u'A t̆ab̆lĕ')
    [3, 6, 9]
    i   i    (   i   i    (   R   RW   Rn   R   t	   enumerateR   R   (   R   t   iR   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   find_combining_charsS  s    c         C   sV   t  t |    } x t |   D] } d | | <q Wg  | D] } | d k	 r: | ^ q: S(   s   Indices of Unicode string `text` when skipping combining characters.

    >>> column_indices(u'A t̆ab̆lĕ')
    [0, 1, 2, 4, 5, 7, 8]
    N(   RI   RV   R   R1   (   R   t   string_indicest   indexR   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   column_indices]  s    i   t   Wt   Fi   t   Nat   Ht   Nt   Ac         C   s   t  |  t  r( t j d k  r( t |   Sy0 t g  |  D] } t t j |  ^ q5  } Wn t	 k
 rw t |   } n X| t t
 |    8} | S(   sq   Return the column width of text.

    Correct ``len(text)`` for wide East Asian and combining Unicode chars.
    i   i    (   i   i    (   R   RW   Rn   R   RV   t   sumt   east_asian_widthsR   t   east_asian_widthR5   R   (   R   R   t   width(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   column_widtht  s    
*c         C   s7   g  } x* |  D]" } | | k r | j  |  q q W| S(   N(   R%   (   t   Lt   rt   item(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   uniq  s
    c         c   ss   | d k r g  Vn[ xX t  t |   | d  D]< } x3 t |  | d | d  D] } |  | g | VqQ Wq/ Wd S(   s=   Return n-length tuples, in sorted order, no repeated elementsi    i   N(   t   xrangeRV   t   unique_combinations(   t   itemst   nR   t   cc(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyR     s
     !"c         C   s   |  j    j d d  }  t j d d |   }  g  } g  |  j d  D] } | j d d  ^ qC } | j d  g } xT t t |  d d  D]: } x1 t | |  D]  } | j	 d j
 | |   q Wq W| | 7} | S(   s   Return a list of normalized combinations for a `BCP 47` language tag.

    Example:

    >>> normalize_language_tag('de_AT-1901')
    ['de-at-1901', 'de-at', 'de-1901', 'de']
    t   _t   -s   -([a-zA-Z0-9])-s   -\1_i    i(   RX   Rk   t   reR   RH   R   RI   RV   R   R%   Rd   (   t   tagt   taglistt   subtagt   subtagst   base_tagR   t   tags(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   normalize_language_tag  s    	."
t   DependencyListc           B   sA   e  Z d  Z d g  d  Z d   Z d   Z d   Z d   Z RS(   s   
    List of dependencies, with file recording support.

    Note that the output file is not automatically closed.  You have
    to explicitly call the close() method.
    c         C   s/   |  j  |  x | D] } |  j |  q Wd S(   s   
        Initialize the dependency list, automatically setting the
        output file to `output_file` (see `set_output()`) and adding
        all supplied dependencies.
        N(   t
   set_outputt   add(   R   t   output_filet   dependenciesR   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyR     s    c         C   s^   g  |  _  | rQ | d k r$ d } n | } t j j d | d d d t  |  _ n	 d |  _ d S(   sH  
        Set the output file and clear the list of already added
        dependencies.

        `output_file` must be a string.  The specified file is
        immediately overwritten.

        If output_file is '-', the output will be written to stdout.
        If it is None, no file output is done when calling add().
        R   t   destination_pathR   t   utf8t	   autocloseN(   R   R1   R   t   iot
   FileOutputRJ   t   file(   R   R   t   of(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyR     s    		c         G   s]   xV | D]N } | |  j  k r |  j  j |  |  j d k	 rU |  j j | d  qU q q Wd S(   s   
        If the dependency `filename` has not already been added,
        append it to self.list and print it to self.file if self.file
        is not None.
        s   
N(   R   R%   R   R1   R8   (   R   t	   filenamest   filename(    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyR     s
    c         C   s   |  j  j   d |  _  d S(   s(   
        Close the output file.
        N(   R   t   closeR1   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyR     s    c         C   sD   y |  j  j } Wn t k
 r) d  } n Xd |  j j | |  j f S(   Ns
   %s(%r, %s)(   R   R\   R5   R1   Rc   R   R   (   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   __repr__  s
    
N(	   R   R   RG   R1   R   R   R   R   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyR     s   
			(    (4   RG   t   __docformat__Rn   R   t   os.pathR   R    R   R   R   R   R   t   docutils.iot   docutils.utils.error_reportingR   R   R   R   R   RK   RL   RM   RN   RU   RO   RP   Ri   Rs   R~   R   R1   R   R   R   R   R   R   R   R0   R   RJ   R   R   R   R   R   R   R   R   R   t   objectR   (    (    (    s;   /usr/lib/python2.7/dist-packages/docutils/utils/__init__.pyt   <module>   sb   		 	!		,											
	

					