def _print_model_folder_sample(self, model_path_tokens, valid_section_folder_keys, control_option): """ Prints a model sample for a folder in a model, when more than just the section_name[:] is provided. :param model_path_tokens: a Python list of path elements built from model path :param valid_section_folder_keys: A list of valid folder names for the model section in the path :param control_option: A command-line switch that controls what is output to STDOUT """ _method_name = '_print_model_folder_sample' section_name = model_path_tokens[0] top_folder = model_path_tokens[1] if top_folder not in valid_section_folder_keys: ex = exception_helper.create_cla_exception( 'WLSDPLY-10110', section_name + ':', top_folder, ', '.join(valid_section_folder_keys)) self._logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex print("") # write the parent folders, with indention and any name folders included indent = 0 model_location = LocationContext() for token in model_path_tokens: if indent > 0: code, message = self._alias_helper.is_valid_model_folder_name( model_location, token) if code != ValidationCodes.VALID: ex = exception_helper.create_cla_exception( "WLSDPLY-05027", message) self._logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex model_location.append_location(token) _print_indent(token + ":", indent) indent += 1 if self._has_multiple_folders(model_location): short_name = self._get_short_name(model_location) name = "'" + short_name + "-1'" _print_indent(name + ":", indent) indent += 1 # list the attributes and folders, as specified if model_help_utils.show_attributes(control_option): # Print the attributes associated with location context self._print_attributes_sample(model_location, indent) if model_help_utils.show_folders(control_option): self._print_subfolders_sample(model_location, control_option, indent) return
def _print_model_section_sample(self, section_name, valid_section_folder_keys, control_option): """ Prints a model sample for a section of a model, when just the section_name[:] is provided :param section_name: the name of the model section :param valid_section_folder_keys: list of the valid top folders in the specified section :param control_option: A command-line switch that controls what is output to STDOUT """ _method_name = '_print_model_section_sample' print _print_indent(section_name + ":", 0) if model_help_utils.show_attributes(control_option): attributes_location = self._alias_helper.get_model_section_attribute_location( section_name) if attributes_location is not None: self._print_attributes_sample(attributes_location, 1) if model_help_utils.show_folders(control_option): model_location = LocationContext() valid_section_folder_keys.sort() self._print_subfolder_keys_sample(model_location, valid_section_folder_keys, control_option, 1)
def _print_model_folder_sample(self, section_name, model_path_tokens, control_option): """ Prints a model sample for a folder in a model, when more than just the section_name[:] is provided. :param section_name: the name of the model section :param model_path_tokens: a Python list of path elements built from model path :param control_option: A command-line switch that controls what is output to STDOUT """ _method_name = '_print_model_folder_sample' print("") # write the parent folders leading up to the specified folder. # include any name folders. indent = 0 _print_indent(section_name + ":", indent) indent += 1 model_path = section_name + ":" current_folder = self._schema for token in model_path_tokens[1:]: properties = _get_properties(current_folder) valid_subfolder_keys = _get_folder_names(properties) if token not in valid_subfolder_keys: ex = exception_helper.create_cla_exception( "WLSDPLY-10111", model_path, token, ', '.join(valid_subfolder_keys)) self._logger.throwing(ex, class_name=self._class_name, method_name=_method_name) raise ex current_folder = properties[token] _print_indent(token + ":", indent) indent += 1 if wko_schema_helper.is_multiple_folder(current_folder): name = token + '-1' _print_indent(name + ":", indent) indent += 1 model_path = model_path + "/" + token # list the attributes and folders, as specified if model_help_utils.show_attributes(control_option): # Print the attributes associated with schema folder self._print_attributes_sample(current_folder, indent) if model_help_utils.show_folders(control_option): self._print_subfolders_sample(current_folder, control_option, indent, model_path)
def _print_model_section_help(self, section_name, valid_section_folder_keys, control_option): """ Prints the help for a section of a model, when just the section_name[:] is provided :param section_name: the name of the model section :param valid_section_folder_keys: list of the valid top folders in the specified section :param control_option: A command-line switch that controls what is output to STDOUT """ _method_name = '_print_model_section_help' self._logger.finest('1 section_name={0}', section_name, class_name=_class_name, method_name=_method_name) location_path = '%s:' % section_name self._logger.finest('1 location_path={0}', location_path, class_name=_class_name, method_name=_method_name) model_section = _format_message('WLSDPLY-10106', location_path) # Print 'Section: <model_section>' label and field print _print_indent(model_section, 0) if model_help_utils.show_attributes(control_option): attributes_location = self._alias_helper.get_model_section_attribute_location( section_name) if attributes_location is not None: self._print_attributes_help(attributes_location, 1) if model_help_utils.show_folders(control_option): print _print_indent(_format_message('WLSDPLY-10107'), 1) valid_section_folder_keys.sort() for section_folder_key in valid_section_folder_keys: _print_indent(section_folder_key, 2) if control_option == ControlOptions.RECURSIVE: model_location = LocationContext().append_location( section_folder_key) self._print_subfolders_help(model_location, control_option, 2)
def _print_model_section_sample(self, section_name, control_option): """ Prints a model sample for a section of a model, when just the section_name[:] is provided :param section_name: the name of the model section :param control_option: A command-line switch that controls what is output to STDOUT """ _method_name = '_print_model_section_sample' print path = section_name + ":" _print_indent(path, 0) if model_help_utils.show_attributes(control_option): self._print_attributes_sample(self._schema, 1) if model_help_utils.show_folders(control_option): self._print_subfolders_sample(self._schema, control_option, 1, path)
def _print_model_folder_help(self, model_path_tokens, valid_section_folder_keys, control_option): """ Prints the help for a folder in a model, when more than just the section_name[:] is provided. The section name in the first token was already validated. :param model_path_tokens: a Python list of path elements built from model path :param valid_section_folder_keys: A list of valid folder names for the model section in the path :param control_option: A command-line switch that controls what is output to STDOUT """ _method_name = '_print_model_folder_help' self._logger.finest( '1 model_path_tokens={0}, control_option={1}, valid_section_folder_keys={0}', str(model_path_tokens), ControlOptions.from_value(control_option), str(valid_section_folder_keys), class_name=_class_name, method_name=_method_name) section_name = model_path_tokens[0] top_folder = model_path_tokens[1] if top_folder not in valid_section_folder_keys: ex = exception_helper.create_cla_exception( 'WLSDPLY-10110', section_name + ':', top_folder, ', '.join(valid_section_folder_keys)) self._logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex # Populate the location context using model_path_tokens[1:] model_location = LocationContext() for folder_key in model_path_tokens[1:]: model_location.append_location(folder_key) name_token = self._alias_helper.get_name_token(model_location) if name_token is not None: model_location.add_name_token(name_token, '%s-0' % folder_key) self._logger.finest('2 model_location={0}', model_location, class_name=_class_name, method_name=_method_name) folder_path = '/'.join(model_path_tokens[1:]) model_path = _format_message('WLSDPLY-10105', '%s:/%s' % (section_name, folder_path)) type_name = self._get_folder_type_name(model_location) if type_name is not None: model_path += " (" + type_name + ")" # Print 'Path: <model_section>' header print _print_indent(model_path, 0) if model_help_utils.show_attributes(control_option): # Print the attributes associated with location context self._print_attributes_help(model_location, 1) if model_help_utils.show_folders(control_option): # Print the folders associated with location context print _print_indent(_format_message('WLSDPLY-10107'), 1) self._print_subfolders_help(model_location, control_option, 1) self._logger.exiting(class_name=_class_name, method_name=_method_name) return