[Debian-astro-commits] [cpl-plugin-template] 52/81: Put parameter section only if there are parameters

Ole Streicher olebole at moszumanska.debian.org
Mon Jul 20 12:08:31 UTC 2015


This is an automated email from the git hooks/post-receive script.

olebole pushed a commit to branch debian
in repository cpl-plugin-template.

commit 576642af2b2edd61060d6e5d3ec8cd1a1575d04b
Author: Ole Streicher <debian at liska.ath.cx>
Date:   Mon Dec 9 11:27:29 2013 +0100

    Put parameter section only if there are parameters
---
 debian/create_sphinx.py | 66 +++++++++++++++++++++++++++----------------------
 1 file changed, 36 insertions(+), 30 deletions(-)

diff --git a/debian/create_sphinx.py b/debian/create_sphinx.py
index db134bd..a8553fb 100644
--- a/debian/create_sphinx.py
+++ b/debian/create_sphinx.py
@@ -33,30 +33,7 @@ Constructor
    import cpl
    {recipe} = cpl.Recipe("{recipe}")
 
-Parameters
-----------
-
-{pars}
-
-The following code snippet shows the default settings for the available 
-parameters.
-
-::
-
-   import cpl
-   {recipe} = cpl.Recipe("{recipe}")
-
-{pars_example1}
-
-You may also set or overwrite some or all parameters by the recipe 
-parameter `param`, as shown in the following example:
-
-::
-
-   import cpl
-   {recipe} = cpl.Recipe("{recipe}")
-   [...]
-   res = {recipe}( ..., param = {{{pars_example2}}})
+{parameters}
 
 .. seealso:: `cpl.Recipe <http://packages.python.org/python-cpl/recipe.html>`_
    for more information about the recipe object.
@@ -124,6 +101,32 @@ Support Department <usd-help at eso.org>`_, describing:
  * whether the problem is repeatable.
 '''
 
+rst_partemplate = '''Parameters
+----------
+
+{pars}
+
+The following code snippet shows the default settings for the available 
+parameters.
+
+::
+
+   import cpl
+   {recipe} = cpl.Recipe("{recipe}")
+
+{pars_example1}
+
+You may also set or overwrite some or all parameters by the recipe 
+parameter `param`, as shown in the following example:
+
+::
+
+   import cpl
+   {recipe} = cpl.Recipe("{recipe}")
+   [...]
+   res = {recipe}( ..., param = {{{pars_example2}}})
+'''
+
 conf_template = '''project = u'{PIPELINE} pipeline'
 version = '{version}'
 release = '{version}'
@@ -184,7 +187,7 @@ def get_description(s):
             o += [ s ]
     return "\n".join(o)
 
-def rstpage(recipe, template):
+def rstpage(recipe, template, partemplate):
     return template.format(
         recipe = recipe.__name__,
         version = recipe.__version__,
@@ -194,16 +197,19 @@ def rstpage(recipe, template):
         author = recipe.__author__,
         license = recipe.__copyright__,
         pipeline = pipeline,
-        pars = par(recipe, par_template),
-        pars_example1 = par(recipe, '   {recipe}.param.{par} = {default}\n'),
-        pars_example2 = par(recipe, '"{par}":{default}', ', ', 2)
+        parameters = partemplate.format(
+            recipe = recipe.__name__,
+            pars = par(recipe, par_template),
+            pars_example1 = par(recipe,
+                                '   {recipe}.param.{par} = {default}\n'),
+            pars_example2 = par(recipe, '"{par}":{default}', ', ', 2)
+        ) if len(recipe.param) > 0 else ''
     )
 
-
 for recipe in recipes_oca + recipes_x:
     f = open(os.path.join("sphinx",
                           fname_template.format(recipe = recipe.__name__)), "w")
-    f.write(rstpage(recipe, rst_template))
+    f.write(rstpage(recipe, rst_template, rst_partemplate))
     f.close()
 
 if len(recipes_oca) > 0 and len(recipes_x) > 0:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-astro/packages/cpl-plugin-template.git



More information about the Debian-astro-commits mailing list