<commit_before>"""
Easy menu selection tree

Contrib - <NAME> 2017

This module allows you to create and initialize an entire branching EvMenu
instance with nothing but a multi-line string passed to one function.

EvMenu is incredibly powerful and flexible, but using it for simple menus
can often be fairly cumbersome - a simple menu that can branch into five
categories would require six nodes, each with options represented as a list
of dictionaries.

This module provides a function, init_tree_selection, which acts as a frontend
for EvMenu, dynamically sourcing the options from a multi-line string you provide.
For example, if you define a string as such:

    TEST_MENU = '''Foo
    Bar
    Baz
    Qux'''

And then use TEST_MENU as the 'treestr' source when you call init_tree_selection
on a player:

    init_tree_selection(TEST_MENU, caller, callback)

The player will be presented with an EvMenu, like so:

    ___________________________
    
    Make your selection:
    ___________________________
    
    Foo  
    Bar  
    Baz  
    Qux  

Making a selection will pass the selection's key to the specified callback as a
string along with the caller, as well as the index of the selection (the line number
on the source string) along with the source string for the tree itself.

In addition to specifying selections on the menu, you can also specify categories.
Categories are indicated by putting options below it preceded with a '-' character.
If a selection is a category, then choosing it will bring up a new menu node, prompting
the player to select between those options, or to go back to the previous menu. In
addition, categories are marked by default with a '[+]' at the end of their key. Both
this marker and the option to go back can be disabled.

Categories can be nested in other categories as well - just go another '-' deeper. You
can do this as many times as you like. There's no hard limit to the number of
categories you can go down.

For example, let's add some more options to our menu, turning 'Foo' into a category.

    TEST_MENU = '''Foo
    Bar
    -You've got to know
    --When to hold em
    --When to fold em
    --When to walk away
    Baz
    Qux'''
    
Now when we call the menu, we can see that 'Foo' has become a category instead of a
selectable option.

    _______________________________<commit_msg>Fix typo in documentation<commit_after>"""
Easy menu selection tree

Contrib - <NAME> 2017

This module allows you to create and initialize an entire branching EvMenu
instance with nothing but a multi-line string passed to one function.

EvMenu is incredibly powerful and flexible, but using it for simple menus
can often be fairly cumbersome - a simple menu that can branch into five
categories would require six nodes, each with options represented as a list
of dictionaries.

This module provides a function, init_tree_selection, which acts as a frontend
for EvMenu, dynamically sourcing the options from a multi-line string you provide.
For example, if you define a string as such:

    TEST_MENU = '''Foo
    Bar
    Baz
    Qux'''

And then use TEST_MENU as the 'treestr' source when you call init_tree_selection
on a player:

    init_tree_selection(TEST_MENU, caller, callback)

The player will be presented with an EvMenu, like so:

    ___________________________
    
    Make your selection:
    ___________________________
    
    Foo  
    Bar  
    Baz  
    Qux  

Making a selection will pass the selection's key to the specified callback as a
string along with the caller, as well as the index of the selection (the line number
on the source string) along with the source string for the tree itself.

In addition to specifying selections on the menu, you can also specify categories.
Categories are indicated by putting options below it preceded with a '-' character.
If a selection is a category, then choosing it will bring up a new menu node, prompting
the player to select between those options, or to go back to the previous menu. In
addition, categories are marked by default with a '[+]' at the end of their key. Both
this marker and the option to go back can be disabled.

Categories can be nested in other categories as well - just go another '-' deeper. You
can do this as many times as you like. There's no hard limit to the number of
categories you can go down.

For example, let's add some more options to our menu, turning 'Bar' into a category.

    TEST_MENU = '''Foo
    Bar
    -You've got to know
    --When to hold em
    --When to fold em
    --When to walk away
    Baz
    Qux'''
    
Now when we call the menu, we can see that 'Bar' has become a category instead of a
selectable option.

    _______________________________
{'fraction_non_alphanumeric': 0.04025423728813559, 'fraction_numerical': 0.001694915254237288, 'mean_word_length': 3.5133843212237093, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '752275', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1166, 'n_words': 725}