Factorize some code 20/24120/2
authorKévin THIERRY <kevin.thierry@open.eurogiciel.org>
Tue, 8 Jul 2014 14:49:49 +0000 (16:49 +0200)
committerKévin THIERRY <kevin.thierry@open.eurogiciel.org>
Wed, 9 Jul 2014 08:19:23 +0000 (10:19 +0200)
Change-Id: I9d42ab450d1937361804e8a6ea392700d1ae17a3
Signed-off-by: Kévin THIERRY <kevin.thierry@open.eurogiciel.org>
tools/spec2yocto.py

index ea13e8f..97b3d2b 100755 (executable)
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 # native
+
 '''
 Created on  05 fevr. 2013
 
 @author: ronan@fridu.net
 '''
+
 import os
 import shutil
-
 import errno
 
 RECIPES_SOURCE_DIR = os.path.dirname( os.path.realpath( __file__ ) )
@@ -137,46 +138,14 @@ class Spec2yoctoConfig( object ):
         res = os.path.expandvars( res )
         return res
 
-    def get_runtime_blacklist( self, project ):
-        """
-        return the list of the blacklisted runtime package.
-        """
-        blacklist_list = self.__get_list( project, "runtime_blacklist", [] )
-        res = []
-        for blacklist in blacklist_list:
-            res.extend( self.__get_list( blacklist, "list", [] ) )
-
-        return res
-
-    def get_whitelist( self, project ):
+    def get_list(self, project, list_name):
         """
-        return the list of the whitelist package.
+        Returns the corresponding list.
         """
-        whitelist_list = self.__get_list( project, "whitelist", [] )
+        res_list = self.__get_list( project, list_name, [] )
         res = []
-        for whitelist in whitelist_list:
-            res.extend( self.__get_list( whitelist, "list", [] ) )
-        return res
-
-    def get_blacklist( self, project ):
-        """
-        return the list of the blacklisted  package.
-        """
-        blacklist_list = self.__get_list( project, "blacklist", [] )
-        res = []
-        for blacklist in blacklist_list:
-            res.extend( self.__get_list( blacklist, "list", [] ) )
-
-        return res
-
-    def get_native_blacklist( self, project ):
-        """
-        return the list of the blacklisted native package.
-        """
-        blacklist_list = self.__get_list( project, "native_blacklist", [] )
-        res = []
-        for blacklist in blacklist_list:
-            res.extend( self.__get_list( blacklist, "list", [] ) )
+        for element in res_list:
+            res.extend(self.__get_list(element, "list", []))
         return res
 
     def get_substitute( self , project = None ):
@@ -2277,13 +2246,13 @@ class manifestCollection:
             if manifest_git is not None:
                 remote = manifest_git
 
-            whitelist = SPEC2YOCTO_CONFIG.get_whitelist( self.__my_project )
+            whitelist = SPEC2YOCTO_CONFIG.get_list(self.__my_project, "whitelist")
             if len( whitelist ) != 0:
                 list_packages = set(whitelist)
             else:
                 list_packages = set(packages_dico.keys())
 
-            blacklist = set(SPEC2YOCTO_CONFIG.get_blacklist( self.__my_project ))
+            blacklist = set(SPEC2YOCTO_CONFIG.get_list(self.__my_project, "blacklist"))
 
             list_packages=list_packages.difference(blacklist)
 
@@ -2415,14 +2384,14 @@ class manifestCollection:
         '''
         load oe_package_blacklist
         '''
-        list_package = SPEC2YOCTO_CONFIG.get_runtime_blacklist( self.__my_project )
+        list_package = SPEC2YOCTO_CONFIG.get_list(self.__my_project, "runtime_blacklist")
         MetaSpec.mOePackageBlacklist.extend( list_package )
 
     def __set_native_package_blacklist( self ):
         '''
         load oe_package_blacklist
         '''
-        list_package = SPEC2YOCTO_CONFIG.get_native_blacklist( self.__my_project )
+        list_package = SPEC2YOCTO_CONFIG.get_list(self.__my_project, "native_blacklist")
         MetaSpec.mNativePackageBlacklist.extend( list_package )