Skip to content

Commit

Permalink
trying to fix broken command line tools
Browse files Browse the repository at this point in the history
  • Loading branch information
daurer committed Jul 31, 2024
1 parent 38053c9 commit 87d1806
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
16 changes: 8 additions & 8 deletions ptypy/cli/default_params.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

from ptypy import utils as u
from ptypy import defaults_tree
import textwrap
import argparse

Expand All @@ -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]
Expand All @@ -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 = ''
Expand Down
10 changes: 7 additions & 3 deletions ptypy/utils/descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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# ')
Expand All @@ -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)
Expand Down

0 comments on commit 87d1806

Please sign in to comment.