From 87d1806ed9f83b3bab0889b22aa40eaf14f09737 Mon Sep 17 00:00:00 2001 From: Benedikt Daurer Date: Wed, 31 Jul 2024 16:39:30 +0100 Subject: [PATCH] trying to fix broken command line tools --- ptypy/cli/default_params.py | 16 ++++++++-------- ptypy/utils/descriptor.py | 10 +++++++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ptypy/cli/default_params.py b/ptypy/cli/default_params.py index 3da2f62e8..91c2fe378 100755 --- a/ptypy/cli/default_params.py +++ b/ptypy/cli/default_params.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -from ptypy import utils as u +from ptypy import defaults_tree import textwrap import argparse @@ -18,7 +18,7 @@ def parse(): return pars def convert_and_print(pars): - root = u.validator.pdroot + root = defaults_tree if pars.path: for node in pars.path.split('.'): root = root.children[node] @@ -38,16 +38,16 @@ def print_param(entry, parent=None, depth=50): entry_name = '%s.%s' % (parent, entry.name) write('[%s]' % entry_name) write('default = %s' % entry.default) - write('help = ' + wrapdoc(entry.shortdoc)) - write('doc = ' + wrapdoc(entry.longdoc)) + write('help = ' + wrapdoc(entry.help)) + write('doc = ' + wrapdoc(entry.doc)) write('type = ' + ', '.join(entry.type)) write('userlevel = %s' % entry.userlevel) if entry.choices: write('choices = ' + ', '.join([str(x) for x in entry.choices])) - if entry.lowlim: - write('lowlim = %s' % entry.lowlim) - if entry.uplim: - write('uplim = %s' % entry.uplim) + if entry.limits: + write('lowlim = %s' % entry.limits[0]) + if entry.limits: + write('uplim = %s' % entry.limits[1]) write('') else: entry_name = '' diff --git a/ptypy/utils/descriptor.py b/ptypy/utils/descriptor.py index 714a581dd..7cf8474fc 100644 --- a/ptypy/utils/descriptor.py +++ b/ptypy/utils/descriptor.py @@ -1194,9 +1194,13 @@ def create_template(self, filename=None, start_at_root=True, user_level=0, doc_l for ret in self._walk(depth=99, ignore_wildcards=False): d = ret['d'] # user level - if d.userlevel > user_level: continue + if d.userlevel is None: + continue + if d.userlevel > user_level: + continue # skip the root, handled above - if d.root is d: continue + if d.root is d: + continue # handle line breaks already in the help/doc strings hlp = '# ' + d.help.replace('\n', '\n# ') doc = '# ' + d.doc.replace('\n', '\n# ') @@ -1215,7 +1219,7 @@ def create_template(self, filename=None, start_at_root=True, user_level=0, doc_l # not Param: actual default value else: val = str(d.default) - if 'str' in d.type and not d.default is None: + if 'str' in d.type and d.default is not None: val = "'" + val + "'" line = base + '.' + ret['path'] + ' = ' + val fp.write(line)