<commit_before>from __future__ import absolute_import
import textwrap
import six

from plotly import exceptions, graph_reference

# Define line and tab size for help text!
LINE_SIZE = 76
TAB_SIZE = 4


def get_help(object_name, path=(), parent_object_names=(), attribute=None):
    """
    Returns a help string for a graph object.

    :param (str) object_name: An object name from GRAPH_REFERENCE
    :param (tuple[str]) path: The path within a `figure` object.
    :param parent_object_names: An iterable of names of this object's parents.
    :param (str|None) attribute: An attribute of <object_name> given <path>.
    :return: (str) A printable string to show to users.

    """
    class_name = graph_reference.string_to_class_name(object_name)
    help_string = 'Help for {}\n\n'.format(class_name)
    if object_name in graph_reference.ARRAYS:
        help_string += _list_help(object_name, path, parent_object_names)
    else:
        if attribute:
            help_string += _dict_attribute_help(object_name, path,
                                                parent_object_names, attribute)
        else:
            help_string += _dict_object_help(object_name, path,
                                             parent_object_names)
    help_string = help_string.expandtabs(TAB_SIZE)
    return help_string


def _list_help(object_name, path=(), parent_object_names=()):
    items = graph_reference.ARRAYS[object_name]['items']
    items_classes = [graph_reference.string_to_class_name(item)
                     for item in items]
    lines = textwrap.wrap(repr(items_classes), width=LINE_SIZE - TAB_SIZE)
    items_string = '\n\t'.join(lines)
    help_string = 'Valid Item Classes:\n{}\n'.format(items_string)
    return help_string


def _dict_object_help(object_name, path, parent_object_names):
    """
    Get general help information on an dict-like plotly graph object.

    :param object_name:
    :param path:<commit_msg>Use `object_name` not `class_name` in `help()`.<commit_after>from __future__ import absolute_import
import textwrap
import six

from plotly import exceptions, graph_reference

# Define line and tab size for help text!
LINE_SIZE = 76
TAB_SIZE = 4


def get_help(object_name, path=(), parent_object_names=(), attribute=None):
    """
    Returns a help string for a graph object.

    :param (str) object_name: An object name from GRAPH_REFERENCE
    :param (tuple[str]) path: The path within a `figure` object.
    :param parent_object_names: An iterable of names of this object's parents.
    :param (str|None) attribute: An attribute of <object_name> given <path>.
    :return: (str) A printable string to show to users.

    """
    help_string = 'Help for {}\n\n'.format(object_name)
    if object_name in graph_reference.ARRAYS:
        help_string += _list_help(object_name, path, parent_object_names)
    else:
        if attribute:
            help_string += _dict_attribute_help(object_name, path,
                                                parent_object_names, attribute)
        else:
            help_string += _dict_object_help(object_name, path,
                                             parent_object_names)
    help_string = help_string.expandtabs(TAB_SIZE)
    return help_string


def _list_help(object_name, path=(), parent_object_names=()):
    items = graph_reference.ARRAYS[object_name]['items']
    items_classes = [graph_reference.string_to_class_name(item)
                     for item in items]
    lines = textwrap.wrap(repr(items_classes), width=LINE_SIZE - TAB_SIZE)
    items_string = '\n\t'.join(lines)
    help_string = 'Valid Item Classes:\n{}\n'.format(items_string)
    return help_string


def _dict_object_help(object_name, path, parent_object_names):
    """
    Get general help information on an dict-like plotly graph object.

    :param object_name:
    :param path:
{'fraction_non_alphanumeric': 0.08876811594202899, 'fraction_numerical': 0.0015527950310559005, 'mean_word_length': 3.160387513455328, 'pattern_counts': {'":': 0, '<': 7, '<?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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '351026', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1124, 'n_words': 314}