本文整理匯總了Python中argcomplete.completers.FilesCompleter方法的典型用法代碼示例。如果您正苦於以下問題:Python completers.FilesCompleter方法的具體用法?Python completers.FilesCompleter怎麽用?Python completers.FilesCompleter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類argcomplete.completers
的用法示例。
在下文中一共展示了completers.FilesCompleter方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _get_arg_parser
# 需要導入模塊: from argcomplete import completers [as 別名]
# 或者: from argcomplete.completers import FilesCompleter [as 別名]
def _get_arg_parser(self, doc_parser=False):
description = textwrap.dedent(__doc__)
examples = textwrap.dedent('''
mdt-info-protocol my_protocol.prtcl
''')
epilog = self._format_examples(doc_parser, examples)
parser = argparse.ArgumentParser(description=description, epilog=epilog,
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('protocol',
action=mdt.lib.shell_utils.get_argparse_extension_checker(['.prtcl']),
help='the protocol file').completer = FilesCompleter(['prtcl'], directories=False)
return parser
示例2: _get_arg_parser
# 需要導入模塊: from argcomplete import completers [as 別名]
# 或者: from argcomplete.completers import FilesCompleter [as 別名]
def _get_arg_parser(self, doc_parser=False):
description = textwrap.dedent(__doc__)
examples = textwrap.dedent('''
mdt-create-bvec-bval my_protocol.prtcl
mdt-create-bvec-bval my_protocol.prtcl bvec_name.bvec bval_name.bval
''')
epilog = self._format_examples(doc_parser, examples)
parser = argparse.ArgumentParser(description=description, epilog=epilog,
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('protocol', help='the protocol file').completer = FilesCompleter()
parser.add_argument('bvec', help="the output bvec file", nargs='?', default=None).completer = FilesCompleter()
parser.add_argument('bval', help="the output bvec file", nargs='?', default=None).completer = FilesCompleter()
return parser
示例3: _get_arg_parser
# 需要導入模塊: from argcomplete import completers [as 別名]
# 或者: from argcomplete.completers import FilesCompleter [as 別名]
def _get_arg_parser(self, doc_parser=False):
description = textwrap.dedent(__doc__)
parser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('items', metavar='items', type=str, nargs='*', help='the directory or file(s)',
default=None).completer = FilesCompleter()
parser.add_argument('-c', '--config', type=str,
help='Use the given initial configuration').completer = \
FilesCompleter(['conf'], directories=False)
parser.add_argument('-m', '--maximize', action='store_true', help="Maximize the shown window")
parser.add_argument('--to-file', type=str, help="If set, export the figure to the given filename")
parser.add_argument('--width', type=int, help="The width of the output file when --to-file is set")
parser.add_argument('--height', type=int, help="The height of the output file when --to-file is set")
parser.add_argument('--dpi', type=int, help="The dpi of the output file when --to-file is set")
return parser
示例4: _get_arg_parser
# 需要導入模塊: from argcomplete import completers [as 別名]
# 或者: from argcomplete.completers import FilesCompleter [as 別名]
def _get_arg_parser(self, doc_parser=False):
description = textwrap.dedent(__doc__)
parser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('-d', '--dir', metavar='dir', type=str, help='the base directory for the file choosers',
default=None).completer = FilesCompleter()
return parser
示例5: _get_arg_parser
# 需要導入模塊: from argcomplete import completers [as 別名]
# 或者: from argcomplete.completers import FilesCompleter [as 別名]
def _get_arg_parser(self, doc_parser=False):
description = textwrap.dedent(__doc__)
examples = textwrap.dedent('''
mdt-get-example-data
mdt-get-example-data .
''')
epilog = self._format_examples(doc_parser, examples)
parser = argparse.ArgumentParser(description=description, epilog=epilog,
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('dir', metavar='dir', type=str, nargs='?', help='the output directory',
default=None).completer = FilesCompleter()
return parser
示例6: _get_arg_parser
# 需要導入模塊: from argcomplete import completers [as 別名]
# 或者: from argcomplete.completers import FilesCompleter [as 別名]
def _get_arg_parser(self, doc_parser=False):
description = textwrap.dedent(__doc__)
examples = textwrap.dedent('''
mdt-create-roi-slice mask.nii.gz
mdt-create-roi-slice mask.nii.gz -d 1 -s 50
mdt-create-roi-slice mask.nii.gz -d 1 -s 50 -o my_roi_1_50.nii.gz
''')
epilog = self._format_examples(doc_parser, examples)
parser = argparse.ArgumentParser(description=description, epilog=epilog,
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('mask',
action=mdt.lib.shell_utils.get_argparse_extension_checker(['.nii', '.nii.gz', '.hdr', '.img']),
help='the mask to select a slice from').completer = \
FilesCompleter(['nii', 'gz', 'hdr', 'img'], directories=False)
parser.add_argument('-d', '--dimension', type=int, help="The dimension to index (0, 1, 2, ...). Default is 2.")
parser.add_argument('-s', '--slice', type=int, help="The slice to use in the selected dimension (0, 1, 2, ...)."
"Defaults to center of chosen dimension.")
parser.add_argument('-o', '--output-name',
action=mdt.lib.shell_utils.get_argparse_extension_checker(['.nii', '.nii.gz', '.hdr', '.img']),
help='the filename of the output file. Default is <mask_name>_<dim>_<slice>.nii.gz').\
completer = FilesCompleter(['nii', 'gz', 'hdr', 'img'], directories=False)
return parser
示例7: _get_arg_parser
# 需要導入模塊: from argcomplete import completers [as 別名]
# 或者: from argcomplete.completers import FilesCompleter [as 別名]
def _get_arg_parser(self, doc_parser=False):
description = textwrap.dedent(__doc__)
examples = textwrap.dedent('''
mdt-math-protocol protocol.prtcl 'G *= 1e-3' -o new_protocol.prtcl
mdt-math-protocol p.prtcl 'G *= 1e-3; TR /= 1000; TE /= 1000'
mdt-math-protocol p.prtcl 'del(G)'
mdt-math-protocol p.prtcl 'TE = 50e-3'
mdt-math-protocol p.prtcl -a Delta.txt 'Delta = files[0]'
''')
epilog = self._format_examples(doc_parser, examples)
parser = argparse.ArgumentParser(description=description, epilog=epilog,
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('input_protocol', metavar='input_protocol', type=str,
help="The input protocol")
parser.add_argument('expr', metavar='expr', type=str,
help="The expression to evaluate.")
parser.add_argument('-o', '--output_file',
help='the output protocol, defaults to the input protocol.').completer = FilesCompleter()
parser.add_argument('-a', '--additional-file', type=str, action='append', dest='additional_files',
help='additional file to load to be used for columns, placed in \'files\' list by index')
return parser
示例8: parser_disk
# 需要導入模塊: from argcomplete import completers [as 別名]
# 或者: from argcomplete.completers import FilesCompleter [as 別名]
def parser_disk(self, parser):
parser.description = "Add a disk to the current parser"
p = parser.add_argument('path', help='path to the disk image that you want to mount')
try:
from argcomplete.completers import FilesCompleter
p.completer = FilesCompleter([".dd", ".e01", ".aff", ".DD", ".E01", ".AFF"])
except ImportError:
pass
parser.add_argument("--mounter", choices=DISK_MOUNTERS, help="the method to mount with")
示例9: FilesCompleter
# 需要導入模塊: from argcomplete import completers [as 別名]
# 或者: from argcomplete.completers import FilesCompleter [as 別名]
def FilesCompleter(*, allowednames, directories):
return None
示例10: add_arguments
# 需要導入模塊: from argcomplete import completers [as 別名]
# 或者: from argcomplete.completers import FilesCompleter [as 別名]
def add_arguments(self, parser, cli_name):
arg = parser.add_argument('-k', '--keystore-root-path', help='root path of keystore')
arg.completer = DirectoriesCompleter()
parser.add_argument(
'-e', '--enclaves', nargs='*', default=[],
help='list of identities, aka ROS security enclave names')
arg = parser.add_argument(
'-p', '--policy-files', nargs='*', default=[],
help='list of policy xml file paths')
arg.completer = FilesCompleter(
allowednames=('xml'), directories=False)
示例11: add_arguments
# 需要導入模塊: from argcomplete import completers [as 別名]
# 或者: from argcomplete.completers import FilesCompleter [as 別名]
def add_arguments(self, parser, cli_name):
arg = parser.add_argument(
'POLICY_FILE_PATH', help='path of the policy xml file')
arg.completer = FilesCompleter(
allowednames=('xml'), directories=False)
add_strategy_node_arguments(parser)
示例12: load_arguments
# 需要導入模塊: from argcomplete import completers [as 別名]
# 或者: from argcomplete.completers import FilesCompleter [as 別名]
def load_arguments(self, _):
with self.argument_context('portal dashboard list') as c:
c.argument('resource_group_name', resource_group_name_type,
help='The name of the resource group.')
with self.argument_context('portal dashboard show') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('name', options_list=[
'--name', '-n'], help='The name of the dashboard.')
with self.argument_context('portal dashboard create') as c:
c.argument('resource_group_name', resource_group_name_type,
help='The name of the resource group.')
c.argument('name', options_list=[
'--name', '-n'], help='The name of the dashboard.')
c.argument('location', arg_type=get_location_type(self.cli_ctx),
validator=get_default_location_from_resource_group)
c.argument('tags', tags_type)
c.argument('input_path', type=file_type,
help='The path to the dashboard properties JSON file.', completer=FilesCompleter())
with self.argument_context('portal dashboard update') as c:
c.argument('resource_group_name', resource_group_name_type,
help='The name of the resource group.')
c.argument('name', options_list=[
'--name', '-n'], help='The name of the dashboard.')
c.argument('input_path', type=file_type,
help='The path to the dashboard properties JSON file.', completer=FilesCompleter())
with self.argument_context('portal dashboard delete') as c:
c.argument('resource_group_name', resource_group_name_type,
help='The name of the resource group.')
c.argument('name', options_list=[
'--name', '-n'], help='The name of the dashboard.')
with self.argument_context('portal dashboard import') as c:
c.argument('resource_group_name', resource_group_name_type,
help='The name of the resource group.')
c.argument('name', options_list=[
'--name', '-n'], help='The name of the dashboard.')
c.argument('input_path', type=file_type,
help='The path to the dashboard json file.', completer=FilesCompleter())
示例13: _get_arg_parser
# 需要導入模塊: from argcomplete import completers [as 別名]
# 或者: from argcomplete.completers import FilesCompleter [as 別名]
def _get_arg_parser(self, doc_parser=False):
description = textwrap.dedent(__doc__)
examples = textwrap.dedent('''
mdt-create-protocol data.bvec data.bval
mdt-create-protocol data.bvec data.bval -o my_protocol.prtcl
mdt-create-protocol data.bvec data.bval
mdt-create-protocol data.bvec data.bval --Delta 30 --delta 20
mdt-create-protocol data.bvec data.bval --sequence-timing-units 's' --Delta 0.03
mdt-create-protocol data.bvec data.bval --TE ../my_TE_file.txt
''')
epilog = self._format_examples(doc_parser, examples)
epilog += textwrap.dedent("""
Additional columns can be specified using the syntax: \"--{column_name} {value}\" structure.
Please note that these additional values will not be auto-converted from ms to s.
""")
parser = argparse.ArgumentParser(description=description, epilog=epilog,
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('bvec', help='the gradient vectors file').completer = FilesCompleter()
parser.add_argument('bval', help='the gradient b-values').completer = FilesCompleter()
parser.add_argument('-s', '--bval-scale-factor', type=float,
help="We expect the b-values in the output protocol in units of s/m^2. "
"Example use: 1 or 1e6. The default is autodetect.")
parser.add_argument('-o', '--output_file',
help='the output protocol, defaults to "<bvec_name>.prtcl" in the same '
'directory as the bvec file.').completer = FilesCompleter()
parser.add_argument('--sequence-timing-units', choices=('ms', 's'), default='ms',
help="The units of the sequence timings. The default is 'ms' which we will convert to 's'.")
parser.add_argument('--G',
help="The gradient amplitudes in T/m.")
parser.add_argument('--maxG',
help="The maximum gradient amplitude in T/m. This is only useful if we need to guess "
"big Delta and small delta. Default is 0.04 T/m")
parser.add_argument('--Delta',
help="The big Delta to use, either a single number or a file with either a single number "
"or one number per gradient direction.")
parser.add_argument('--delta',
help="The small delta to use, either a single number or a file with either a single number "
"or one number per gradient direction.")
parser.add_argument('--TE',
help="The TE to use, either a single number or a file with either a single number "
"or one number per gradient direction.")
parser.add_argument('--TR',
help="The TR to use, either a single number or a file with either a single number "
"or one number per gradient direction.")
return parser
示例14: _get_arg_parser
# 需要導入模塊: from argcomplete import completers [as 別名]
# 或者: from argcomplete.completers import FilesCompleter [as 別名]
def _get_arg_parser(self, doc_parser=False):
description = textwrap.dedent(__doc__)
examples = textwrap.dedent('''
mdt-create-mask data.nii.gz data.prtcl
mdt-create-mask data.nii.gz data.prtcl -o data_mask.nii.gz
mdt-create-mask data.nii.gz data.prtcl -o data_mask.nii.gz --median-radius 2
''')
epilog = self._format_examples(doc_parser, examples)
parser = argparse.ArgumentParser(description=description, epilog=epilog,
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('dwi',
action=mdt.lib.shell_utils.get_argparse_extension_checker(['.nii', '.nii.gz', '.hdr', '.img']),
help='the diffusion weighted image').completer = FilesCompleter(['nii', 'gz', 'hdr', 'img'],
directories=False)
parser.add_argument('protocol',
action=mdt.lib.shell_utils.get_argparse_extension_checker(['.prtcl']),
help='the protocol file, see mdt-create-protocol').\
completer = FilesCompleter(['prtcl'], directories=False)
parser.add_argument('-o', '--output-name',
action=mdt.lib.shell_utils.get_argparse_extension_checker(['.nii', '.nii.gz', '.hdr', '.img']),
help='the filename of the output file. Default is <dwi_name>_mask.nii.gz').completer = \
FilesCompleter(['nii', 'gz', 'hdr', 'img'], directories=False)
parser.add_argument('--median-radius', type=int, default=4,
help="Radius (in voxels) of the applied median filter (default 4).")
parser.add_argument('--mask-threshold', type=float, default=0,
help="Everything below this b-value threshold is masked away (value in s/m^2, default 0)")
parser.add_argument('--numpass', type=int, default=4,
help="Number of pass of the median filter (default 4).")
parser.add_argument('--dilate', type=int, default=1,
help="Number of iterations for binary dilation (default 1).")
parser.add_argument('--cl-device-ind', type=int, nargs='*', choices=self.available_devices.keys(),
help="The index of the device we would like to use. This follows the indices "
"in mdt-list-devices and defaults to the first GPU.")
return parser