<commit_before>"""
Comprehensive command line completer support

Provides extended tab-completions support for
    - std items: keywords, attributes
    - import statements
    - array indicies
    - dict keys

It is based on the code from rlcompleter, then pimped out.

"""

import os
import sys
import re
import keyword
import pkgutil

import builtins
import __main__

__all__ = ["Completer", "ReadlineCompleter",
           "EditlineCompleter", "global_line_editor"]

def _debug(tag, *args):
    """Debugging utility.

    Args:
        tag:  debug tag to enable/disable visibility
        args: va-args of what to print

    Returns:
       Nothing

    """
    do_debug = False
    if not do_debug:
        return
    monitor_tags = [
        #'complete(0)',
        #'complete(match)',
        #'attr_matches'
        #'global_matches',
        #'dict_matches',
        #'array_matches'
        #'LastExpr(0)',
        #'LastExpr(1)',
        #'LastExpr(2)',
        #'LastExpr(3)',
        #'LastExpr(4)',
        #'LastExpr(5)',
        #'LastExpr(6)',
        #'LastExpr(7)',
        #'LastExpr(8)'
    ]
    if tag in monitor_tags:
        print(os.linesep + "DBG["+tag+"]:", *args)


#
# Maintain a global for the lineditor
#
_gle_data = None

def global_line_editor(gle=None):
    """Access the global lineeditor instance.

    Args:
        gle: (optional) new global lineeditor instance

    Returns:
        Current global lineeditor instance

    """
    if gle is not None:
        _gle_data = gle
    return _gle_data


class Completer(object):
    """General tab-completion support for underlying terminal infrastructure.

    Provides extended tab-completion mechanisms in a way which is available
    to both 'readline' and 'editline'. The goal is to coalece the completion
    functionality into a single place and have it independent of one specific<commit_msg>Correcting scoping bug to fix access to global line-editor instance.<commit_after>"""
Comprehensive command line completer support

Provides extended tab-completions support for
    - std items: keywords, attributes
    - import statements
    - array indicies
    - dict keys

It is based on the code from rlcompleter, then pimped out.

"""

import os
import sys
import re
import keyword
import pkgutil

import builtins
import __main__

__all__ = ["Completer", "ReadlineCompleter",
           "EditlineCompleter", "global_line_editor"]

def _debug(tag, *args):
    """Debugging utility.

    Args:
        tag:  debug tag to enable/disable visibility
        args: va-args of what to print

    Returns:
       Nothing

    """
    do_debug = False
    if not do_debug:
        return
    monitor_tags = [
        #'complete(0)',
        #'complete(match)',
        #'attr_matches'
        #'global_matches',
        #'dict_matches',
        #'array_matches'
        #'LastExpr(0)',
        #'LastExpr(1)',
        #'LastExpr(2)',
        #'LastExpr(3)',
        #'LastExpr(4)',
        #'LastExpr(5)',
        #'LastExpr(6)',
        #'LastExpr(7)',
        #'LastExpr(8)'
    ]
    if tag in monitor_tags:
        print(os.linesep + "DBG["+tag+"]:", *args)


#
# Maintain a global for the lineditor
#
_gle_data = None

def global_line_editor(gle=None):
    """Access the global lineeditor instance.

    Args:
        gle: (optional) new global lineeditor instance

    Returns:
        Current global lineeditor instance

    """
    global _gle_data
    if gle is not None:
        _gle_data = gle
    return _gle_data


class Completer(object):
    """General tab-completion support for underlying terminal infrastructure.

    Provides extended tab-completion mechanisms in a way which is available
    to both 'readline' and 'editline'. The goal is to coalece the completion
    functionality into a single place and have it independent of one specific
{'fraction_non_alphanumeric': 0.09729448491155047, 'fraction_numerical': 0.005202913631633715, 'mean_word_length': 2.6549429657794676, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1268923', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1094, 'n_words': 368}