change metaclass with python3 style 61/279661/1
authorbiao716.wang <biao716.wang@samsung.com>
Mon, 15 Aug 2022 08:33:58 +0000 (17:33 +0900)
committerbiao716.wang <biao716.wang@samsung.com>
Mon, 15 Aug 2022 08:33:58 +0000 (17:33 +0900)
Change-Id: Icc022572d61129607de63e04b4b79cd07594c46b
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
mic/3rdparty/pykickstart/commands/partition.py
mic/pluginbase.py

index 2ed4bdc5ea9bc3ae18903fa798d678ad8011f04c..a4d6fc00ecfefbb193f948f653b8791ebc9c2298 100644 (file)
@@ -117,7 +117,7 @@ class FC4_PartData(FC3_PartData):
             retval += " --bytes-per-inode=%d" % self.bytesPerInode
         if self.fsopts:
             retval += " --fsoptions=\"%s\"" % self.fsopts
-        if self.label
+        if self.label:
             retval += " --label=%s" % self.label
         if self.fslabel != "":
             retval += " --fslabel=%s" % self.fslabel
index 0bb1badf16be193f15afe67cd4cde11d5dcaa3ea..65351c5f1e6067ca9ef25cd806bdf2c8d09fd7cd 100644 (file)
@@ -1,8 +1,3 @@
-#!/usr/bin/python3 -tt
-#
-# Copyright (c) 2011 Intel, Inc.
-#
-# This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by the Free
 # Software Foundation; version 2 of the License
 #
@@ -20,25 +15,31 @@ import shutil
 from mic import msger
 from mic.utils import errors
 
-class _Plugin(object):
-    class __metaclass__(type):
-        def __init__(cls, name, bases, attrs):
-            if not hasattr(cls, 'plugins'):
-                cls.plugins = {}
+class pluginMetaClass(type):
+    def __new__(cls, name, bases, attrs):
+
+        return type.__new__(cls,name, bases, attrs)
+
+    def __init__(cls, name, bases, attrs):
+        if not hasattr(cls, 'plugins'):
+            cls.plugins = {}
+        elif 'mic_plugin_type' in attrs:
+            if attrs['mic_plugin_type'] not in cls.plugins:
+                cls.plugins[attrs['mic_plugin_type']] = {}
+
+        elif hasattr(cls, 'mic_plugin_type') and 'name' in attrs:
+            cls.plugins[cls.mic_plugin_type][attrs['name']] = cls
 
-            elif 'mic_plugin_type' in attrs:
-                if attrs['mic_plugin_type'] not in cls.plugins:
-                    cls.plugins[attrs['mic_plugin_type']] = {}
+    def show_plugins(cls):
+        for cls in cls.plugins[cls.mic_plugin_type]:
+            print (cls)
 
-            elif hasattr(cls, 'mic_plugin_type') and 'name' in attrs:
-                cls.plugins[cls.mic_plugin_type][attrs['name']] = cls
+    def get_plugins(cls):
+        return cls.plugins
 
-        def show_plugins(cls):
-            for cls in cls.plugins[cls.mic_plugin_type]:
-                print (cls)
 
-        def get_plugins(cls):
-            return cls.plugins
+class _Plugin(object, metaclass=pluginMetaClass):
+    pass
 
 class ImagerPlugin(_Plugin):
     mic_plugin_type = "imager"