コード例 #1
0
def createCoreOptions():

    parser = OptionParser(
        usage=
        "Usage: %prog [core options] [input/output/task options] [other options]"
    )
    group = OptionGroup(parser, "Core options")
    group.add_option(
        "--other_app_dir",
        action="append",
        dest="other_dirs",
        metavar="dir",
        help=
        "additional directory to load a task from. Optional and repeatable.")
    group.add_option(
        "--settings_file",
        dest="settings_file",
        metavar="file",
        help=
        "a file of settings to use which overwrites existing settings. The file should be a Python config file in the style of the template in etc/MAT_settings.config.in. Optional."
    )
    group.add_option(
        "--task",
        dest="task",
        type="string",
        metavar="task",
        action="callback",
        callback=_taskCallback,
        help=
        "name of the task to use. Obligatory if the system knows of more than one task. Known tasks are: "
        + ", ".join(PLUGIN_DIR.keys()))
    MAT.ExecutionContext.addOptions(group)
    parser.add_option_group(group)
    return parser
コード例 #2
0
        except KeyError:
            parentNode.children[newChild.label] = [newChild]
    else:
        parentNode.children[newChild.label] = newChild


#
# Toplevel
#

from MAT.Operation import OptionParser, OptionGroup

parser = OptionParser(usage = """Usage: %prog [options] mat_1_3_root task_xml [outdir]

mat_1_3_root: a 1.3 final MAT root directory, typically src/MAT in the 1.3 distribution
task_xml: the task.xml file to update. The original file will be written to task.xml.1_3, and the new
  file, no matter what this name is, is task.xml. This way, you can repeatedly update the
  1.3 task.xml file if you need to
outdir: the directory to save the task.xml files to. Optional. By default, this will be the same
  directory you started with.""")

parser.add_option("--print_to_stdout", action = "store_true",
                  help = "if present, print to stdout instead of task.xml, and don't copy the original")
parser.add_option("--cheat_on_1_3_requirement", action = "store_true",
                  help = "don't require that the mat_1_3_root actually be 1.3, but permit early versions of 2.0")
options, args = parser.parse_args()

if len(args) not in (2, 3):
    parser.print_help()
    sys.exit(1)

[MAT_1_3_ROOT, TASK_XML] = args[:2]
コード例 #3
0
        return json.dumps(finalJsonData)


#
# Toplevel
#

from MAT.Operation import OptionParser, OptionGroup

import MAT.PluginMgr

PLUGIN_DIR = MAT.PluginMgr.LoadPlugins()

parser = OptionParser(usage="""Usage: %prog [options] task outfile

task: the name of a MAT task. Known tasks are: """ +
                      ", ".join(PLUGIN_DIR.keys()) + """
outfile: the output file to write the JSON version of the annotation info to. If the file
  is '-', the JSON will be written to standard output.""")

parser.add_option(
    "--dont_remove_redundant_info",
    action="store_true",
    help=
    "By default, the tool removes redundant information to improve readability. If this flag is present, the redundant information will be retained. Both the Java library and the Javascript standalone viewer are configured to repopulate redundant information."
)
parser.add_option(
    "--compact",
    action="store_true",
    help=
    "By default, the tool pretty-prints its JSON output. If this flag is present, the JSON will not be pretty-printed."
)
コード例 #4
0
sys.path.insert(0, MAT_PKG_PYLIB)

# Must import MAT so that sys.path is enhanced.

import MAT

PLUGIN_DIR = MAT.PluginMgr.LoadPlugins()

#
# Toplevel
#

from MAT.Operation import CmdlineOpArgumentAggregator, OptionParser, OptionGroup
from MAT.Score import WriteableTable

parser = OptionParser(usage="Usage: %prog [options]")
AGGREGATOR = CmdlineOpArgumentAggregator(parser)
CONCORDANCE_WINDOW = 32


def UsageError(msg):
    global parser
    print >> sys.stderr, msg
    parser.print_help()
    sys.exit(1)


