From: biao716.wang Date: Fri, 5 May 2023 09:03:09 +0000 (+0900) Subject: fix pylint error X-Git-Tag: accepted/tools/devbase/tools/20250527.103804~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8cd0e14209529c27cb4ce6aae11c5cf94084db6f;p=tools%2Fmic.git fix pylint error 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 --- diff --git a/mic/3rdparty/pykickstart/sections.py b/mic/3rdparty/pykickstart/sections.py index 2aafd14..a452a90 100644 --- a/mic/3rdparty/pykickstart/sections.py +++ b/mic/3rdparty/pykickstart/sections.py @@ -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 diff --git a/mic/kickstart/__init__.py b/mic/kickstart/__init__.py index 833fd72..a5f46ef 100755 --- a/mic/kickstart/__init__.py +++ b/mic/kickstart/__init__.py @@ -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): diff --git a/plugins/backend/yumpkgmgr.py b/plugins/backend/yumpkgmgr.py index 850dc38..51d9786 100644 --- a/plugins/backend/yumpkgmgr.py +++ b/plugins/backend/yumpkgmgr.py @@ -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): diff --git a/plugins/backend/zypppkgmgr.py b/plugins/backend/zypppkgmgr.py index c1bae73..7822904 100644 --- a/plugins/backend/zypppkgmgr.py +++ b/plugins/backend/zypppkgmgr.py @@ -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