id stringlengths 23 25 | content stringlengths 1.16k 88k | max_stars_repo_path stringlengths 12 48 |
|---|---|---|
codereval_python_data_201 | Helper method to send a document via POST.
Additional ``*args`` and ``**kwargs`` will be passed on to ``requests.post``.
:arg url: Full url to send to, including protocol
:arg data: Dictionary (will be form-encoded), bytes, or file-like object to send in the body
:arg timeout: Seconds to wait for response (defaults t... | federation/utils/network.py |
codereval_python_data_202 | insert a value of a nested key into a dictionary
to insert value for a nested key, all ancestor keys should be given as
method's arguments
example:
dict_insert({}, 'val', 'key1.key2'.split('.'))
:param dic: a dictionary object to insert the nested key value into
:param val: a value to insert to the given dictionar... | infrared/core/utils/dict_utils.py |
codereval_python_data_203 | Create a new IniType complex type
def list_of_file_names(settings_dirs, spec_option):
"""Create a new IniType complex type
"""
return cli.ListOfFileNames("ListOfFileNames", settings_dirs, None,
spec_option)
import os
import pytest
from infrared.core.cli import cli
from in... | tests/test_complex_types.py |
codereval_python_data_204 | Gets the ansible config manager.
@classmethod
def ansible_config_manager(cls):
"""Gets the ansible config manager. """
return cls._get_service(ServiceName.ANSIBLE_CONFIG_MANAGER)
"""Service locator for the IR services
Stores and resolves all the dependencies for the services.
"""
import os
i... | infrared/core/services/__init__.py |
codereval_python_data_205 | Gets the workspace manager.
@classmethod
def workspace_manager(cls):
"""Gets the workspace manager. """
return cls._get_service(ServiceName.WORKSPACE_MANAGER)
"""Service locator for the IR services
Stores and resolves all the dependencies for the services.
"""
import os
import sys
from infr... | infrared/core/services/__init__.py |
codereval_python_data_206 | Gets the plugin manager.
@classmethod
def plugins_manager(cls):
"""Gets the plugin manager. """
return cls._get_service(ServiceName.PLUGINS_MANAGER)
"""Service locator for the IR services
Stores and resolves all the dependencies for the services.
"""
import os
import sys
from infrared.core.... | infrared/core/services/__init__.py |
codereval_python_data_207 | validates that spec (YAML) content has all required fields
:param spec_content: content of spec file
:raise IRValidatorException: when mandatory data
is missing in spec file
:return: Dictionary with data loaded from a spec (YAML) file
@classmethod
def validate_from_content(cls, spec_content=None):
"""... | infrared/core/utils/validators.py |
codereval_python_data_208 | Loads & validates that a YAML file has all required fields
:param yaml_file: Path to YAML file
:raise IRValidatorException: when mandatory data is missing in file
:return: Dictionary with data loaded from a YAML file
@classmethod
def validate_from_file(cls, yaml_file=None):
"""Loads & validates that a... | infrared/core/utils/validators.py |
codereval_python_data_209 | Resolves the include dict directive in the spec files.
def _include_groups(self, parser_dict):
"""Resolves the include dict directive in the spec files. """
for group in parser_dict.get('include_groups', []):
# ensure we have that group
grp_dict = next(
(grp ... | infrared/core/inspector/helper.py |
codereval_python_data_210 | Resolve arguments' values from spec and other sources.
def get_spec_defaults(self):
"""Resolve arguments' values from spec and other sources. """
def spec_default_getter(option):
"""Getter function to retrieve the default value from spec.
:param option: argument name
... | infrared/core/inspector/inspector.py |
codereval_python_data_211 | Returning dict with options which deprecate others.
def get_deprecated_args(self):
"""Returning dict with options which deprecate others. """
result = collections.defaultdict(dict)
for parser, option in self.spec_helper.iterate_option_specs():
if option.get('deprecates') is not... | infrared/core/inspector/inspector.py |
codereval_python_data_212 | Validates and prints the deprecated arguments.
:param cli_args: the dict of arguments from cli
:param answer_file_args: the dict of arguments from files
def validate_arg_deprecation(self, cli_args, answer_file_args):
"""Validates and prints the deprecated arguments.
:param cli_args: the dict of ... | infrared/core/inspector/inspector.py |
codereval_python_data_213 | Gets all the options for the specified command
:param command_name: the command name (main, virsh, ospd, etc...)
:return: the list of all command options
def get_parser_option_specs(self, command_name):
"""Gets all the options for the specified command
:param command_name: the command name (main,... | infrared/core/inspector/helper.py |
codereval_python_data_214 | Gets the specification for the specified option name.
def get_option_spec(self, command_name, argument_name):
"""Gets the specification for the specified option name. """
options = self.get_parser_option_specs(command_name)
return next((opt for opt in options
if opt['n... | infrared/core/inspector/helper.py |
codereval_python_data_215 | list of silenced argument
:param args: The received arguments.
:return: list, slienced argument names
def get_silent_args(self, args):
"""list of silenced argument
:param args: The received arguments.
:return: list, slienced argument names
"""
silent_args_names = []
... | infrared/core/inspector/inspector.py |
codereval_python_data_216 | Check if all the required arguments have been provided.
def validate_requires_args(self, args):
"""Check if all the required arguments have been provided. """
silent_args = self.get_silent_args(args)
def validate_parser(parser_name, expected_options, parser_args):
"""Helper me... | infrared/core/inspector/inspector.py |
codereval_python_data_217 | List arguments with ``required_when`` condition matched.
:param command_name: the command name.
:param options_spec: the list of command spec options.
:param args: the received input arguments
:return: list, list of argument names with matched ``required_when``
condition
def _get_conditionally_required_args(... | infrared/core/inspector/inspector.py |
codereval_python_data_218 | Check if value of arguments is not longer than length specified.
:param args: The received arguments.
def validate_length_args(self, args):
"""Check if value of arguments is not longer than length specified.
:param args: The received arguments.
"""
invalid_options = []
for... | infrared/core/inspector/inspector.py |
codereval_python_data_219 | Check if value of choice arguments is one of the available choices.
:param args: The received arguments.
def validate_choices_args(self, args):
"""Check if value of choice arguments is one of the available choices.
:param args: The received arguments.
"""
invalid_options = []
... | infrared/core/inspector/inspector.py |
codereval_python_data_220 | Check if value of arguments is between minimum and maximum values.
:param args: The received arguments.
def validate_min_max_args(self, args):
"""Check if value of arguments is between minimum and maximum values.
:param args: The received arguments.
"""
invalid_options = []
... | infrared/core/inspector/inspector.py |
codereval_python_data_221 | Build the complex argument type
:param subcommand: the command name
:param type_name: the complex type name
:param option_name: the option name
:param spec_option: option's specifications
:return: the complex type instance
def create_complex_argumet_type(self, subcommand, type_name, option_name,
... | infrared/core/inspector/inspector.py |
codereval_python_data_222 | Split input arguments to control nested and custom.
Controls arguments: control the IR behavior. These arguments
will not be put into the spec yml file
Nested arguments: are used by the Ansible playbooks and will be put
into the spec yml file.
Custom arguments: Custom ansible variables to be used instead of th... | infrared/core/inspector/inspector.py |
codereval_python_data_223 | Extend ``vars_dict`` with ``extra-vars``
:param vars_dict: Dictionary to merge extra-vars into
:param extra_vars: List of extra-vars
@staticmethod
def merge_extra_vars(vars_dict, extra_vars=None):
"""Extend ``vars_dict`` with ``extra-vars``
:param vars_dict: Dictionary to merge extra-vars int... | infrared/core/settings.py |
codereval_python_data_224 | Wraps the 'ansible-playbook' CLI.
:param ir_workspace: An Infrared Workspace object represents the active
workspace
:param ir_plugin: An InfraredPlugin object of the current plugin
:param playbook_path: the playbook to invoke
:param verbose: Ansible verbosity level
:param extra_vars: dict. Passed to Ansible as extra-v... | infrared/core/execute.py |
codereval_python_data_225 | Runs ansible cli with vars dict
:param vars_dict: dict, Will be passed as Ansible extra-vars
:param cli_args: the list of command line arguments
:param ir_workspace: An Infrared Workspace object represents the active
workspace
:param ir_plugin: An InfraredPlugin object of the current plugin
:return: ansible results
... | infrared/core/execute.py |
codereval_python_data_226 | Casts arguments to correct types by modifying values_dict param.
By default all the values are strings.
:param parser_name: The command name, e.g. main, virsh, ospd, etc
:param values_dict: The dict of with arguments
def _convert_non_cli_args(self, parser_name, values_dict):
"""Casts arguments to correct... | infrared/core/inspector/inspector.py |
codereval_python_data_227 | Creates a flat dict from the plugin spec
:param plugin_dir: A path to the plugin's dir
:return: A flatten dictionary contains the plugin's properties
def get_plugin_spec_flatten_dict(plugin_dir):
"""Creates a flat dict from the plugin spec
:param plugin_dir: A path to the plugin's dir
:return: A flatten ... | tests/test_plugins.py |
codereval_python_data_228 | Set the environment variable for config path, if it is undefined.
def inject_config(self):
"""Set the environment variable for config path, if it is undefined."""
if os.environ.get('ANSIBLE_CONFIG', '') == '':
os.environ['ANSIBLE_CONFIG'] = self.ansible_config_path
return os.env... | infrared/core/services/ansible_config.py |
codereval_python_data_229 | Adds the spec cli options to to the main entry point.
:param subparser: the subparser object to extend.
def extend_cli(self, root_subparsers):
workspace_plugin = root_subparsers.add_parser(
self.name,
help=self.kwargs["description"],
**self.kwargs)
workspace_sub... | infrared/main.py |
codereval_python_data_230 | Remove root from path, throw exception on failure.
def strip_root(path, root):
"""Remove root from path, throw exception on failure."""
root = root.rstrip(os.sep) # ditch any trailing path separator
if os.path.commonprefix((path, root)) == root:
return os.path.relpath(path, start=root)
raise E... | ocfl/dispositor.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.