<commit_before>


class ModuleScope(object):
    id, type = xrange(2)


def scope(name, by_student=True, by_course=True, by_module=ModuleScope.id, attr=None, attrs=None):
    def wrapper(fn):
        return fn
    return wrapper


def requires_children(fn):
    return fn


def register_view(name):
    def wrapper(fn):
        return fn
    return wrapper

register_handler = register_view


class Widget(object):
    pass


class XModule(object):
    pass


class VerticalModule(XModule):

    @register_view('student')
    @requires_children
    def render_student(self, context):
        result = Widget()
        child_widgets = [self.render_child(child) for child in context.children]
        result.add_widget_resources(child_widgets)
        result.add_content(render_template("vertical.html",
            children=[w.content for w in child_widgets]
        ))


class ThumbsModule(XModule):

    votes_scope = scope('votes', by_student=False, attr='votes')

    @register_view('student')
    @votes_scope
    def render_student(self, context):
        return Widget(render_template("upvotes.html",
            upvotes=context.votes.get('up', 0),
            downvotes=context.votes.get('down', 0),
        ))

    @register_handler('vote')
    @votes_scope
    def handle_vote(self, context, data):
        if data['vote_type'] not in ('up', 'down'):
            log.error('error!')
            return

        context.votes.setdefault(data['vote_type'], 0) += 1
<commit_msg>change name of child decorator<commit_after>


class ModuleScope(object):
    id, type = xrange(2)


def scope(name, by_student=True, by_course=True, by_module=ModuleScope.id, attr=None, attrs=None):
    def wrapper(fn):
        return fn
    return wrapper


def needs_children(fn):
    return fn


def needs_settings(fn):
    return fn


def register_view(name):
    def wrapper(fn):
        return fn
    return wrapper

register_handler = register_view


class Widget(object):
    pass


class XModule(object):
    pass


class VerticalModule(XModule):

    @register_view('student')
    @needs_children
    def render_student(self, context):
        result = Widget()
        child_widgets = [self.render_child(child) for child in context.children]
        result.add_widget_resources(child_widgets)
        result.add_content(render_template("vertical.html",
            children=[w.content for w in child_widgets]
        ))


class ThumbsModule(XModule):

    votes_scope = scope('votes', by_student=False, attr='votes')

    @register_view('student')
    @votes_scope
    def render_student(self, context):
        return Widget(render_template("upvotes.html",
            upvotes=context.votes.get('up', 0),
            downvotes=context.votes.get('down', 0),
        ))

    @register_handler('vote')
    @votes_scope
    def handle_vote(self, context, data):
        if data['vote_type'] not in ('up', 'down'):
            log.error('error!')
            return

        context.votes.setdefault(data['vote_type'], 0) += 1

{'fraction_non_alphanumeric': 0.11493872143093739, 'fraction_numerical': 0.0033123550844650546, 'mean_word_length': 3.108843537414966, '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': '1725822', 'n_tokens_mistral': 954, 'n_tokens_neox': 918, 'n_words': 198}