ó
„¾^Yc           @   sŒ   d  Z  d d l Z d d l Z d d l m Z d d l m Z	 e j
 e ƒ Z d Z d „  Z d e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d S(   sÒ   Module containing shims around Flake8 2.x behaviour.

Previously, users would import :func:`get_style_guide` from ``flake8.engine``.
In 3.0 we no longer have an "engine" module but we maintain the API from it.
iÿÿÿÿN(   t   base(   t   applicationt   get_style_guidec          K   sÊ   t  j ƒ  } | j ƒ  | j ƒ  | j g  ƒ | j } x_ |  j ƒ  D]Q \ } } y! t | | ƒ t | | | ƒ WqC t	 k
 r“ t
 j d | ƒ qC XqC W| j ƒ  | j ƒ  | j ƒ  | j ƒ  t | ƒ S(   sÜ   Provision a StyleGuide for use.

    :param \*\*kwargs:
        Keyword arguments that provide some options for the StyleGuide.
    :returns:
        An initialized StyleGuide
    :rtype:
        :class:`StyleGuide`
    s   Could not update option "%s"(   t   appt   Applicationt   find_pluginst   register_plugin_optionst   parse_configuration_and_clit   optionst   itemst   getattrt   setattrt   AttributeErrort   LOGt   errort   make_formattert   make_notifiert
   make_guidet   make_file_checker_managert
   StyleGuide(   t   kwargsR   R   t   keyt   value(    (    s1   /tmp/pip-build-EndXZ2/flake8/flake8/api/legacy.pyR      s     


	



R   c           B   sk   e  Z d  Z d „  Z e d „  ƒ Z e d „  ƒ Z d	 d „ Z d	 d „ Z	 d	 d „ Z
 d	 d	 d d „ Z RS(
   sD  Public facing object that mimic's Flake8 2.0's StyleGuide.

    .. note::

        There are important changes in how this object behaves compared to
        the StyleGuide object provided in Flake8 2.x.

    .. warning::

        This object should not be instantiated directly by users.

    .. versionchanged:: 3.0.0
    c         C   s   | |  _  | j |  _ d S(   s   Initialize our StyleGuide.N(   t   _applicationt   file_checker_managert   _file_checker_manager(   t   selfR   (    (    s1   /tmp/pip-build-EndXZ2/flake8/flake8/api/legacy.pyt   __init__@   s    	c         C   s
   |  j  j S(   sh   The parsed options.

        An instance of :class:`optparse.Values` containing parsed options.
        (   R   R   (   R   (    (    s1   /tmp/pip-build-EndXZ2/flake8/flake8/api/legacy.pyR   E   s    c         C   s
   |  j  j S(   s$   The extra arguments passed as paths.(   R   t   paths(   R   (    (    s1   /tmp/pip-build-EndXZ2/flake8/flake8/api/legacy.pyR   M   s    c         C   s*   |  j  j | ƒ |  j  j ƒ  t |  j  ƒ S(   sc  Run collected checks on the files provided.

        This will check the files passed in and return a :class:`Report`
        instance.

        :param list paths:
            List of filenames (or paths) to check.
        :returns:
            Object that mimic's Flake8 2.0's Reporter class.
        :rtype:
            flake8.api.legacy.Report
        (   R   t
   run_checkst   report_errorst   Report(   R   R   (    (    s1   /tmp/pip-build-EndXZ2/flake8/flake8/api/legacy.pyt   check_filesR   s    c         C   s7   |  j  j | ƒ p6 | o6 |  j  j t j j | | ƒ ƒ S(   sK  Determine if a file is excluded.

        :param str filename:
            Path to the file to check if it is excluded.
        :param str parent:
            Name of the parent directory containing the file.
        :returns:
            True if the filename is excluded, False otherwise.
        :rtype:
            bool
        (   R   t   is_path_excludedt   ost   patht   join(   R   t   filenamet   parent(    (    s1   /tmp/pip-build-EndXZ2/flake8/flake8/api/legacy.pyt   excludedc   s    	c         C   sj   | d k r d St | t j ƒ s1 t d ƒ ‚ n  d |  j _ |  j j | ƒ d |  j _ |  j j ƒ  d S(   s*   Set up a formatter for this run of Flake8.Ns<   Report should be subclass of flake8.formatter.BaseFormatter.(	   t   Nonet
   issubclasst	   formattert   BaseFormattert
   ValueErrorR   R   t   guideR   (   R   t   reporter(    (    s1   /tmp/pip-build-EndXZ2/flake8/flake8/api/legacy.pyt   init_reportt   s    i    c         C   s   |  j  | g ƒ S(   s  Run collected checks on a single file.

        This will check the file passed in and return a :class:`Report`
        instance.

        :param str filename:
            The path to the file to check.
        :param list lines:
            Ignored since Flake8 3.0.
        :param expected:
            Ignored since Flake8 3.0.
        :param int line_offset:
            Ignored since Flake8 3.0.
        :returns:
            Object that mimic's Flake8 2.0's Reporter class.
        :rtype:
            flake8.api.legacy.Report
        (   R    (   R   R%   t   linest   expectedt   line_offset(    (    s1   /tmp/pip-build-EndXZ2/flake8/flake8/api/legacy.pyt
   input_fileƒ   s    N(   t   __name__t
   __module__t   __doc__R   t   propertyR   R   R(   R    R'   R/   R3   (    (    (    s1   /tmp/pip-build-EndXZ2/flake8/flake8/api/legacy.pyR   1   s   	R   c           B   s/   e  Z d  Z d „  Z e d „  ƒ Z d „  Z RS(   s"  Public facing object that mimic's Flake8 2.0's API.

    .. note::

        There are important changes in how this object behaves compared to
        the object provided in Flake8 2.x.

    .. warning::

        This should not be instantiated by users.

    .. versionchanged:: 3.0.0
    c         C   s(   | |  _  | j |  _ |  j j |  _ d S(   sl   Initialize the Report for the user.

        .. warning:: This should not be instantiated by users.
        N(   R   R-   t   _style_guidet   statst   _stats(   R   R   (    (    s1   /tmp/pip-build-EndXZ2/flake8/flake8/api/legacy.pyR   ¨   s    	c         C   s
   |  j  j S(   s+   The total number of errors found by Flake8.(   R   t   result_count(   R   (    (    s1   /tmp/pip-build-EndXZ2/flake8/flake8/api/legacy.pyt   total_errors±   s    c         C   s;   g  |  j  j | ƒ D]$ } d j | j | j | j ƒ ^ q S(   s  Get the list of occurrences of a violation.

        :returns:
            List of occurrences of a violation formatted as:
            {Count} {Error Code} {Message}, e.g.,
            ``8 E531 Some error message about the error``
        :rtype:
            list
        s   {} {} {}(   R:   t   statistics_fort   formatt   countt
   error_codet   message(   R   t	   violationt   s(    (    s1   /tmp/pip-build-EndXZ2/flake8/flake8/api/legacy.pyt   get_statistics¶   s    (   R4   R5   R6   R   R7   R<   RD   (    (    (    s1   /tmp/pip-build-EndXZ2/flake8/flake8/api/legacy.pyR   ™   s   		(   s   get_style_guide(   R6   t   loggingt   os.pathR"   t   flake8.formattingR    R*   t   flake8.mainR   R   t	   getLoggerR4   R   t   __all__R   t   objectR   R   (    (    (    s1   /tmp/pip-build-EndXZ2/flake8/flake8/api/legacy.pyt   <module>   s   	h