<commit_before># -*- coding: utf-8 -*-

import os
import sys
from docopt import docopt
from time import time

from radish import __VERSION__
from radish.parser import FeatureParser
from radish.loader import Loader
from radish.matcher import Matcher
from radish.stepregistry import StepRegistry
from radish.hookregistry import HookRegistry
from radish.core import Runner
from radish.exceptions import FeatureFileNotFoundError
from radish.errororacle import error_oracle
from radish.terrain import world
import radish.utils as utils

# extensions
# FIXME: load dynamically
import radish.extensions.time_recorder
import radish.extensions.syslog_writer
import radish.extensions.console_writer
import radish.extensions.failure_inspector
import radish.extensions.failure_debugger
import radish.extensions.bdd_xml_writer


def setup_config(arguments):
    """
        Parses the docopt arguments and creates a configuration object in terrain.world
    """
    world.config = lambda: None
    for key, value in arguments.items():
        config_key = key.replace("--", "").replace("-", "_").replace("<", "").replace(">", "")
        setattr(world.config, config_key, value)


@error_oracle
def main():
    """
Usage:
    radish <features>...
           [-b=<basedir> | --basedir=<basedir>]
           [--early-exit]
           [--debug-steps]
           [--debug-after-failure]
           [--inspect-after-failure]
           [--bdd-xml]
           [--no-ansi]
           [--no-line-jump]
           [--write-steps-once]
           [-t | --with-traceback]
           [-m=<marker> | --marker=<marker>]
           [-p=<profile> | --profile=<profile>]
    radish (-h | --help)
    radish (-v | --version)

Arguments:
    features                             feature files to run

Options:
    -h --help                            show this screen
    -v --version                         show version
    --early-exit                         stop the run after the first failed step
    --debug-steps                        debugs each step
    --debug-after-failure                start python debugger after failure
    --inspect-after-failure              start python shell after failure
    --bdd-xml                            write BDD XML result file after run
    --no-ansi                            print features without any ANSI sequences (like colors, line jump)
    --no-line-jump                       print features without line jumps (overwriting steps)
    --write-steps-once                   does not rewrite the steps (this option only makes sense in combination with the --no-ansi flag)
    -t --with-traceback                  show the Exception traceback when a step fails
    -m=<marker> --marker=<marker>        specify the marker for this run [default: time.time()]
    -p=<profile> --profile=<profile>     specify the profile which can be used in the step/hook implementation

    -b=<basedir> --basedir=<basedir>     set base dir from where the step.py and terrain.py will be loaded [default: $PWD/radish]

(C) Copyright 2013 by <NAME> <<EMAIL>>
    """

    arguments = docopt("radish {}\n{}".format(__VERSION__, main.__doc__), version=__VERSION__)<commit_msg>args: support -e alias for --early-exit<commit_after># -*- coding: utf-8 -*-

import os
import sys
from docopt import docopt
from time import time

from radish import __VERSION__
from radish.parser import FeatureParser
from radish.loader import Loader
from radish.matcher import Matcher
from radish.stepregistry import StepRegistry
from radish.hookregistry import HookRegistry
from radish.core import Runner
from radish.exceptions import FeatureFileNotFoundError
from radish.errororacle import error_oracle
from radish.terrain import world
import radish.utils as utils

# extensions
# FIXME: load dynamically
import radish.extensions.time_recorder
import radish.extensions.syslog_writer
import radish.extensions.console_writer
import radish.extensions.failure_inspector
import radish.extensions.failure_debugger
import radish.extensions.bdd_xml_writer


def setup_config(arguments):
    """
        Parses the docopt arguments and creates a configuration object in terrain.world
    """
    world.config = lambda: None
    for key, value in arguments.items():
        config_key = key.replace("--", "").replace("-", "_").replace("<", "").replace(">", "")
        setattr(world.config, config_key, value)


@error_oracle
def main():
    """
Usage:
    radish <features>...
           [-b=<basedir> | --basedir=<basedir>]
           [-e | --early-exit]
           [--debug-steps]
           [--debug-after-failure]
           [--inspect-after-failure]
           [--bdd-xml]
           [--no-ansi]
           [--no-line-jump]
           [--write-steps-once]
           [-t | --with-traceback]
           [-m=<marker> | --marker=<marker>]
           [-p=<profile> | --profile=<profile>]
    radish (-h | --help)
    radish (-v | --version)

Arguments:
    features                             feature files to run

Options:
    -h --help                            show this screen
    -v --version                         show version
    -e --early-exit                      stop the run after the first failed step
    --debug-steps                        debugs each step
    --debug-after-failure                start python debugger after failure
    --inspect-after-failure              start python shell after failure
    --bdd-xml                            write BDD XML result file after run
    --no-ansi                            print features without any ANSI sequences (like colors, line jump)
    --no-line-jump                       print features without line jumps (overwriting steps)
    --write-steps-once                   does not rewrite the steps (this option only makes sense in combination with the --no-ansi flag)
    -t --with-traceback                  show the Exception traceback when a step fails
    -m=<marker> --marker=<marker>        specify the marker for this run [default: time.time()]
    -p=<profile> --profile=<profile>     specify the profile which can be used in the step/hook implementation

    -b=<basedir> --basedir=<basedir>     set base dir from where the step.py and terrain.py will be loaded [default: $PWD/radish]

(C) Copyright 2013 by <NAME> <<EMAIL>>
    """

    arguments = docopt("radish {}\n{}".format(__VERSION__, main.__doc__), version=__VERSION__)
{'fraction_non_alphanumeric': 0.10420904396808012, 'fraction_numerical': 0.0015647003598810829, 'mean_word_length': 2.215291750503018, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '6386414', 'n_tokens_mistral': 1754, 'n_tokens_neox': 1706, 'n_words': 560}