summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Erdmann2012-06-25 18:05:17 (GMT)
committerAndré Erdmann2012-06-25 18:05:17 (GMT)
commit3608ce9e8abe2412f2cf032b1e22c1a3be8aee2a (patch)
tree71f9b3824ed0a372e03ee90b33db6585b4d1b367
parent0085c0ed8b384b6f06311b47c49fd331b4b53250 (diff)
fix _tree_to_str() in ConfigTree
modified: roverlay/config/tree.py
-rw-r--r--roverlay/config/tree.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/roverlay/config/tree.py b/roverlay/config/tree.py
index 707aa8a..adcdcde 100644
--- a/roverlay/config/tree.py
+++ b/roverlay/config/tree.py
@@ -189,13 +189,17 @@ class ConfigTree ( object ):
var_indent = indent + '* '
if root is None:
return "%s%s is unset\n" % ( var_indent, name )
- elif len ( root ) == 0:
- return "%s%s is empty\n" % ( var_indent, name )
elif isinstance ( root, dict ):
- extra = ''.join ( [
- self._tree_to_str ( n, r, level+1 ) for r, n in root.items()
- ] )
- return "%s%s {\n%s%s}\n" % ( indent, name, extra, indent )
+ if len ( root ) == 0:
+ return "%s%s is empty\n" % ( var_indent, name )
+ else:
+ extra = ''.join ( [
+ self._tree_to_str ( n, r, level+1 ) for r, n in root.items()
+ ] )
+ return "%s%s {\n%s%s}\n" % ( indent, name, extra, indent )
+ elif level == 1:
+ # non-nested config entry
+ return "\n%s%s = '%s'\n\n" % ( var_indent, name, root )
else:
return "%s%s = '%s'\n" % ( var_indent, name, root )
# --- end of _tree_to_str (...) ---