root/galaxy-central/eggs/twill-0.9-py2.6.egg/twill/extensions/argparse.py

リビジョン 3, 1.1 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1"""
2Extension functions for parsing sys.argv.
3
4Commands:
5
6   get_args -- load all command-line arguments after the last --
7      into $arg1...$argN.
8   
9"""
10
11import twill.utils
12
13def get_args(require=0):
14    """
15    >> get_args [<require>]
16
17    Load the command line arguments after the last '--' into $arg1...$argN,
18    optionally requiring at least 'require' such arguments.
19    """
20    from twill import commands, namespaces, shell, errors
21
22    global_dict, local_dict = namespaces.get_twill_glocals()
23
24    require = int(require)
25
26    if len(shell.twillargs) < require:
27        from twill.errors import TwillAssertionError
28        raise TwillAssertionError("too few arguments; %d rather than %d" % \
29                                    (len(shell.twillargs), require,))
30
31    if shell.twillargs:
32        for i, arg in enumerate(shell.twillargs):
33            global_dict["arg%d" % (i + 1,)] = arg
34
35        print>>commands.OUT, "get_args: loaded %d args as $arg1..$arg%d." % \
36                             (i + 1, i + 1)
37    else:
38        print>>commands.OUT, "no arguments to parse!"
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。