def _check_section_option_is_valid(self, section, option): """ Sanity check the section and option are strings """ if not is_text_string(section): raise RuntimeError("section is not a text string") if not is_text_string(option): raise RuntimeError("option is not a text string")
def _check_section_option_is_valid(self, option, second): """ Sanity check the section and option are strings and return the flattened option key """ if second is None: if not is_text_string(option): raise TypeError('Found invalid type ({}) for option ({}) must be a string'.format(type(option), option)) return option else: # fist argument is actually the section/group if not is_text_string(option): raise TypeError('Found invalid type ({}) for section ({}) must be a string'.format(type(option), option)) if not is_text_string(second): raise TypeError('Found invalid type ({}) for option ({}) must be a string'.format(type(second), second)) return joinsettings(option, second)
def figure_title(workspaces, fig_num): """Create a default figure title from a single workspace, list of workspaces or workspace names and a figure number. The name of the first workspace in the list is concatenated with the figure number. :param workspaces: A single workspace, list of workspaces or workspace name/list of workspace names :param fig_num: An integer denoting the figure number :return: A title for the figure """ def wsname(w): return w.name() if hasattr(w, 'name') else w if is_text_string(workspaces) or not isinstance(workspaces, collections.Sequence): # assume a single workspace first = workspaces else: assert len(workspaces) > 0 first = workspaces[0] return wsname(first) + '-' + str(fig_num)