def _fileTypeCallback(optionObj, flag, value, parser):
    global AGGREGATOR
    setattr(parser.values, optionObj.dest, value)
    try:
コード例 #5
0
PLUGIN_DIR = MAT.PluginMgr.LoadPlugins(*OTHER_DIRS)

#
# Toplevel
#

from MAT.Operation import OptionParser, OptionGroup

# The command-line processing will be very similar to MATEngine, except there's
# no directory option. And then there's whether it's a workspace operation or not.
# So a combination of both. But since we're not actually building an engine, we
# can't do progressive enhancement, except for the input and output formats.

parser = OptionParser(
    usage=
    "Usage: MATWebClient [ do_steps | ws_import_file | ws_operation ] [ options ]"
)

if len(sys.argv) < 2:
    print "Error: not enough arguments."
    parser.print_help()
    sys.exit(1)

if sys.argv[1] == "do_steps":
    group = OptionGroup("Options for do_steps")
    group.add_option(
        "--task",
        dest="task",
        type="string",
        metavar="task",
        action="callback",
コード例 #6
0
MAT_PKG_PYLIB = "MF_MAT_PKG_PYLIB"
sys.path.insert(0, MAT_PKG_PYLIB)

# Must import MAT so that sys.path is enhanced.

import MAT

PLUGIN_DIR = MAT.PluginMgr.LoadPlugins()

#
# Toplevel
#

from MAT.Operation import CmdlineOpArgumentAggregator, OptionParser, OptionGroup

parser = OptionParser(
    usage="Usage: %prog [task option] [config name option] [other options]")
AGGREGATOR = CmdlineOpArgumentAggregator(parser)

group = OptionGroup(parser, "Task option")
group.add_option(
    "--task",
    metavar="task",
    dest="task",
    type="string",
    help=
    "name of the task to use. Must be the first argument, if present. Obligatory if the system knows of more than one task. Known tasks are: "
    + ", ".join(PLUGIN_DIR.keys()))
parser.add_option_group(group)

group = OptionGroup(parser, "Config name option")
group.add_option(
コード例 #7
0
MAT_PKG_PYLIB = "MF_MAT_PKG_PYLIB"
sys.path.insert(0, MAT_PKG_PYLIB)

#
# Toplevel
#

# This was gutted from MATEngine.

import MAT

from MAT.Operation import OptionParser, OptionGroup

PLUGIN_DIR = MAT.PluginMgr.LoadPlugins()

parser = OptionParser()
AGGREGATOR = MAT.Operation.CmdlineOpArgumentAggregator(parser)

# We want to be able to present progressive help, so we first want
# to be able to construct a core option parser, which we can print
# out if --task is missing or there is more than one task.

# Once the task and workflow are set, you can add the
# other options.


def _inputFileTypeCallback(optionObj, flag, value, parser):
    global AGGREGATOR
    setattr(parser.values, optionObj.dest, value)
    try:
        cls = MAT.DocumentIO.getInputDocumentIOClass(value)
コード例 #8
0
import MAT
from MAT.Operation import OptionParser, OptionGroup
from MAT.Workspace import WorkspaceGeneralOperation, WorkspaceOperation, CMDLINE_AVAILABLE_MASK

def _allOperations(cls, lst):
    if (cls.name is not None) and cls.availability & CMDLINE_AVAILABLE_MASK:
        lst.append(cls.name)
    for c in cls.__subclasses__():
        _allOperations(c, lst)
ALL_OPERATIONS = []
_allOperations(WorkspaceGeneralOperation, ALL_OPERATIONS)

parser = OptionParser(usage = """Usage: %prog [options] <dir> create ...
""" + "\n".join(["       %prog [options] <dir> " + op + " ..." for op in ALL_OPERATIONS]) + \
"""

Provide the directory and operation followed by --help for more detailed help.""")
parser.add_option("--other_app_dir", action = "append",
                  dest="other_dirs",
                  help="additional directory to load a task from. Optional.")
MAT.ExecutionContext.addOptions(parser)

parser.disable_interspersed_args()

coreOptions, args = parser.parse_args()

if len(args) < 1:
    parser.print_help()
    sys.exit(1)
コード例 #9
0
    newWs.task.workspaceUpdate1To2(newWs, oldWorkspace, basenames, initialUser)

    print "Dumping workspace database."

    newWs.runOperation("dump_database", [], fromCmdline=True)


#
# Toplevel
#

from MAT.Operation import OptionParser, OptionGroup

parser = OptionParser(
    usage="""Usage: %prog [options] old_workspace new_workspace initial_user

old_workspace: a pre-2.0 MAT workspace directory
new_workspace: a location for your 2.0-compliant workspace copy. This directory must not already exist.
initial_user: a user to register as the first user for your workspace""")
MAT.ExecutionContext.addOptions(parser)
options, args = parser.parse_args()
MAT.ExecutionContext.extractOptions(options)
from MAT.ExecutionContext import _DEBUG

if len(args) != 3:
    parser.print_help()
    sys.exit(1)

[OLD_WORKSPACE, NEW_WORKSPACE, INITIAL_USER] = args

# First, we need to make sure the old directory really is a workspace, and that it's
# a version 1 workspace. Obviously, we can't do that by opening the workspace,
コード例 #10
0
# file LICENSE for license terms.

import os, sys

MAT_PKG_PYLIB = "MF_MAT_PKG_PYLIB"
sys.path.insert(0, MAT_PKG_PYLIB)

import MAT

PLUGIN_DIR = MAT.PluginMgr.LoadPlugins()

from MAT.Operation import OptionParser, OptionGroup

parser = OptionParser(usage = """Usage: %prog [options] task_name output_doc pivot_doc otherdoc...

task_name: the name of a known task. Known tasks are: """ + ", ".join(PLUGIN_DIR.keys()) + """
output_doc: the file to save the comparison document to.
pivot_doc: the document to which each of the other documents will be compared.
otherdoc...: a sequence of other documents, which all share the same signal with the pivot_doc.""")

# Progressive enhancement.
from MAT.Operation import CmdlineOpArgumentAggregator
AGGREGATOR = CmdlineOpArgumentAggregator(parser)

parser.add_activation_option("--file_type", AGGREGATOR, MAT.DocumentIO.DocumentIO, subtype = "inputArgs",
                             classFilters = ["excluderaw"],
                             default = "mat-json", help = "The file type of the input documents. Default is mat-json.")
parser.add_option("--similarity_profile", dest="similarity_profile",
                 metavar = "profile",
                 help = "If provided, the name of a similarity profile in the specified task.")
options, args = parser.parse_args()
コード例 #11
0
# file LICENSE for license terms.

import os, sys

MAT_PKG_PYLIB = "MF_MAT_PKG_PYLIB"
sys.path.insert(0, MAT_PKG_PYLIB)

#
# Toplevel
#

from MAT.Operation import OptionParser
import MAT.ExecutionContext

parser = OptionParser(usage = """Usage: %prog [options] <xml_file>

<xml_file>: An experiment XML file""")
parser.add_option("--force", action = "store_true",
                  dest = "force",
                  help = "redo all analysis")
parser.add_option("--batch_test_runs", action = "store_true",
                  dest = "batch_test_runs",
                  help = "don't interleave test runs with model builds")
parser.add_option("--mark_done", action = "store_true",
                  dest = "mark_done",
                  help = "forcibly mark the experiment as done")
parser.add_option("--exp_dir", dest = "exp_dir",
                  metavar = "dir",
                  help = "optionally, the directory to use for the record of the experiment. This directory path is used when no 'dir' attribute is provided to the <experiment> element in the experiment XML file.")
parser.add_option("--pattern_dir", dest = "pattern_dir",
                  metavar = "dir",