Salome HOME
style: black format
[tools/sat.git] / commands / doc.py
index 0c9b44881b807698f208719607bd97816135b85d..0a218814e4f0ba6f3dd81b1788f0673d2d6fd3ef 100644 (file)
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-#-*- coding:utf-8 -*-
+# -*- coding:utf-8 -*-
 #  Copyright (C) 2010-2012  CEA/DEN
 #
 #  This library is free software; you can redistribute it and/or
@@ -21,10 +21,24 @@ import src
 
 # Define all possible option for log command :  sat doc <options>
 parser = src.options.Options()
-parser.add_option('x', 'xml', 'boolean', 'xml', "Open sat xml/html documentation in browser (x as firefoX)", None)
-parser.add_option('p', 'pdf', 'boolean', 'pdf', "Open sat pdf documentation in viewer", False)
-parser.add_option('e', 'edit', 'boolean', 'edit', "edit/modify source dodumentation rst files", False)
-parser.add_option('c', 'compile', 'boolean', 'compile', "how to compile html/pdf doc", False)
+parser.add_option(
+    "x",
+    "xml",
+    "boolean",
+    "xml",
+    "Open sat xml/html documentation in browser (x as firefoX)",
+    None,
+)
+parser.add_option(
+    "p", "pdf", "boolean", "pdf", "Open sat pdf documentation in viewer", False
+)
+parser.add_option(
+    "e", "edit", "boolean", "edit", "edit/modify source dodumentation rst files", False
+)
+parser.add_option(
+    "c", "compile", "boolean", "compile", "how to compile html/pdf doc", False
+)
+
 
 def description():
     """method that is called when salomeTools is called with --help option.
@@ -32,22 +46,24 @@ def description():
     :return: The text to display for the log command description.
     :rtype: str
     """
-    return _("""\
+    return _(
+        """\
 The doc command gives access to the sat documentation.
     
 example:
 >> sat doc         # --xml as default
 >> sat doc --xml
 >> sat doc --pdf
-""")
+"""
+    )
+
 
 def run(args, runner, logger):
-    '''method that is called when salomeTools is called with log parameter.
-    '''
+    """method that is called when salomeTools is called with log parameter."""
     # Parse the options
     (options, args) = parser.parse_args(args)
 
-    # get the log directory. 
+    # get the log directory.
     satDir = runner.cfg.VARS.salometoolsway
     docDir = os.path.join(satDir, "doc")
     htmlFile = os.path.join(docDir, "build", "html", "index.html")
@@ -61,8 +77,10 @@ def run(args, runner, logger):
 
     if options.pdf:
         if not os.path.isfile(pdfFile):
-            msg = "\npdf documentation not found. Please build it inside doc directory\n"\
-                  "(follow README instructions in doc directory)\n"
+            msg = (
+                "\npdf documentation not found. Please build it inside doc directory\n"
+                "(follow README instructions in doc directory)\n"
+            )
             logger.error(msg)
             return 1
         src.system.show_in_editor(runner.cfg.USER.pdf_viewer, pdfFile, logger)
@@ -72,12 +90,16 @@ def run(args, runner, logger):
         src.system.show_in_editor(runner.cfg.USER.editor, rstFilesCommands, logger)
 
     elif options.compile:
-        logger.write("How to compile documentation:\n%s" % open(readmeFile,"r").read(), 3)
+        logger.write(
+            "How to compile documentation:\n%s" % open(readmeFile, "r").read(), 3
+        )
 
     else:
         if not os.path.isfile(htmlFile):
-            msg = "\nhtml documentation not found. Please build it inside doc directory\n"\
-                  "(follow README instructions in doc directory)\n"
+            msg = (
+                "\nhtml documentation not found. Please build it inside doc directory\n"
+                "(follow README instructions in doc directory)\n"
+            )
             logger.error(msg)
             return 1
         src.system.show_in_editor(runner.cfg.USER.browser, htmlFile, logger)