本文整理汇总了Python中coalib.settings.FunctionMetadata.FunctionMetadata.filter_parameters方法的典型用法代码示例。如果您正苦于以下问题:Python FunctionMetadata.filter_parameters方法的具体用法?Python FunctionMetadata.filter_parameters怎么用?Python FunctionMetadata.filter_parameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coalib.settings.FunctionMetadata.FunctionMetadata
的用法示例。
在下文中一共展示了FunctionMetadata.filter_parameters方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from coalib.settings.FunctionMetadata import FunctionMetadata [as 别名]
# 或者: from coalib.settings.FunctionMetadata.FunctionMetadata import filter_parameters [as 别名]
def run(self, filename, file, **kwargs):
# Get the **kwargs params to forward to `generate_config()`
# (from `_create_config()`).
generate_config_kwargs = FunctionMetadata.filter_parameters(
self._get_generate_config_metadata(), kwargs)
with self._create_config(
filename,
file,
**generate_config_kwargs) as config_file:
# And now retrieve the **kwargs for `create_arguments()`.
create_arguments_kwargs = (
FunctionMetadata.filter_parameters(
self._get_create_arguments_metadata(), kwargs))
arguments = (self.get_executable(),) + tuple(
self.create_arguments(
filename, file, config_file,
**create_arguments_kwargs))
self.debug("Running '{}'".format(' '.join(arguments)))
output = run_shell_command(
arguments,
stdin="".join(file) if options["use_stdin"] else None)
output = tuple(compress(
output,
(options["use_stdout"], options["use_stderr"])))
if len(output) == 1:
output = output[0]
process_output_kwargs = FunctionMetadata.filter_parameters(
self._get_process_output_metadata(), kwargs)
return self.process_output(output, filename, file,
**process_output_kwargs)
示例2: run
# 需要导入模块: from coalib.settings.FunctionMetadata import FunctionMetadata [as 别名]
# 或者: from coalib.settings.FunctionMetadata.FunctionMetadata import filter_parameters [as 别名]
def run(self, filename, file, **kwargs):
# Get the **kwargs params to forward to `generate_config()`
# (from `_create_config()`).
generate_config_kwargs = FunctionMetadata.filter_parameters(
self._get_generate_config_metadata(), kwargs)
with self._create_config(
filename,
file,
**generate_config_kwargs) as config_file:
# And now retrieve the **kwargs for `create_arguments()`.
create_arguments_kwargs = (
FunctionMetadata.filter_parameters(
self._get_create_arguments_metadata(), kwargs))
args = self.create_arguments(filename, file, config_file,
**create_arguments_kwargs)
try:
args = tuple(args)
except TypeError:
self.err('The given arguments '
'{!r} are not iterable.'.format(args))
return
arguments = (self.get_executable(),) + args
self.debug("Running '{}'".format(' '.join(arguments)))
output = run_shell_command(
arguments,
stdin=''.join(file) if options['use_stdin'] else None,
cwd=self.get_config_dir())
output = tuple(compress(
output,
(options['use_stdout'], options['use_stderr'])))
if len(output) == 1:
output = output[0]
process_output_kwargs = FunctionMetadata.filter_parameters(
self._get_process_output_metadata(), kwargs)
return self.process_output(output, filename, file,
**process_output_kwargs)
示例3: run
# 需要导入模块: from coalib.settings.FunctionMetadata import FunctionMetadata [as 别名]
# 或者: from coalib.settings.FunctionMetadata.FunctionMetadata import filter_parameters [as 别名]
def run(self, filename=None, file=None, **kwargs):
"""
Runs the wrapped tool.
:param filename:
The filename of the file being linted. ``None`` for project
scope.
:param file:
The content of the file being linted. ``None`` for project
scope.
"""
# Get the **kwargs params to forward to `generate_config()`
# (from `_create_config()`).
generate_config_kwargs = FunctionMetadata.filter_parameters(
self._get_generate_config_metadata(), kwargs)
with self._create_config(
filename,
file,
**generate_config_kwargs) as config_file:
# And now retrieve the **kwargs for `create_arguments()`.
create_arguments_kwargs = (
FunctionMetadata.filter_parameters(
self._get_create_arguments_metadata(), kwargs))
# The interface of create_arguments is different for local
# and global bears, therefore we must check here, what kind
# of bear we have.
if isinstance(self, LocalBear):
args = self.create_arguments(filename,
file, config_file,
**create_arguments_kwargs)
else:
args = self.create_arguments(config_file,
**create_arguments_kwargs)
try:
args = tuple(args)
except TypeError:
self.err('The given arguments '
'{!r} are not iterable.'.format(args))
return
arguments = (self.get_executable(),) + args
self.debug("Running '{}'".format(
' '.join(str(arg) for arg in arguments)))
output = run_shell_command(
arguments,
stdin=''.join(file) if options['use_stdin'] else None,
cwd=self.get_config_dir())
output = tuple(compress(
output,
(options['use_stdout'], options['use_stderr'])))
if len(output) == 1:
output = output[0]
process_output_kwargs = FunctionMetadata.filter_parameters(
self._get_process_output_metadata(), kwargs)
return self.process_output(output, filename, file,
**process_output_kwargs)
示例4: run
# 需要导入模块: from coalib.settings.FunctionMetadata import FunctionMetadata [as 别名]
# 或者: from coalib.settings.FunctionMetadata.FunctionMetadata import filter_parameters [as 别名]
def run(self, filename=None, file=None, **kwargs):
"""
Runs the wrapped tool.
:param filename:
The filename of the file being linted. ``None`` for project
scope.
:param file:
The content of the file being linted. ``None`` for project
scope.
"""
# Get the **kwargs params to forward to `generate_config()`
# (from `_create_config()`).
generate_config_kwargs = FunctionMetadata.filter_parameters(
self._get_generate_config_metadata(), kwargs)
with self._create_config(
filename,
file,
**generate_config_kwargs) as config_file:
# And now retrieve the **kwargs for `create_arguments()`.
create_arguments_kwargs = (
FunctionMetadata.filter_parameters(
self._get_create_arguments_metadata(), kwargs))
# The interface of create_arguments is different for local
# and global bears, therefore we must check here, what kind
# of bear we have.
if isinstance(self, LocalBear):
args = self.create_arguments(filename,
file, config_file,
**create_arguments_kwargs)
else:
args = self.create_arguments(config_file,
**create_arguments_kwargs)
try:
args = tuple(args)
except TypeError:
self.err('The given arguments '
'{!r} are not iterable.'.format(args))
return
arguments = (self.get_executable(),) + args
self.debug("Running '{}'".format(
' '.join(str(arg) for arg in arguments)))
result = run_shell_command(
arguments,
stdin=''.join(file) if options['use_stdin'] else None,
cwd=self.get_config_dir())
stdout, stderr = result
output = []
if options['use_stdout']:
output.append(stdout)
elif stdout:
logging.warning(
'{}: Discarded stdout: {}'.format(
self.__class__.__name__, stdout))
if options['use_stderr']:
output.append(stderr)
elif stderr:
logging.warning(
'{}: Discarded stderr: {}'.format(
self.__class__.__name__, stderr))
if result.code:
logging.warning(
'{}: Exit code {}'.format(
self.__class__.__name__, result.code))
if not any(output):
logging.info(
'{}: No output; skipping processing'.format(
self.__class__.__name__))
return
if options['strip_ansi']:
output = tuple(map(strip_ansi, output))
if len(output) == 1:
output = output[0]
else:
output = tuple(output)
process_output_kwargs = FunctionMetadata.filter_parameters(
self._get_process_output_metadata(), kwargs)
return self.process_output(output, filename, file,
**process_output_kwargs)