id
stringlengths
24
24
input
stringlengths
69
2.76k
output
stringlengths
97
21.1k
630629e752e177c0ba46a0fb
def send_document(url, data, timeout=10, method="post", *args, **kwargs): """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, o...
def send_document(url, data, timeout=10, method="post", *args, **kwargs): """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, o...
6306091073426c38ae68acac
def dict_insert(dic, val, key, *keys): """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 k...
def dict_insert(dic, val, key, *keys): """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 k...
6306091a73426c38ae68acc8
def list_of_file_names(settings_dirs, spec_option): """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)
6306091b73426c38ae68acd7
@classmethod def ansible_config_manager(cls): """Gets the ansible config manager. """
@classmethod def ansible_config_manager(cls): """Gets the ansible config manager. """ return cls._get_service(ServiceName.ANSIBLE_CONFIG_MANAGER)
6306091b73426c38ae68acd9
@classmethod def workspace_manager(cls): """Gets the workspace manager. """
@classmethod def workspace_manager(cls): """Gets the workspace manager. """ return cls._get_service(ServiceName.WORKSPACE_MANAGER)
6306091b73426c38ae68acda
@classmethod def plugins_manager(cls): """Gets the plugin manager. """
@classmethod def plugins_manager(cls): """Gets the plugin manager. """ return cls._get_service(ServiceName.PLUGINS_MANAGER)
6306091c73426c38ae68acdc
@classmethod def validate_from_content(cls, spec_content=None): """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 ...
@classmethod def validate_from_content(cls, spec_content=None): """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 ...
6306091c73426c38ae68acdd
@classmethod def validate_from_file(cls, yaml_file=None): """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 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 ...
6306091d73426c38ae68ace5
def _include_groups(self, parser_dict): """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 for grp in self.spec_dict.get('shared_groups', []) ...
6306092373426c38ae68acfa
def get_spec_defaults(self): """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 """ # first try to get environment v...
6306092973426c38ae68ad01
def get_deprecated_args(self): """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 None: result[option.get('deprecates'...
6306092c73426c38ae68ad02
def validate_arg_deprecation(self, cli_args, answer_file_args): """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 arguments from cli :param answer_file_args: the dict of arguments from files """ for deprecated, deprecates in self.get_deprecated...
6306092d73426c38ae68ad04
def get_parser_option_specs(self, command_name): """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, virsh, ospd, etc...) :return: the list of all command options """ options = [] for parser in self.iterate_parsers(): ...
6306092d73426c38ae68ad05
def get_option_spec(self, command_name, argument_name): """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['name'] == argument_name), {})
6306092d73426c38ae68ad06
def get_silent_args(self, args): """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 = [] for (parser_name, parser_dict, arg_name, arg_value, arg_spec) in self._iterate_received_a...
6306092d73426c38ae68ad07
def validate_requires_args(self, args): """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 method to resolve dict_merge. """ result = col...
6306092d73426c38ae68ad08
def _get_conditionally_required_args(self, command_name, options_spec, args): """List arguments with ``required_when`` condition matched. :param command_name: the command name. :param options_spec: the list of command spec options. :param ar...
def _get_conditionally_required_args(self, command_name, options_spec, args): """List arguments with ``required_when`` condition matched. :param command_name: the command name. :param options_spec: the list of command spec options. :param ar...
6306092e73426c38ae68ad09
def validate_length_args(self, args): """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 parser_name, parser_dict in args.items(): for spec_option in \ self.spe...
6306092e73426c38ae68ad0a
def validate_choices_args(self, args): """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 = [] for parser_name, parser_dict in args.items(): for spec_option in \ self...
6306092e73426c38ae68ad0b
def validate_min_max_args(self, args): """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 = [] for parser_name, parser_dict in args.items(): for spec_option in \ self....
6306092e73426c38ae68ad0d
def create_complex_argumet_type(self, subcommand, type_name, option_name, spec_option): """Build the complex argument type :param subcommand: the command name :param type_name: the complex type name :param option_name: the option name :par...
def create_complex_argumet_type(self, subcommand, type_name, option_name, spec_option): """Build the complex argument type :param subcommand: the command name :param type_name: the complex type name :param option_name: the option name :par...
6306092e73426c38ae68ad0f
def get_nested_custom_and_control_args(self, args): """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 ...
def get_nested_custom_and_control_args(self, args): """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 ...
6306092e73426c38ae68ad11
@staticmethod def merge_extra_vars(vars_dict, extra_vars=None): """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 into :param extra_vars: List of extra-vars """ for extra_var in extra_vars or []: if extra_var.startsw...
6306092f73426c38ae68ad13
def ansible_playbook(ir_workspace, ir_plugin, playbook_path, verbose=None, extra_vars=None, ansible_args=None): """Wraps the 'ansible-playbook' CLI. :param ir_workspace: An Infrared Workspace object represents the active workspace :param ir_plugin: An InfraredPlugin object of th...
def ansible_playbook(ir_workspace, ir_plugin, playbook_path, verbose=None, extra_vars=None, ansible_args=None): """Wraps the 'ansible-playbook' CLI. :param ir_workspace: An Infrared Workspace object represents the active workspace :param ir_plugin: An InfraredPlugin object of th...
6306093273426c38ae68ad15
def _run_playbook(cli_args, vars_dict, ir_workspace, ir_plugin): """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 ...
def _run_playbook(cli_args, vars_dict, ir_workspace, ir_plugin): """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 ...
63060ada73426c38ae68ad31
def _convert_non_cli_args(self, parser_name, values_dict): """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 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 ...
63060b1a73426c38ae68ad3e
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 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 dictionary contains the plugin's properties """ with open(os.path.join(plugin_dir, PLUGIN_SPEC)) as fp: spec_yaml = yaml.safe_load(fp) ...
63060b1b73426c38ae68ad42
def inject_config(self): """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.environ['ANSIBLE_CONFIG']
63060b1b73426c38ae68ad43
def extend_cli(self, root_subparsers): """ 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_subparsers = workspace_plugin.add_subparsers(dest="command0") # create create_parser = works...
62ece4982e6aefcf4aabbd64
def strip_root(path, root): """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 Exception("Path %s is not in root %s" % (path, root))...