<commit_before>from .activation import STATUS


default_app_config = 'viewflow.apps.ViewflowConfig'


class ThisObject(object):
    """Helper for forward references on flow tasks."""

    def __init__(self, name):  # noqa D102
        self.name = name

    @property
    def owner(self):
        """Return user that was assigned to the task."""
        def get_task_owner(activation):
            flow_class = activation.process.flow_class
            task_node = flow_class._meta.node(self.name)
            task = flow_class.task_class.objects.get(
                process=activation.process,
                flow_task=task_node,
                status=STATUS.DONE)
            return task.owner
        return get_task_owner


class This(object):
    """Helper for building forward referenced flow task.

    The rationaly is ability to specify referencies to the class
    attribute and methods before they declated.

    `this` is like a `self` but for the class body.

    The referencies are resolved by the metaclass at the end of the
    flow construction.

    Example::

        class MyFlow(Flow):
            start = (
                flow.StartFunction(this.start_flow)
                .Next(this.task)
            )

            task = (
                flow.View(MyView)
                .Assign(this.start.owner)
                .Next(this.end)
            )

            end = flow.End()

            def start_flow(self, activation):
                activation.prepare()
                activation.done()

    """

    def __getattr__(self, name):
        return ThisObject(name)


class Edge(object):
    """Edge of the Flow graph."""<commit_msg>Fix typos etc. in docstrings<commit_after>from .activation import STATUS


default_app_config = 'viewflow.apps.ViewflowConfig'


class ThisObject(object):
    """Helper for forward references on flow tasks."""

    def __init__(self, name):  # noqa D102
        self.name = name

    @property
    def owner(self):
        """Return user that was assigned to the task."""
        def get_task_owner(activation):
            flow_class = activation.process.flow_class
            task_node = flow_class._meta.node(self.name)
            task = flow_class.task_class.objects.get(
                process=activation.process,
                flow_task=task_node,
                status=STATUS.DONE)
            return task.owner
        return get_task_owner


class This(object):
    """Helper for building forward referenced flow task.

    The rationale is ability to specify references to the class
    attributes and methods before they are declared.

    `this` is like a `self` but for the class body.

    The references are resolved by the metaclass at the end of the
    flow construction.

    Example::

        class MyFlow(Flow):
            start = (
                flow.StartFunction(this.start_flow)
                .Next(this.task)
            )

            task = (
                flow.View(MyView)
                .Assign(this.start.owner)
                .Next(this.end)
            )

            end = flow.End()

            def start_flow(self, activation):
                activation.prepare()
                activation.done()

    """

    def __getattr__(self, name):
        return ThisObject(name)


class Edge(object):
    """Edge of the Flow graph."""
{'fraction_non_alphanumeric': 0.08452807646356034, 'fraction_numerical': 0.0017921146953405018, 'mean_word_length': 1.874678111587983, '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': '5408595', 'n_tokens_mistral': 920, 'n_tokens_neox': 854, 'n_words': 256}