diff --git a/exhale/configs.py b/exhale/configs.py index e54dbbf..dd6ce39 100644 --- a/exhale/configs.py +++ b/exhale/configs.py @@ -1342,7 +1342,7 @@ def apply_sphinx_configurations(app): if breathe_default_project not in breathe_projects: raise ConfigError( - "The given breathe_default_project='{0}' was not a valid key in `breathe_projects`:\n{1}".format( + "The given breathe_default_project='{}' was not a valid key in `breathe_projects`:\n{}".format( breathe_default_project, breathe_projects ) ) @@ -1405,7 +1405,7 @@ def apply_sphinx_configurations(app): raise ConfigError(val_error.format(key=key, exp=expected_type, got=val_t)) # Make sure that a value was provided (e.g. no empty strings) if not val: - raise ConfigError("Non-empty value for key [{0}] required.".format(key)) + raise ConfigError("Non-empty value for key [{}] required.".format(key)) # If the string represents a path, make it absolute if make_absolute: # Directories are made absolute relative to app.confdir (where conf.py is) @@ -1417,7 +1417,7 @@ def apply_sphinx_configurations(app): keys_processed.append(key) except Exception as e: raise ExtensionError( - "Critical error: unable to set `global {0}` to `{1}` in exhale.configs:\n{2}".format( + "Critical error: unable to set `global {}` to `{}` in exhale.configs:\n{}".format( key, val, e ) ) @@ -1440,7 +1440,7 @@ def apply_sphinx_configurations(app): raise ValueError except: raise ConfigError( - "The given `containmentFolder` [{0}] must be a *SUBDIRECTORY* of [{1}].".format( + "The given `containmentFolder` [{}] must be a *SUBDIRECTORY* of [{}].".format( containmentFolder, app.srcdir ) ) @@ -1464,7 +1464,7 @@ def apply_sphinx_configurations(app): # Make sure the doxygen strip path is an exclude-able path if not os.path.exists(doxygenStripFromPath): raise ConfigError( - "The path given as `doxygenStripFromPath` ({0}) does not exist!".format(doxygenStripFromPath) + "The path given as `doxygenStripFromPath` ({}) does not exist!".format(doxygenStripFromPath) ) #################################################################################### @@ -1538,7 +1538,7 @@ def apply_sphinx_configurations(app): keys_processed.append(key) except Exception as e: raise ExtensionError( - "Critical error: unable to set `global {0}` to `{1}` in exhale.configs:\n{2}".format( + "Critical error: unable to set `global {}` to `{}` in exhale.configs:\n{}".format( key, val, e ) ) @@ -1598,7 +1598,7 @@ def item_or_index(item, idx): pattern, flags = item except Exception as e: raise ConfigError( - "listingExclude item {0} cannot be unpacked as `pattern, flags = item`:\n{1}".format( + "listingExclude item {} cannot be unpacked as `pattern, flags = item`:\n{}".format( item_or_index(item, idx), e ) ) @@ -1607,7 +1607,7 @@ def item_or_index(item, idx): regex = re.compile(pattern, flags) except Exception as e: raise ConfigError( - "Unable to compile specified listingExclude {0}:\n{1}".format( + "Unable to compile specified listingExclude {}:\n{}".format( item_or_index(item, idx), e ) ) @@ -1631,14 +1631,14 @@ def item_or_index(item, idx): regex = re.compile(key) except Exception as e: raise ConfigError( - "The `lexerMapping` key [{0}] is not a valid regular expression: {1}".format(key, e) + "The `lexerMapping` key [{}] is not a valid regular expression: {}".format(key, e) ) # Make sure the provided lexer is available try: lex = lexers.find_lexer_class_by_name(val) except Exception as e: raise ConfigError( - "The `lexerMapping` value of [{0}] for key [{1}] is not a valid Pygments lexer.".format( + "The `lexerMapping` value of [{}] for key [{}] is not a valid Pygments lexer.".format( val, key ) ) @@ -1676,19 +1676,19 @@ def item_or_index(item, idx): ''')) for key in keys_expected: - err.write("- {0}\n".format(key)) + err.write("- {}\n".format(key)) err.write(textwrap.dedent(''' Available keys: ''')) for key in keys_available: - err.write("- {0}\n".format(key)) + err.write("- {}\n".format(key)) err.write(textwrap.dedent(''' The Mismatch(es): ''')) for key in (keys_available ^ keys_expected): - err.write("- {0}\n".format(key)) + err.write("- {}\n".format(key)) err_msg = err.getvalue() err.close() @@ -1717,7 +1717,7 @@ def similar(a, b): extra_error = StringIO() extra_error.write("Exhale found unexpected keys in `exhale_args`:\n") for key in extras: - extra_error.write(" - Extra key: {0}\n".format(key)) + extra_error.write(" - Extra key: {}\n".format(key)) potentials = [] for mate in potential_keys_lower: similarity = similar(key, mate) @@ -1727,7 +1727,7 @@ def similar(a, b): if potentials: potentials = reversed(sorted(potentials)) for rank, mate in potentials: - extra_error.write(" - {0:2.2f}% match with: {1}\n".format(rank, mate)) + extra_error.write(" - {:2.2f}% match with: {}\n".format(rank, mate)) extra_error_str = extra_error.getvalue() extra_error.close() @@ -1743,7 +1743,7 @@ def similar(a, b): # fullToctreeMaxDepth > 5 may produce other sphinx issues unrelated to exhale if fullToctreeMaxDepth > 5: logger.warning( - "Exhale: `fullToctreeMaxDepth={0}` is greater than 5 and may build errors for non-html.".format( + "Exhale: `fullToctreeMaxDepth={}` is greater than 5 and may build errors for non-html.".format( fullToctreeMaxDepth ) ) @@ -1762,7 +1762,7 @@ def similar(a, b): provided_keys = set(customSpecificationsMapping.keys()) diff = provided_keys - expected_keys if diff: - raise ConfigError("Found extra keys in `customSpecificationsMapping`: {0}".format(diff)) + raise ConfigError("Found extra keys in `customSpecificationsMapping`: {}".format(diff)) # Sanity check #3: make sure the return values are all strings for key in customSpecificationsMapping: val_t = type(customSpecificationsMapping[key]) @@ -1792,7 +1792,7 @@ def similar(a, b): if exhaleUseDoxyfile: doxyfile_path = os.path.abspath(os.path.join(app.confdir, "Doxyfile")) if not os.path.exists(doxyfile_path): - raise ConfigError("The file [{0}] does not exist".format(doxyfile_path)) + raise ConfigError("The file [{}] does not exist".format(doxyfile_path)) here = os.path.abspath(os.curdir) if here == app.confdir: @@ -1805,7 +1805,7 @@ def similar(a, b): start = utils.get_time() if returnPath: logger.info(utils.info( - "Exhale: changing directories to [{0}] to execute Doxygen.".format(app.confdir) + "Exhale: changing directories to [{}] to execute Doxygen.".format(app.confdir) )) os.chdir(app.confdir) logger.info(utils.info("Exhale: executing doxygen.")) @@ -1813,7 +1813,7 @@ def similar(a, b): # Being overly-careful to put sphinx back where it was before potentially erroring out if returnPath: logger.info(utils.info( - "Exhale: changing directories back to [{0}] after Doxygen.".format(returnPath) + "Exhale: changing directories back to [{}] after Doxygen.".format(returnPath) )) os.chdir(returnPath) if status: @@ -1821,7 +1821,7 @@ def similar(a, b): else: end = utils.get_time() logger.info(utils.progress( - "Exhale: doxygen ran successfully in {0}.".format(utils.time_string(start, end)) + "Exhale: doxygen ran successfully in {}.".format(utils.time_string(start, end)) )) else: if exhaleUseDoxyfile: @@ -1835,11 +1835,11 @@ def similar(a, b): # Make sure that the files we need are actually there. if not os.path.isdir(doxy_xml_dir): raise ConfigError( - "Exhale: the specified folder [{0}] does not exist. Has Doxygen been run?".format(doxy_xml_dir) + "Exhale: the specified folder [{}] does not exist. Has Doxygen been run?".format(doxy_xml_dir) ) index = os.path.join(doxy_xml_dir, "index.xml") if not os.path.isfile(index): - raise ConfigError("Exhale: the file [{0}] does not exist. Has Doxygen been run?".format(index)) + raise ConfigError("Exhale: the file [{}] does not exist. Has Doxygen been run?".format(index)) # Legacy / debugging feature, warn of its purpose if generateBreatheFileDirectives: @@ -1881,7 +1881,7 @@ def similar(a, b): collapse_data = os.path.join(os.path.abspath(os.path.dirname(__file__)), "data", tree_data_static_base) if not os.path.isdir(collapse_data): raise ExtensionError( - "Exhale: the path to [{0}] was not found, possible installation error.".format(collapse_data) + "Exhale: the path to [{}] was not found, possible installation error.".format(collapse_data) ) else: all_files = tree_data_css + tree_data_js + tree_data_ext @@ -1892,7 +1892,7 @@ def similar(a, b): missing.append(path) if missing: raise ExtensionError( - "Exhale: the path(s) {0} were not found, possible installation error.".format(missing) + "Exhale: the path(s) {} were not found, possible installation error.".format(missing) ) # We have all the files we need, the extra files will be copied automatically by diff --git a/exhale/deploy.py b/exhale/deploy.py index cca1f98..575b39c 100644 --- a/exhale/deploy.py +++ b/exhale/deploy.py @@ -169,9 +169,9 @@ def _generate_doxygen(doxygen_input): # Make sure we had a valid execution of doxygen exit_code = doxygen_proc.returncode if exit_code != 0: - raise RuntimeError("Non-zero return code of [{0}] from 'doxygen'...".format(exit_code)) + raise RuntimeError("Non-zero return code of [{}] from 'doxygen'...".format(exit_code)) except Exception as e: - return "Unable to execute 'doxygen': {0}".format(e) + return "Unable to execute 'doxygen': {}".format(e) # returning None signals _success_ return None @@ -386,21 +386,21 @@ def explode(): utils.fancyError("Unable to create an `ExhaleRoot` object:") try: - sys.stdout.write("{0}\n".format(utils.info("Exhale: parsing Doxygen XML."))) + sys.stdout.write("{}\n".format(utils.info("Exhale: parsing Doxygen XML."))) start = utils.get_time() textRoot.parse() end = utils.get_time() - sys.stdout.write("{0}\n".format( - utils.progress("Exhale: finished parsing Doxygen XML in {0}.".format( + sys.stdout.write("{}\n".format( + utils.progress("Exhale: finished parsing Doxygen XML in {}.".format( utils.time_string(start, end) )) )) except: utils.fancyError("Exception caught while parsing:") try: - sys.stdout.write("{0}\n".format( + sys.stdout.write("{}\n".format( utils.info("Exhale: generating reStructuredText documents.") )) start = utils.get_time() @@ -408,8 +408,8 @@ def explode(): textRoot.generateFullAPI() end = utils.get_time() - sys.stdout.write("{0}\n".format( - utils.progress("Exhale: generated reStructuredText documents in {0}.".format( + sys.stdout.write("{}\n".format( + utils.progress("Exhale: generated reStructuredText documents in {}.".format( utils.time_string(start, end) )) )) diff --git a/exhale/graph.py b/exhale/graph.py index c0d8e86..9397063 100644 --- a/exhale/graph.py +++ b/exhale/graph.py @@ -316,7 +316,7 @@ def full_signature(self): """ if self.kind == "function": return "{template}{return_type} {name}({parameters})".format( - template="template <{0}> ".format(", ".join(self.template)) if self.template is not None else "", + template="template <{}> ".format(", ".join(self.template)) if self.template is not None else "", return_type=self.return_type, name=self.name, parameters=", ".join(self.parameters) @@ -348,7 +348,7 @@ def templateParametersStringAsRestList(self, nodeByRefid): if refid: # Easy case: the refid is something Exhale is explicitly documenting if refid in nodeByRefid: - link = "{0}_".format(nodeByRefid[refid].link_name) + link = "{}_".format(nodeByRefid[refid].link_name) else: # It's going to get generated by Breathe down the line, we need # to reference the page the directive will appear on. @@ -417,7 +417,7 @@ def baseOrDerivedListString(self, lst, nodeByRefid): # Include the prototype if prot: - bod_stream.write("``{0}".format(prot)) + bod_stream.write("``{}".format(prot)) please_close = True else: please_close = False @@ -449,7 +449,7 @@ def baseOrDerivedListString(self, lst, nodeByRefid): bod_stream.write("``") else: bod_stream.write(" ") - bod_stream.write("{0}``".format(string)) + bod_stream.write("{}``".format(string)) bod_stream.write("\n") bod_value = bod_stream.getvalue() @@ -824,7 +824,7 @@ def toHierarchy(self, hierarchyType, level, stream, lastChild=False): else: # Declare the relevant links needed for the Tree Views indent = " " * (level * 2) - next_indent = " {0}".format(indent) + next_indent = " {}".format(indent) # turn double underscores into underscores, then underscores into hyphens html_link = self.link_name.replace("__", "_").replace("_", "-") @@ -1179,17 +1179,17 @@ def discoverAllNodes(self): with codecs.open(doxygen_index_xml, "r", "utf-8") as index: index_contents = index.read() except: - raise RuntimeError("Could not read the contents of [{0}].".format(doxygen_index_xml)) + raise RuntimeError("Could not read the contents of [{}].".format(doxygen_index_xml)) try: index_soup = BeautifulSoup(index_contents, "lxml-xml") except: - raise RuntimeError("Could not parse the contents of [{0}] as an xml.".format(doxygen_index_xml)) + raise RuntimeError("Could not parse the contents of [{}] as an xml.".format(doxygen_index_xml)) doxygen_root = index_soup.doxygenindex if not doxygen_root: raise RuntimeError( - "Did not find root XML node named 'doxygenindex' parsing [{0}].".format(doxygen_index_xml) + "Did not find root XML node named 'doxygenindex' parsing [{}].".format(doxygen_index_xml) ) for compound in doxygen_root.find_all("compound"): @@ -1226,7 +1226,7 @@ def discoverAllNodes(self): try: page.soup = BeautifulSoup(node_xml_contents, "lxml-xml") except: - utils.fancyError("Unable to parse file xml [{0}]:".format(page.name)) + utils.fancyError("Unable to parse file xml [{}]:".format(page.name)) try: cdef = page.soup.doxygen.compounddef @@ -1241,7 +1241,7 @@ def discoverAllNodes(self): inner_pages = cdef.find_all("innerpage", recursive=False) utils.verbose_log( - "*** [{0}] had [{1}] innerpages found".format(page.name, len(inner_pages)), + "*** [{}] had [{}] innerpages found".format(page.name, len(inner_pages)), utils.AnsiColors.BOLD_MAGENTA ) @@ -1253,7 +1253,7 @@ def discoverAllNodes(self): # << verboseBuild utils.verbose_log( - " - [{0}]".format(node.name), + " - [{}]".format(node.name), utils.AnsiColors.BOLD_MAGENTA ) @@ -1285,7 +1285,7 @@ def discoverAllNodes(self): except: utils.fancyError( - "Could not process Doxygen xml for file [{0}]".format(f.name) + "Could not process Doxygen xml for file [{}]".format(f.name) ) self.pages = [page for page in self.pages if not page.parent] @@ -1299,7 +1299,7 @@ def discoverAllNodes(self): try: f.soup = BeautifulSoup(node_xml_contents, "lxml-xml") except: - utils.fancyError("Unable to parse file xml [{0}]:".format(f.name)) + utils.fancyError("Unable to parse file xml [{}]:".format(f.name)) try: cdef = f.soup.doxygen.compounddef @@ -1314,7 +1314,7 @@ def discoverAllNodes(self): # << verboseBuild utils.verbose_log( - "*** [{0}] had [{1}] innerclasses found".format(f.name, len(inner_classes)), + "*** [{}] had [{}] innerclasses found".format(f.name, len(inner_classes)), utils.AnsiColors.BOLD_MAGENTA ) @@ -1326,7 +1326,7 @@ def discoverAllNodes(self): # << verboseBuild utils.verbose_log( - " - [{0}]".format(node.name), + " - [{}]".format(node.name), utils.AnsiColors.BOLD_MAGENTA ) @@ -1357,7 +1357,7 @@ def discoverAllNodes(self): # << verboseBuild utils.verbose_log( - "*** [{0}] had [{1}] memberdef".format(f.name, len(memberdefs)), + "*** [{}] had [{}] memberdef".format(f.name, len(memberdefs)), utils.AnsiColors.BOLD_MAGENTA ) @@ -1369,7 +1369,7 @@ def discoverAllNodes(self): # << verboseBuild utils.verbose_log( - " - [{0}]".format(node.name), + " - [{}]".format(node.name), utils.AnsiColors.BOLD_MAGENTA ) @@ -1391,7 +1391,7 @@ def discoverAllNodes(self): except: utils.fancyError( - "Could not process Doxygen xml for file [{0}]".format(f.name) + "Could not process Doxygen xml for file [{}]".format(f.name) ) ###### TODO: explain how the parsing works // move it to exhale.parse @@ -1540,7 +1540,7 @@ def discoverAllNodes(self): node.def_in_file = candidates[0] # << verboseBuild utils.verbose_log(utils.info( - "Manually setting file definition of {0} {1} to [{2}]".format( + "Manually setting file definition of {} {} to [{}]".format( node.kind, node.name, node.def_in_file.location ), utils.AnsiColors.BOLD_CYAN @@ -1550,13 +1550,13 @@ def discoverAllNodes(self): # << verboseBuild err_msg = StringIO() err_msg.write(textwrap.dedent(''' - While attempting to discover the file that Doxygen refid `{0}` was + While attempting to discover the file that Doxygen refid `{}` was defined in, more than one candidate was found. The candidates were: '''.format(refid))) # NOTE: candidates should only ever contain File nodes (thus c.location # should exist, and already be populated). for c in candidates: - err_msg.write(" - path=[{0}], refid={1}\n".format(c.location, c.refid)) + err_msg.write(" - path=[{}], refid={}\n".format(c.location, c.refid)) err_msg.write("\n") utils.verbose_log(utils.critical(err_msg.getvalue())) # NOTE: no 'else' clause here, a warning about no file link generated is @@ -1570,8 +1570,8 @@ def discoverAllNodes(self): try: name_soup = BeautifulSoup(node_xml_contents, "lxml-xml") except: - utils.fancyError("Could not process [{0}]".format( - os.path.join(configs._doxygen_xml_output_directory, "{0}".format(node.refid)) + utils.fancyError("Could not process [{}]".format( + os.path.join(configs._doxygen_xml_output_directory, "{}".format(node.refid)) )) try: @@ -1652,7 +1652,7 @@ def prot_ref_str(soup_node): for derived in cdef.find_all("derivedcompoundref", recursive=False): node.derived_compounds.append(prot_ref_str(derived)) except: - utils.fancyError("Error processing Doxygen XML for [{0}]".format(node.name), "txt") + utils.fancyError("Error processing Doxygen XML for [{}]".format(node.name), "txt") def trackNodeIfUnseen(self, node): ''' @@ -1756,7 +1756,7 @@ def reparentUnions(self): else: # << verboseBuild utils.verbose_log( - "The union {0} has '::' in its name, but no parent was found!".format(u.name), + "The union {} has '::' in its name, but no parent was found!".format(u.name), utils.AnsiColors.BOLD_RED ) @@ -1848,10 +1848,10 @@ def renameToNamespaceScopes(self): ``external::MAX_DEPTH``. ''' for n in self.namespaces: - namespace_name = "{0}::".format(n.name) + namespace_name = "{}::".format(n.name) for child in n.children: if namespace_name not in child.name: - child.name = "{0}{1}".format(namespace_name, child.name) + child.name = "{}{}".format(namespace_name, child.name) def reparentNamespaces(self): ''' @@ -1918,7 +1918,7 @@ def fileRefDiscovery(self): be an enum declared inside of a namespace within this file. ''' if not os.path.isdir(configs._doxygen_xml_output_directory): - utils.fancyError("The doxygen xml output directory [{0}] is not valid!".format( + utils.fancyError("The doxygen xml output directory [{}] is not valid!".format( configs._doxygen_xml_output_directory )) @@ -1937,7 +1937,7 @@ def fileRefDiscovery(self): for f in self.files: doxygen_xml_file_ownerships[f] = [] try: - doxy_xml_path = os.path.join(configs._doxygen_xml_output_directory, "{0}.xml".format(f.refid)) + doxy_xml_path = os.path.join(configs._doxygen_xml_output_directory, "{}.xml".format(f.refid)) with codecs.open(doxy_xml_path, "r", "utf-8") as doxy_file: processing_code_listing = False # shows up at bottom of xml for line in doxy_file: @@ -1977,7 +1977,7 @@ def fileRefDiscovery(self): f.program_listing.append(line) except: utils.fancyError( - "Unable to process doxygen xml for file [{0}].\n".format(f.name) + "Unable to process doxygen xml for file [{}].\n".format(f.name) ) # @@ -2045,7 +2045,7 @@ def fileRefDiscovery(self): elif child.def_in_file != f: # << verboseBuild utils.verbose_log( - "Conflicting file definition for [{0}]: both [{1}] and [{2}] found.".format( + "Conflicting file definition for [{}]: both [{}] and [{}] found.".format( child.name, child.def_in_file.name, f.name ), utils.AnsiColors.BOLD_RED @@ -2076,7 +2076,7 @@ def filePostProcess(self): for f in self.files: if not f.location: sys.stderr.write(utils.critical( - "Cannot reparent file [{0}] because it's location was not discovered.\n".format( + "Cannot reparent file [{}] because it's location was not discovered.\n".format( f.name ) )) @@ -2084,7 +2084,7 @@ def filePostProcess(self): elif os.sep not in f.location: # top-level file, cannot parent do a directory utils.verbose_log( - "### File [{0}] with location [{1}] was identified as being at the top level".format( + "### File [{}] with location [{}] was identified as being at the top level".format( f.name, f.location ), utils.AnsiColors.BOLD_YELLOW @@ -2102,7 +2102,7 @@ def filePostProcess(self): if not found: sys.stderr.write(utils.critical( - "Could not find directory parent of file [{0}] with location [{1}].\n".format( + "Could not find directory parent of file [{}] with location [{}].\n".format( f.name, f.location ) )) @@ -2121,8 +2121,8 @@ def parseFunctionSignatures(self): parent_refid = func.parent.refid else: raise RuntimeError(textwrap.dedent(''' - Function [{0}] with refid=[{1}] had a parent of kind '{2}': - Parent name=[{3}], refid=[{4}]. + Function [{}] with refid=[{}] had a parent of kind '{}': + Parent name=[{}], refid=[{}]. Functions may only have namespace parents. Please report this issue online, Exhale has a parsing error. @@ -2281,7 +2281,7 @@ def generateFullAPI(self): root_directory_path.mkdir(parents=True, exist_ok=True) except Exception as e: utils.fancyError( - "Cannot create the directory {0} {1}".format(self.root_directory, e) + "Cannot create the directory {} {}".format(self.root_directory, e) ) # TODO: API root body does not need to be separate, but it does need to happen # after node documents are generated due to bad design (link names and other @@ -2307,7 +2307,7 @@ def generateAPIRootHeader(self): with codecs.open(self.full_root_file_path, "w", "utf-8") as generated_index: # Add the metadata if they requested it if configs.pageLevelConfigMeta: - generated_index.write("{0}\n\n".format(configs.pageLevelConfigMeta)) + generated_index.write("{}\n\n".format(configs.pageLevelConfigMeta)) if configs.rootFileTitle: generated_index.write(textwrap.dedent('''\ @@ -2324,10 +2324,10 @@ def generateAPIRootHeader(self): ))) if configs.afterTitleDescription: - generated_index.write("\n{0}\n\n".format(configs.afterTitleDescription)) + generated_index.write("\n{}\n\n".format(configs.afterTitleDescription)) except: utils.fancyError( - "Unable to create the root api file / header: {0}".format(self.full_root_file_path) + "Unable to create the root api file / header: {}".format(self.full_root_file_path) ) def generateNodeDocuments(self): @@ -2674,7 +2674,7 @@ def adjustFunctionTitles(self): '''.format( num=len(warn_functions), breathe_identifier=warn_functions[0].breathe_identifier() )) + \ - "".join(["\n- {0}".format(wf.full_signature()) for wf in warn_functions]) + \ + "".join(["\n- {}".format(wf.full_signature()) for wf in warn_functions]) + \ textwrap.dedent(''' Unfortunately, there are no known workarounds at this time. Your only options @@ -2715,7 +2715,7 @@ def generateSingleNodeRST(self, node): # Page header / linking. # ######################################################################## # generate a link label for every generated file - link_declaration = ".. _{0}:".format(node.link_name) + link_declaration = ".. _{}:".format(node.link_name) # acquire the file this was originally defined in if node.def_in_file: @@ -2723,13 +2723,13 @@ def generateSingleNodeRST(self, node): else: defined_in = ".. did not find file this was defined in" sys.stderr.write(utils.critical( - "Did not locate file that defined {0} [{1}]; no link generated.\n".format(node.kind, + "Did not locate file that defined {} [{}]; no link generated.\n".format(node.kind, node.name) )) # Add the metadata if they requested it if configs.pageLevelConfigMeta: - gen_file.write("{0}\n\n".format(configs.pageLevelConfigMeta)) + gen_file.write("{}\n\n".format(configs.pageLevelConfigMeta)) gen_file.write(textwrap.dedent('''\ {link} @@ -2781,7 +2781,7 @@ def generateSingleNodeRST(self, node): nested_children.sort(key=lambda x: x.name) nested_child_stream = StringIO() for nc in nested_children: - nested_child_stream.write("- :ref:`{0}`\n".format(nc.link_name)) + nested_child_stream.write("- :ref:`{}`\n".format(nc.link_name)) # extract the list of links and add them as a subsection in the header nested_child_string = nested_child_stream.getvalue() @@ -2798,7 +2798,7 @@ def generateSingleNodeRST(self, node): configs.SUB_SUB_SECTION_HEADING_CHAR ) )) - nested_defs = "{0}{1}\n".format(nested_defs, nested_child_string) + nested_defs = "{}{}\n".format(nested_defs, nested_child_string) if nested_type_of or nested_defs: heading = "Nested Relationships" @@ -2814,7 +2814,7 @@ def generateSingleNodeRST(self, node): ) ))) if nested_type_of: - gen_file.write("{0}\n\n".format(nested_type_of)) + gen_file.write("{}\n\n".format(nested_type_of)) if nested_defs: gen_file.write(nested_defs) @@ -2851,7 +2851,7 @@ def generateSingleNodeRST(self, node): configs.SUB_SUB_SECTION_HEADING_CHAR ) ))) - gen_file.write("{0}\n".format(node.baseOrDerivedListString( + gen_file.write("{}\n".format(node.baseOrDerivedListString( node.base_compounds, self.node_by_refid ))) if node.derived_compounds: @@ -2870,7 +2870,7 @@ def generateSingleNodeRST(self, node): configs.SUB_SUB_SECTION_HEADING_CHAR ) ))) - gen_file.write("{0}\n".format(node.baseOrDerivedListString( + gen_file.write("{}\n".format(node.baseOrDerivedListString( node.derived_compounds, self.node_by_refid ))) @@ -2934,7 +2934,7 @@ def generateSingleNodeRST(self, node): gen_file.write(specifications) except: utils.fancyError( - "Critical error while generating the file for [{0}].".format(node.file_name) + "Critical error while generating the file for [{}].".format(node.file_name) ) def generatePageDocuments(self): @@ -2962,11 +2962,11 @@ def generateSinglePageDocument(self, node): # Page header / linking. # ######################################################################## # generate a link label for every generated file - link_declaration = ".. _{0}:".format(node.link_name) + link_declaration = ".. _{}:".format(node.link_name) # Add the metadata if they requested it if configs.pageLevelConfigMeta: - gen_file.write("{0}\n\n".format(configs.pageLevelConfigMeta)) + gen_file.write("{}\n\n".format(configs.pageLevelConfigMeta)) gen_file.write(textwrap.dedent('''\ {link} @@ -3000,7 +3000,7 @@ def generateSinglePageDocument(self, node): gen_file.write(specifications) except: utils.fancyError( - "Critical error while generating the file for [{0}].".format(node.file_name) + "Critical error while generating the file for [{}].".format(node.file_name) ) def generateNamespaceNodeDocuments(self): @@ -3037,9 +3037,9 @@ def generateSingleNamespace(self, nspace): with codecs.open(nspace.file_name, "w", "utf-8") as gen_file: # Add the metadata if they requested it if configs.pageLevelConfigMeta: - gen_file.write("{0}\n\n".format(configs.pageLevelConfigMeta)) + gen_file.write("{}\n\n".format(configs.pageLevelConfigMeta)) - nspace.title = "{0} {1}".format(utils.qualifyKind(nspace.kind), nspace.name) + nspace.title = "{} {}".format(utils.qualifyKind(nspace.kind), nspace.name) # generate a link label for every generated file gen_file.write(textwrap.dedent(''' @@ -3056,22 +3056,22 @@ def generateSingleNamespace(self, nspace): brief, detailed = parse.getBriefAndDetailedRST(self, nspace) if brief: - gen_file.write("{0}\n\n".format(brief)) + gen_file.write("{}\n\n".format(brief)) # include the contents directive if requested contents = utils.contentsDirectiveOrNone(nspace.kind) if contents: - gen_file.write("{0}\n\n".format(contents)) + gen_file.write("{}\n\n".format(contents)) if detailed: - gen_file.write("{0}\n\n".format(detailed)) + gen_file.write("{}\n\n".format(detailed)) # generate the headings and links for the children children_string = self.generateNamespaceChildrenString(nspace) gen_file.write(children_string) except: utils.fancyError( - "Critical error while generating the file for [{0}]".format(nspace.file_name) + "Critical error while generating the file for [{}]".format(nspace.file_name) ) def generateNamespaceChildrenString(self, nspace): @@ -3196,7 +3196,7 @@ def generateFileNodeDocuments(self): if len(f.program_listing) > 0: include_program_listing = True lexer = utils.doxygenLanguageToPygmentsLexer(f.location, f.language) - full_program_listing = '.. code-block:: {0}\n\n'.format(lexer) + full_program_listing = '.. code-block:: {}\n\n'.format(lexer) # need to reformat each line to remove xml tags / put <>& back in for pgf_line in f.program_listing: @@ -3216,7 +3216,7 @@ def generateFileNodeDocuments(self): with codecs.open(f.program_file, "w", "utf-8") as gen_file: # Add the metadata if they requested it if configs.pageLevelConfigMeta: - gen_file.write("{0}\n\n".format(configs.pageLevelConfigMeta)) + gen_file.write("{}\n\n".format(configs.pageLevelConfigMeta)) # generate a link label for every generated file link_declaration = ".. _{}:".format(f.program_link_name) @@ -3245,7 +3245,7 @@ def generateFileNodeDocuments(self): gen_file.write(full_program_listing) except: utils.fancyError( - "Critical error while generating the file for [{0}]".format(f.file_name) + "Critical error while generating the file for [{}]".format(f.file_name) ) else: include_program_listing = False @@ -3381,12 +3381,12 @@ def generateFileNodeDocuments(self): with codecs.open(f.file_name, "w", "utf-8") as gen_file: # Add the metadata if they requested it if configs.pageLevelConfigMeta: - gen_file.write("{0}\n\n".format(configs.pageLevelConfigMeta)) + gen_file.write("{}\n\n".format(configs.pageLevelConfigMeta)) # generate a link label for every generated file - link_declaration = ".. _{0}:".format(f.link_name) + link_declaration = ".. _{}:".format(f.link_name) # every generated file must have a header for sphinx to be happy - f.title = "{0} {1}".format(utils.qualifyKind(f.kind), f.name) + f.title = "{} {}".format(utils.qualifyKind(f.kind), f.name) gen_file.write(textwrap.dedent(''' {link} @@ -3439,7 +3439,7 @@ def generateFileNodeDocuments(self): )).lstrip()) except: utils.fancyError( - "Critical error while generating the file for [{0}]".format(f.file_name) + "Critical error while generating the file for [{}]".format(f.file_name) ) if configs.generateBreatheFileDirectives: @@ -3470,7 +3470,7 @@ def generateFileNodeDocuments(self): ))) except: utils.fancyError( - "Critical error while generating the breathe directive for [{0}]".format(f.file_name) + "Critical error while generating the breathe directive for [{}]".format(f.file_name) ) def generateDirectoryNodeDocuments(self): @@ -3559,10 +3559,10 @@ def generateDirectoryNodeRST(self, node): with codecs.open(node.file_name, "w", "utf-8") as gen_file: # Add the metadata if they requested it if configs.pageLevelConfigMeta: - gen_file.write("{0}\n\n".format(configs.pageLevelConfigMeta)) + gen_file.write("{}\n\n".format(configs.pageLevelConfigMeta)) # generate a link label for every generated file - link_declaration = ".. _{0}:\n\n".format(node.link_name) + link_declaration = ".. _{}:\n\n".format(node.link_name) header = textwrap.dedent(''' {heading} {heading_mark} @@ -3576,12 +3576,12 @@ def generateDirectoryNodeRST(self, node): )) path = "\n*Directory path:* ``{path}``\n".format(path=node.name) # write it all out - gen_file.write("{0}{1}{2}{3}{4}\n{5}\n\n".format( + gen_file.write("{}{}{}{}{}\n{}\n\n".format( link_declaration, header, parent_directory, path, child_dirs_string, child_files_string) ) except: utils.fancyError( - "Critical error while generating the file for [{0}]".format(node.file_name) + "Critical error while generating the file for [{}]".format(node.file_name) ) def generateAPIRootBody(self): @@ -3614,39 +3614,39 @@ def generateAPIRootBody(self): # Include index page, if present for page in self.pages: if page.refid == "indexpage": - generated_index.write(".. include:: {0}\n\n".format( + generated_index.write(".. include:: {}\n\n".format( os.path.basename(page.file_name) )) break # Include the page, class, and file hierarchies if os.path.exists(self.page_hierarchy_file): - generated_index.write(".. include:: {0}\n\n".format( + generated_index.write(".. include:: {}\n\n".format( os.path.basename(self.page_hierarchy_file) )) if os.path.exists(self.class_hierarchy_file): - generated_index.write(".. include:: {0}\n\n".format( + generated_index.write(".. include:: {}\n\n".format( os.path.basename(self.class_hierarchy_file) )) if os.path.exists(self.file_hierarchy_file): - generated_index.write(".. include:: {0}\n\n".format( + generated_index.write(".. include:: {}\n\n".format( os.path.basename(self.file_hierarchy_file) )) # Add the afterHierarchyDescription if provided if configs.afterHierarchyDescription: generated_index.write( - "\n{0}\n\n".format(configs.afterHierarchyDescription) + "\n{}\n\n".format(configs.afterHierarchyDescription) ) # Include the unabridged API - generated_index.write(".. include:: {0}\n\n".format( + generated_index.write(".. include:: {}\n\n".format( os.path.basename(self.unabridged_api_file) )) # Add the afterBodySummary if provided if configs.afterBodySummary: generated_index.write( - "\n{0}\n\n".format(configs.afterBodySummary) + "\n{}\n\n".format(configs.afterBodySummary) ) # The following should only be applied to the page library root page @@ -3753,7 +3753,7 @@ def generateAPIRootBody(self): ))) except: utils.fancyError( - "Unable to create the root api body: [{0}]".format(self.full_root_file_path) + "Unable to create the root api body: [{}]".format(self.full_root_file_path) ) def gerrymanderNodeFilenames(self): @@ -4214,7 +4214,7 @@ def toConsole(self): } self.consoleFormat( - "{0} and {1}".format( + "{} and {}".format( utils._use_color("Classes", fmt_spec["class"], sys.stderr), utils._use_color("Structs", fmt_spec["struct"], sys.stderr), ), @@ -4300,7 +4300,7 @@ def consoleFormat(self, sectionTitle, lst, fmt_spec): utils.verbose_log(textwrap.dedent(''' ########################################################### - ## {0} + ## {} ###########################################################'''.format(sectionTitle))) for l in lst: l.toConsole(0, fmt_spec) diff --git a/exhale/parse.py b/exhale/parse.py index fb2f506..4cdba19 100644 --- a/exhale/parse.py +++ b/exhale/parse.py @@ -111,13 +111,13 @@ def walk(textRoot, currentTag, level, prefix=None, postfix=None, unwrapUntilPara if currentTag.name == "orderedlist": idx = 1 for child in children: - walk(textRoot, child, level + 1, "\n{0}{1}. ".format(indent, idx), None, True) + walk(textRoot, child, level + 1, "\n{}{}. ".format(indent, idx), None, True) idx += 1 child.unwrap() currentTag.unwrap() elif currentTag.name == "itemizedlist": for child in children: - walk(textRoot, child, level + 1, "\n{0}- ".format(indent), None, True) + walk(textRoot, child, level + 1, "\n{}- ".format(indent), None, True) child.unwrap() currentTag.unwrap() elif currentTag.name == "verbatim": @@ -129,36 +129,36 @@ def walk(textRoot, currentTag, level, prefix=None, postfix=None, unwrapUntilPara cont = textwrap.dedent(cont.replace("\n*", "\n")) currentTag.string = cont elif currentTag.name == "formula": - currentTag.string = ":math:`{0}`".format(currentTag.string[1:-1]) + currentTag.string = ":math:`{}`".format(currentTag.string[1:-1]) elif currentTag.name == "ref": signal = None if "refid" not in currentTag.attrs: - signal = "No 'refid' in `ref` tag attributes of file documentation. Attributes were: {0}".format( + signal = "No 'refid' in `ref` tag attributes of file documentation. Attributes were: {}".format( currentTag.attrs ) else: refid = currentTag.attrs["refid"] if refid not in textRoot.node_by_refid: - signal = "Found unknown 'refid' of [{0}] in file level documentation.".format(refid) + signal = "Found unknown 'refid' of [{}] in file level documentation.".format(refid) else: - currentTag.string = ":ref:`{0}`".format(textRoot.node_by_refid[refid].link_name) + currentTag.string = ":ref:`{}`".format(textRoot.node_by_refid[refid].link_name) if signal: # << verboseBuild utils.verbose_log(signal, utils.AnsiColors.BOLD_YELLOW) elif currentTag.name == "emphasis": - currentTag.string = "*{0}*".format(currentTag.string) + currentTag.string = "*{}*".format(currentTag.string) elif currentTag.name == "computeroutput": - currentTag.string = "``{0}``".format(currentTag.string) + currentTag.string = "``{}``".format(currentTag.string) elif currentTag.name == "bold": - currentTag.string = "**{0}**".format(currentTag.string) + currentTag.string = "**{}**".format(currentTag.string) else: ctr = 0 for child in children: c_prefix = None c_postfix = None if ctr > 0 and child.name == "para": - c_prefix = "\n{0}".format(indent) + c_prefix = "\n{}".format(indent) walk(textRoot, child, level, c_prefix, c_postfix) @@ -191,7 +191,7 @@ def convertDescriptionToRST(textRoot, node, soupTag, heading): configs.SUB_SECTION_HEADING_CHAR ) )) - return "{0}{1}".format(start, contents) + return "{}{}".format(start, contents) else: return "" @@ -211,7 +211,7 @@ def getBriefAndDetailedRST(textRoot, node): try: node_soup = BeautifulSoup(node_xml_contents, "lxml-xml") except: - utils.fancyError("Unable to parse [{0}] xml using BeautifulSoup".format(node.name)) + utils.fancyError("Unable to parse [{}] xml using BeautifulSoup".format(node.name)) try: # In the file xml definitions, things such as enums or defines are listed inside diff --git a/exhale/utils.py b/exhale/utils.py index 2e6890d..add27e5 100644 --- a/exhale/utils.py +++ b/exhale/utils.py @@ -73,21 +73,21 @@ def time_string(start, end): elif hours == 1: hours_str = "1 hour, " else: - hours_str = "{0} hours, ".format(hours) + hours_str = "{} hours, ".format(hours) if mins == 0: mins_str = "" elif mins == 1: mins_str = "1 minute, and " else: - mins_str = "{0} minutes, and ".format(mins) + mins_str = "{} minutes, and ".format(mins) if secs == 1.00: # LOL I would love to see this happen secs_str = "1.00 second" else: - secs_str = "{0} seconds".format(secs) + secs_str = "{} seconds".format(secs) - time_str = "{0}{1}{2}".format(hours_str, mins_str, secs_str) + time_str = "{}{}{}".format(hours_str, mins_str, secs_str) except: time_str = str(delta) else: @@ -213,7 +213,7 @@ def makeCustomSpecificationsMapping(func): # Make sure they gave us a function if not isinstance(func, types.FunctionType): raise ValueError( - "The input to exhale.util.makeCustomSpecificationsMapping was *NOT* a function: {0}".format( + "The input to exhale.util.makeCustomSpecificationsMapping was *NOT* a function: {}".format( type(func) ) ) @@ -242,14 +242,14 @@ def makeCustomSpecificationsMapping(func): '''.format(kind=kind))) ret[kind] = specs except Exception as e: - raise RuntimeError("Unable to create custom specifications:\n{0}".format(e)) + raise RuntimeError("Unable to create custom specifications:\n{}".format(e)) # Everything went according to plan, send it back to `conf.py` :) return ret def nodeCompoundXMLContents(node): - node_xml_path = os.path.join(configs._doxygen_xml_output_directory, "{0}.xml".format(node.refid)) + node_xml_path = os.path.join(configs._doxygen_xml_output_directory, "{}.xml".format(node.refid)) if os.path.isfile(node_xml_path): try: with codecs.open(node_xml_path, "r", "utf-8") as xml: @@ -742,7 +742,7 @@ def exclaim(err_msg): def colorize(msg, ansi_fmt): - return "\033[{0}{1}\033[0m".format(ansi_fmt, msg) + return "\033[{}{}\033[0m".format(ansi_fmt, msg) def _use_color(msg, ansi_fmt, output_stream): @@ -815,7 +815,7 @@ def fancyErrorString(lex): err = traceback.format_exc() # shenanigans = "During handling of the above exception, another exception occurred:" # err = err.split(shenanigans)[0] - return __fancy("{0}\n".format(err), lex, "console") + return __fancy("{}\n".format(err), lex, "console") except: return "CRITICAL: could not extract traceback.format_exc!" @@ -834,7 +834,7 @@ def fancyError(critical_msg=None, lex="py3tb", singleton_hook=None): singleton_hook() except Exception as e: sys.stderr.write(critical( - "fancyError: `singleton_hook` caused exception: {0}".format(e) + "fancyError: `singleton_hook` caused exception: {}".format(e) )) os._exit(1)