0P9UudZddlmZddlmZddlmZddlmZddlmZddlmZGdd Z Gd d eZ Gd d Z dS)z&Statistic collection logic for Flake8.)Dict) Generator)List) NamedTuple)Optional) ViolationcjeZdZdZd dZdeefdZddZ dd ed e ede d fd Z dS) Statisticsz5Manager of aggregated statistics for a run of Flake8.returnNci|_dS)z8Initialize the underlying dictionary for our statistics.N)_storeselfs /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/flake8/statistics.py__init__zStatistics.__init__s .0 c>td|jDS)ziReturn all unique error codes stored. :returns: Sorted list of error codes. ch|] }|j S)code).0keys r z)Statistics.error_codes..s777Csx777rsortedr rs r error_codeszStatistics.error_codess# 774;777888rerrorrct|}||jvr"t||j|<|j|dS)zAdd the fact that the error was seen in the file. :param error: The Violation instance containing the information about the violation. N)Key create_fromr Statistic increment)rrrs rrecordzStatistics.records[ooe$$ dk ! !(44U;;DK  C""$$$$$rprefixfilename)r!NNc#xKtfd|jD}|D]}|j|VdS)aBGenerate statistics for the prefix and filename. If you have a :class:`Statistics` object that has recorded errors, you can generate the statistics for a prefix (e.g., ``E``, ``E1``, ``W50``, ``W503``) with the optional filter of a filename as well. .. code-block:: python >>> stats = Statistics() >>> stats.statistics_for('E12', filename='src/flake8/statistics.py') >>> stats.statistics_for('W') :param prefix: The error class or specific error code to find statistics for. :param filename: (Optional) The filename to further filter results by. :returns: Generator of instances of :class:`Statistic` c3HK|]}||VdSN)matches)rrr%r$s r z,Statistics.statistics_for..?sJ! ! #++fh*G*G! ! ! ! ! ! ! rNr)rr$r%matching_errors error_codes `` rstatistics_forzStatistics.statistics_for&sw2!! ! ! ! ! ;! ! !   * * *J+j) ) ) ) ) * *rr N)rrr Nr() __name__ __module__ __qualname____doc__rrstrrr#rrr-rrrr r s??11119T#Y9999 % % % %6:***%-c]* * +******rr c`eZdZUdZeed<eed<ed dZdedeede fd Z d S) rzSimple key structure for the Statistics dictionary. To make things clearer, easier to read, and more understandable, we use a namedtuple here for all Keys in the underlying dictionary for the Statistics object. r%rrrr c0||j|jS)z6Create a Key from :class:`flake8.violation.Violation`.r%rr6clsrs rr zKey.create_fromQssEN<<<||_||_||_||_dS)zInitialize our Statistic.Nr,r%r?r@)rr,r%r?r@s rrzStatistic.__init__os$%    rrrc>||j|j|jdS)z>Create a Statistic from a :class:`flake8.violation.Violation`.rrB)rr%textr7s rr zStatistic.create_fromxs/sz^J     rc&|xjdz c_dS)zAIncrement the number of times we've seen this error in this file.N)r@rs rr"zStatistic.increments a r)rrr r!r.) r/r0r1r2r3intrr<r r"rrrr!r!gs),7:CF    [ rr!N) r2typingrrrrrflake8.violationrr rr!rrrrJs,,&&&&&&8*8*8*8*8*8*8*8*v     *   Br