From 291511b5b1a39d888a61a1f579badf4d42ed9d9a Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Wed, 11 Aug 2021 14:44:35 +0200 Subject: Add verbose mode to docs loading and tweak defaults Instead of printing every single page loaded, print the start of the process and the statitics by default. The existing --quiet parameter continues to work to make the process completely quiet. Add a new parameter --verbose that makes it run in the old way, printing everything. --- tools/docs/docload.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'tools/docs') diff --git a/tools/docs/docload.py b/tools/docs/docload.py index 427a9345..5ececcb6 100755 --- a/tools/docs/docload.py +++ b/tools/docs/docload.py @@ -21,6 +21,8 @@ BOOTSTRAP_FIGURE_CLASS = r'([^<]+)', re.IGNORECASE) @@ -76,8 +78,8 @@ def load_doc_file(filename, f, c): # in order to ensure they are able to display responsively contents = re_figure_match.sub(BOOTSTRAP_FIGURE_CLASS, contents) - # if not in quiet mode, output the (filename, title) pair of the docpage that is being processed - if not quiet: + # in verbose mode, output the (filename, title) pair of the docpage that is being processed + if verbose: print("--- file: %s (%s) ---" % (filename, title)) # run libtidy on the content @@ -99,7 +101,9 @@ def load_svg_file(filename, f, c): # Main execution parser = OptionParser(usage="usage: %prog [options] ") parser.add_option("-q", "--quiet", action="store_true", dest="quiet", - help="Run quietly") + help="Run quietly (no output at all)") +parser.add_option("-v", "--verbose", action="store_true", dest="verbose", + help="Run verbosely") (options, args) = parser.parse_args() if len(args) != 2: @@ -107,6 +111,12 @@ if len(args) != 2: sys.exit(1) quiet = options.quiet +verbose = options.verbose + +if verbose and quiet: + print("Can't be both verbose and quiet at the same time!") + sys.exit(1) + ver = sys.argv[1] tarfilename = sys.argv[2] @@ -124,6 +134,9 @@ tf = tarfile.open(tarfilename) connection = psycopg2.connect(config.get('db', 'dsn')) +if not quiet: + print("Starting load of documentation for version %s." % (ver, )) + curs = connection.cursor() # Verify that the version exists, and what we're loading curs.execute("SELECT current FROM core_version WHERE tree=%(v)s", {'v': ver}) @@ -237,4 +250,4 @@ connection.commit() connection.close() if not quiet: - print("Done (%i pages)." % pagecount) + print("Done loading docs version %s (%i pages)." % (ver, pagecount)) -- cgit v1.2.3