<commit_before>#!/usr/bin/env python

"""
This script should be used for creating the scaffolding for a test.
"""
import os
import sys
from ooni import log

test_template = """\"\"\"
This is a self genrated test created by scaffolding.py.
you will need to fill it up with all your necessities.
Safe hacking :).
\"\"\"
from zope.interface import implements
from twisted.python import usage
from twisted.plugin import IPlugin
from plugoo.tests import ITest, OONITest

class %(testName)sArgs(usage.Options):
    optParameters = [['asset', 'a', None, 'Asset file'],
                     ['resume', 'r', 0, 'Resume at this index']]

class %(testName)sTest(OONITest):
    implements(IPlugin, ITest)

    shortName = "%(testShortname)s"
    description = "%(testName)s"
    requirements = None
    options = %(testName)sArgs
    blocking = True

    def control(self, experiment_result, args):
        # What you return here ends up inside of the report.
        return {}

    def experiment(self, args):
        # What you return here gets handed as input to control
        return {}

    def load_assets(self):
        if self.local_options:
            return {'asset': Asset(self.local_options['asset'])}
        else:
            return {}

# We need to instantiate it otherwise getPlugins does not detect it
# XXX Find a way to load plugins without instantiating them.
%(testShortname)s = %(testName)sTest(None, None, None)
"""

test_vars = {'testName': None, 'testShortname': None}
test_vars['testName'] = raw_input('Test Name: ')
test_vars['testShortname'] = raw_input("Test Short Name: ")

fname = os.path.join('plugins', test_vars['testShortname']+'.py')

if os.path.exists(fname):
    print 'WARNING! File named "%s" already exists.' % fname<commit_msg>Fix scaffolding script<commit_after>#!/usr/bin/env python

"""
This script should be used for creating the scaffolding for a test.
"""
import os
import sys
from ooni import log

test_template = """\"\"\"
This is a self genrated test created by scaffolding.py.
you will need to fill it up with all your necessities.
Safe hacking :).
\"\"\"
from zope.interface import implements
from twisted.python import usage
from twisted.plugin import IPlugin
from ooni.plugoo.tests import ITest, OONITest
from ooni.plugoo.assets import Asset
from ooni import log

class %(testShortname)sArgs(usage.Options):
    optParameters = [['asset', 'a', None, 'Asset file'],
                     ['resume', 'r', 0, 'Resume at this index']]

class %(testShortname)sTest(OONITest):
    implements(IPlugin, ITest)

    shortName = "%(testSNlower)s"
    description = "%(testName)s"
    requirements = None
    options = %(testShortname)sArgs
    blocking = True

    def control(self, experiment_result, args):
        # What you return here ends up inside of the report.
        log.msg("Running control")
        return {}

    def experiment(self, args):
        # What you return here gets handed as input to control
        log.msg("Running experiment")
        return {}

    def load_assets(self):
        if self.local_options:
            return {'asset': Asset(self.local_options['asset'])}
        else:
            return {}

# We need to instantiate it otherwise getPlugins does not detect it
# XXX Find a way to load plugins without instantiating them.
%(testShortname)s = %(testShortname)sTest(None, None, None)
"""

test_vars = {'testName': None, 'testShortname': None}
test_vars['testName'] = raw_input('Test Name: ')
test_vars['testShortname'] = raw_input("Test Short Name: ")
test_vars['testSNlower'] = test_vars['testShortname'].lower()

fname = os.path.join('plugins', test_vars['testSNlower']+'.py')

if os.path.exists(fname):
    print 'WARNING! File named "%s" already exists.' % fname
{'fraction_non_alphanumeric': 0.1210906174819567, 'fraction_numerical': 0.0005346164127238706, 'mean_word_length': 3.631188118811881, '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': '5068538', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1111, 'n_words': 373}