<commit_before># disable missing docstring
#pylint: disable=C0111

from lettuce import world
from nose.tools import assert_equal
from terrain.steps import reload_the_page


@world.absorb
def create_component_instance(step, component_button_css, instance_id, expected_css):
    click_new_component_button(step, component_button_css)
    click_component_from_menu(instance_id, expected_css)


@world.absorb
def click_new_component_button(step, component_button_css):
    # step.given('I have opened a new course section in Studio')
    # step.given('I have added a new subsection')
    # step.given('I expand the first section')
    # world.css_click('a.new-unit-item')
    step.given('I have clicked the new unit button')
    world.css_click(component_button_css)


@world.absorb
def click_component_from_menu(instance_id, expected_css):
    elem_css = "a[data-location='%s']" % instance_id
    elements = world.css_find(elem_css)
    if len(elements) == 1: # Multiple templates
        world.css_click(elem_css)
        assert_equal(1, len(world.css_find(expected_css)))
    else: # Single template
        assert(len(filter(lambda ele: ele.has_class('single_template'), elements)) == 1)

@world.absorb<commit_msg>Fix pep8 violations.<commit_after># disable missing docstring
#pylint: disable=C0111

from lettuce import world
from nose.tools import assert_equal
from terrain.steps import reload_the_page


@world.absorb
def create_component_instance(step, component_button_css, instance_id, expected_css):
    click_new_component_button(step, component_button_css)
    click_component_from_menu(instance_id, expected_css)


@world.absorb
def click_new_component_button(step, component_button_css):
    # step.given('I have opened a new course section in Studio')
    # step.given('I have added a new subsection')
    # step.given('I expand the first section')
    # world.css_click('a.new-unit-item')
    step.given('I have clicked the new unit button')
    world.css_click(component_button_css)


@world.absorb
def click_component_from_menu(instance_id, expected_css):
    elem_css = "a[data-location='%s']" % instance_id
    elements = world.css_find(elem_css)
    if len(elements) == 1:  # Multiple templates
        world.css_click(elem_css)
        assert_equal(1, len(world.css_find(expected_css)))
    else:  # Single template
        assert(len(filter(lambda ele: ele.has_class('single_template'), elements)) == 1)


@world.absorb
{'fraction_non_alphanumeric': 0.09967186218211649, 'fraction_numerical': 0.0061525840853158325, 'mean_word_length': 5.082294264339152, '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': '1220969', 'n_tokens_mistral': 789, 'n_tokens_neox': 758, 'n_words': 175}