<commit_before>" File: pythonhelper.vim
" Author: <NAME> <fuf-at-mageo-dot-cz>
" Version: 0.83
" Last Modified: Jan 4, 2010
"
" Overview
" --------
" This Vim script helps you find yourself in larger Python source files. It
" displays the current Python class, method or function the cursor is placed
" on in the status line. It's smarter than Yegappan Lakshmanan's taglist.vim
" because it takes indentation and comments into account in order to determine
" what identifier the cursor is placed on.
"
" Requirements
" ------------
" This script needs only VIM compiled with the Python interpreter. It doesn't
" rely on the exuberant ctags utilities. You can determine whether your VIM
" has Python support by issuing command :ver and looking for +python in the
" list of features.
"
" Installation
" ------------
" 1. Make sure your Vim has the Python feature enabled (+python). If not, you
"    will need to recompile it with the --with-pythoninterp option passed to
"    the configure script
" 2. Copy the pythonhelper.vim script to the $HOME/.vim/plugin directory, or
"    install it in some other way (vim-addon-manager, pathogen, ...)
" 3. Add '%{TagInStatusLine()}' the statusline in your vimrc
" 4. Run Vim and open any Python file.
"
python << EOS

# import of required modules {{{
import re
import sys
import time
import traceback
import vim
# }}}


# global dictionaries of tags and their line numbers, keys are buffer numbers {{{
TAGS            = {}
TAGLINENUMBERS  = {}
BUFFERTICKS     = {}
# }}}


# class PythonTag() {{{
class PythonTag(object):
    # DOC {{{
    """A simple storage class representing a python tag.
    """
    # }}}


    # STATIC VARIABLES {{{

    # possible tag types {{{
    TT_CLASS                    = 0
    TT_METHOD                   = 1
    TT_FUNCTION                 = 2
    # }}}

    # tag type names {{{
    TAG_TYPE_NAME               = {
        TT_CLASS                : "class",
        TT_METHOD               : "method",
        TT_FUNCTION             : "function",
    }
    # }}}

    # }}}


    # METHODS {{{

    def __init__(self, type, name, fullName, lineNumber, indentLevel):
        # DOC {{{
        """Initializes instances of PythonTag().

        Parameters

            type -- tag type

            name -- short tag name

            fullName -- full tag name (in dotted notation)

            lineNumber -- line number on which the tag starts

            indentLevel -- indentation level of the tag
        """
        # }}}

        # CODE {{{
        # remember the settings {{{
        self.type               = type
        self.name               = name
        self.fullName           = fullName
        self.lineNumber         = lineNumber
        self.indentLevel        = indentLevel
        # }}}
        # }}}


    def __str__(self):
        # DOC {{{
        """Returns a string representation of the tag.
        """
        # }}}

        # CODE {{{
        return "%s (%s) [%s, %u, %u]" % (self.name, PythonTag.TAG_TYPE_NAME[self.type],
                                         self.fullName, self.lineNumber, self.indentLevel,)
        # }}}


    __repr__ = __str__


    # }}}
# }}}


# class SimplePythonTagsParser() {{{
class SimplePythonTagsParser(object):
    # DOC {{{
    """Provides a simple Python tag parser.
    """
    # }}}


    # STATIC VARIABLES {{{

    # how many chars a single tab represents (visually)
    TABSIZE                     = 8
    # regexp used to extract indentation and strip comments
    COMMENTS_INDENT_RE          = re.compile('([ \t]*)([^\n#]*).*')
    # regexp used to extract a class name
    CLASS_RE                    = re.compile('class[ \t]+([^(:]+).*')
    # regexp used to extract a method or function name
    METHOD_RE                   = re.compile('def[ \t]+([^(]+).*')

    # }}}


    # METHODS {{{

    def __init__(self, source):
        # DOC {{{
        """Initializes instances of SimplePythonTagsParser().

        Parameters

            source -- source for which the tags will be generated. It must
                provide callable method readline (i.e. as file objects do).
        """
        # }}}

        # CODE {{{
        # make sure source has readline() method {{{
        if ((hasattr(source, 'readline') == 0) or
            (callable(source.readline) == 0)):
            raise AttributeError("Source must have callable readline method.")
        # }}}

        # remember what the source is
        self.source = source
        # }}}


    def getTags(self):
        # DOC {{{
        """Determines all the tags for the buffer. Returns a tuple in the format
        (tagLineNumbers, tags,).
        """
        # }}}

        # CODE {{{
        # initialize the resulting list of tag line numbers and the tag information {{{
        tagLineNumbers  = []
        tags            = {}
        # }}}

        # initalize local auxiliary variables {{{
        tagsStack       = []
        lineNumber      = 0<commit_msg>Exceptions can tell you the same thing.<commit_after>" File: pythonhelper.vim
" Author: <NAME> <fuf-at-mageo-dot-cz>
" Version: 0.83
" Last Modified: Jan 4, 2010
"
" Overview
" --------
" This Vim script helps you find yourself in larger Python source files. It
" displays the current Python class, method or function the cursor is placed
" on in the status line. It's smarter than Yegappan Lakshmanan's taglist.vim
" because it takes indentation and comments into account in order to determine
" what identifier the cursor is placed on.
"
" Requirements
" ------------
" This script needs only VIM compiled with the Python interpreter. It doesn't
" rely on the exuberant ctags utilities. You can determine whether your VIM
" has Python support by issuing command :ver and looking for +python in the
" list of features.
"
" Installation
" ------------
" 1. Make sure your Vim has the Python feature enabled (+python). If not, you
"    will need to recompile it with the --with-pythoninterp option passed to
"    the configure script
" 2. Copy the pythonhelper.vim script to the $HOME/.vim/plugin directory, or
"    install it in some other way (vim-addon-manager, pathogen, ...)
" 3. Add '%{TagInStatusLine()}' the statusline in your vimrc
" 4. Run Vim and open any Python file.
"
python << EOS

# import of required modules {{{
import re
import sys
import time
import traceback
import vim
# }}}


# global dictionaries of tags and their line numbers, keys are buffer numbers {{{
TAGS            = {}
TAGLINENUMBERS  = {}
BUFFERTICKS     = {}
# }}}


# class PythonTag() {{{
class PythonTag(object):
    # DOC {{{
    """A simple storage class representing a python tag.
    """
    # }}}


    # STATIC VARIABLES {{{

    # possible tag types {{{
    TT_CLASS                    = 0
    TT_METHOD                   = 1
    TT_FUNCTION                 = 2
    # }}}

    # tag type names {{{
    TAG_TYPE_NAME               = {
        TT_CLASS                : "class",
        TT_METHOD               : "method",
        TT_FUNCTION             : "function",
    }
    # }}}

    # }}}


    # METHODS {{{

    def __init__(self, type, name, fullName, lineNumber, indentLevel):
        # DOC {{{
        """Initializes instances of PythonTag().

        Parameters

            type -- tag type

            name -- short tag name

            fullName -- full tag name (in dotted notation)

            lineNumber -- line number on which the tag starts

            indentLevel -- indentation level of the tag
        """
        # }}}

        # CODE {{{
        # remember the settings {{{
        self.type               = type
        self.name               = name
        self.fullName           = fullName
        self.lineNumber         = lineNumber
        self.indentLevel        = indentLevel
        # }}}
        # }}}


    def __str__(self):
        # DOC {{{
        """Returns a string representation of the tag.
        """
        # }}}

        # CODE {{{
        return "%s (%s) [%s, %u, %u]" % (self.name, PythonTag.TAG_TYPE_NAME[self.type],
                                         self.fullName, self.lineNumber, self.indentLevel,)
        # }}}


    __repr__ = __str__


    # }}}
# }}}


# class SimplePythonTagsParser() {{{
class SimplePythonTagsParser(object):
    # DOC {{{
    """Provides a simple Python tag parser.
    """
    # }}}


    # STATIC VARIABLES {{{

    # how many chars a single tab represents (visually)
    TABSIZE                     = 8
    # regexp used to extract indentation and strip comments
    COMMENTS_INDENT_RE          = re.compile('([ \t]*)([^\n#]*).*')
    # regexp used to extract a class name
    CLASS_RE                    = re.compile('class[ \t]+([^(:]+).*')
    # regexp used to extract a method or function name
    METHOD_RE                   = re.compile('def[ \t]+([^(]+).*')

    # }}}


    # METHODS {{{

    def __init__(self, source):
        # DOC {{{
        """Initializes instances of SimplePythonTagsParser().

        Parameters

            source -- source for which the tags will be generated. It must
                provide callable method readline (i.e. as file objects do).
        """
        # }}}

        # remember what the source is
        self.source = source
        # }}}


    def getTags(self):
        # DOC {{{
        """Determines all the tags for the buffer. Returns a tuple in the format
        (tagLineNumbers, tags,).
        """
        # }}}

        # CODE {{{
        # initialize the resulting list of tag line numbers and the tag information {{{
        tagLineNumbers  = []
        tags            = {}
        # }}}

        # initalize local auxiliary variables {{{
        tagsStack       = []
        lineNumber      = 0
{'fraction_non_alphanumeric': 0.11540437776179222, 'fraction_numerical': 0.0036995170075017985, 'mean_word_length': 1.8159722222222223, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '82347', 'n_tokens_mistral': 2868, 'n_tokens_neox': 2621, 'n_words': 928}