[PATCH 05/22] esx_vi_generator: Simplify generate_helper_source

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The generate_helper_source() function returns a formatted string.
This could be achieved without the use of a local variable "source"
and string concatenation.

Signed-off-by: Radostin Stoyanov <rstoyanov1@xxxxxxxxx>
---
 src/esx/esx_vi_generator.py | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index 8fbc8bef1..19c225384 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -1092,26 +1092,17 @@ class ManagedObject(GenericObject):
 
 
     def generate_helper_source(self):
-        source = ""
-
         # lookup
-        source += "/* esxVI_Lookup%s */\n" % self.name
-        source += "ESX_VI__TEMPLATE__LOOKUP(%s,\n" % self.name
-        source += "{\n"
-
-        source += self.generate_lookup_code1()
-
-        source += "},\n"
-        source += "{\n"
-
-        source += self.generate_lookup_code2()
-
-        source += "})\n\n"
-
-        source += "\n\n"
-
-        return source
-
+        return (
+            "/* esxVI_Lookup{name} */\n"
+            "ESX_VI__TEMPLATE__LOOKUP({name},\n"
+            "{{\n{lookup_code1}}},\n"
+            "{{\n{lookup_code2}}})\n\n\n\n"
+        ).format(
+            name=self.name,
+            lookup_code1=self.generate_lookup_code1(),
+            lookup_code2=self.generate_lookup_code2()
+        )
 
 
 class Enum(Type):
-- 
2.14.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux