fix pylint error 91/292391/2
authorbiao716.wang <biao716.wang@samsung.com>
Fri, 5 May 2023 09:03:09 +0000 (18:03 +0900)
committerwang biao <biao716.wang@samsung.com>
Sat, 6 May 2023 00:46:17 +0000 (08:46 +0800)
1.change file() to open() to open a file.
2.fix Value 'filter(lambda r: r.name == name, self.repos)' is unsubscriptable
Change-Id: Ieec8e179a9b54a5acbd0edaedcb9ed1595ba5f1e
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
mic/3rdparty/pykickstart/sections.py
mic/kickstart/__init__.py
plugins/backend/yumpkgmgr.py
plugins/backend/zypppkgmgr.py

index 2aafd14f7343576fd3ed2bfd48a46429799b352b..a452a902bf274175f456c1683d0015efa1df1577 100644 (file)
@@ -34,7 +34,7 @@ from pykickstart.constants import KS_SCRIPT_PRE, KS_SCRIPT_POST, KS_SCRIPT_TRACE
                                   KS_SCRIPT_PREINSTALL, KS_SCRIPT_ONERROR, \
                                   KS_MISSING_IGNORE, KS_MISSING_PROMPT, \
                                   KS_BROKEN_IGNORE, KS_BROKEN_REPORT, KS_SCRIPT_RUN, KS_SCRIPT_UMOUNT
-from pykickstart.errors import KickstartParseError, KickstartDeprecationWarning
+from pykickstart.errors import KickstartError, KickstartParseError, KickstartDeprecationWarning
 from pykickstart.options import KSOptionParser
 from pykickstart.version import FC4, F7, F9, F18, F21, F22, F24, F32, F34, RHEL6, RHEL7, RHEL9, \
     isRHEL
index 833fd72a0f54f9510318692718ade43f9806469c..a5f46ef60d434524953027958b53542c54d82333 100755 (executable)
@@ -540,7 +540,7 @@ class NetworkConfig(KickstartConfig):
     def write_ifcfg(self, network):
         p = self.path("/etc/sysconfig/network-scripts/ifcfg-" + network.device)
 
-        f = file(p, "w+")
+        f = open(p, "w+")
         os.chmod(p, 0o644)
 
         f.write("DEVICE=%s\n" % network.device)
@@ -581,14 +581,14 @@ class NetworkConfig(KickstartConfig):
             return
 
         p = self.path("/etc/sysconfig/network-scripts/keys-" + network.device)
-        f = file(p, "w+")
+        f = open(p, "w+")
         os.chmod(p, 0o600)
         f.write("KEY=%s\n" % network.wepkey)
         f.close()
 
     def write_sysconfig(self, useipv6, hostname, gateway):
         path = self.path("/etc/sysconfig/network")
-        f = file(path, "w+")
+        f = open(path, "w+")
         os.chmod(path, 0o644)
 
         f.write("NETWORKING=yes\n")
@@ -618,7 +618,7 @@ class NetworkConfig(KickstartConfig):
         localline += "localhost.localdomain localhost"
 
         path = self.path("/etc/hosts")
-        f = file(path, "w+")
+        f = open(path, "w+")
         os.chmod(path, 0o644)
         f.write("127.0.0.1\t\t%s\n" % localline)
         f.write("::1\t\tlocalhost6.localdomain6 localhost6\n")
@@ -629,7 +629,7 @@ class NetworkConfig(KickstartConfig):
             return
 
         path = self.path("/etc/resolv.conf")
-        f = file(path, "w+")
+        f = open(path, "w+")
         os.chmod(path, 0o644)
 
         for ns in (nameservers):
index 850dc3830490d3280448b209924bf19c7f222d06..51d978660fc66f52dffda7f541ed9f89ee12c4e8 100644 (file)
@@ -161,7 +161,7 @@ class Yum(BackendPlugin, yum.YumBase):
     def _writeConf(self, confpath, installroot):
         conf = Template(YUMCONF_TEMP).safe_substitute(installroot=installroot)
 
-        f = file(confpath, "w+")
+        f = open(confpath, "w+")
         f.write(conf)
         f.close()
 
@@ -368,7 +368,7 @@ class Yum(BackendPlugin, yum.YumBase):
         msger.info("\nChecking packages cached ...")
         for po in dlpkgs:
             local = po.localPkg()
-            repo = filter(lambda r: r.id == po.repoid, self.repos.listEnabled())[0]
+            repo = list(filter(lambda r: r.id == po.repoid, self.repos.listEnabled()))[0]
             if repo.nocache and os.path.exists(local):
                 os.unlink(local)
             if not os.path.exists(local):
index c1bae73b0de266f7c4ecb9f3a7df332074b04f9d..7822904de0e2eda8368336fdee38faa0f1387e07 100644 (file)
@@ -559,7 +559,7 @@ class Zypp(BackendPlugin):
                 local = self.getLocalPkgPath(po)
                 name = str(po.repoInfo().name())
                 try:
-                    repo = filter(lambda r: r.name == name, self.repos)[0]
+                    repo = list(filter(lambda r: r.name == name, self.repos))[0]
                 except IndexError:
                     repo = None
                 nocache = repo.nocache if repo else False
@@ -992,7 +992,7 @@ class Zypp(BackendPlugin):
 
         name = str(pobj.repoInfo().name())
         try:
-            repo = filter(lambda r: r.name == name, self.repos)[0]
+            repo = list(filter(lambda r: r.name == name, self.repos))[0]
         except IndexError:
             return None