Gentoo Archives: gentoo-commits

From: "André Erdmann" <dywi@×××××××.de>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/config/
Date: Mon, 25 Jun 2012 18:20:23
Message-Id: 1340647517.3608ce9e8abe2412f2cf032b1e22c1a3be8aee2a.dywi@gentoo
commit:     3608ce9e8abe2412f2cf032b1e22c1a3be8aee2a
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Mon Jun 25 18:05:17 2012 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Mon Jun 25 18:05:17 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=3608ce9e

fix _tree_to_str() in ConfigTree

	modified:   roverlay/config/tree.py

---
 roverlay/config/tree.py |   16 ++++++++++------
 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 (...) ---