replace SafeConfigParser with ConfigParser which is dropped in python3.12 14/312814/3
authorwangbiao <biao716.wang@samsung.com>
Fri, 14 Jun 2024 09:06:07 +0000 (18:06 +0900)
committerwangbiao <biao716.wang@samsung.com>
Thu, 4 Jul 2024 05:54:44 +0000 (14:54 +0900)
fix SyntaxWarning: invalid escape sequence
Change-Id: I0d51350f54bdfe953550ecba948db8cc0898344d
Signed-off-by: wangbiao <biao716.wang@samsung.com>
mic/cmd_create.py
mic/conf.py [changed mode: 0755->0644]
mic/rt_util.py
mic/utils/misc.py [changed mode: 0755->0644]
mic/utils/rpmmisc.py
plugins/imager/raw_plugin.py

index bb60c9dcae861d4d74334c40cda0ea91426a11a2..ed8a7c9ee1156eea2c806354c2e26136464f3bc4 100644 (file)
@@ -231,9 +231,9 @@ def do_auto(parser, ksfile, argv):
 
             inline_argv = m.group(1).strip()
             if ptype == 'mic':
-                m2 = re.search('(?P<format>\w+)', inline_argv)
+                m2 = re.search(r'(?P<format>\w+)', inline_argv)
             elif ptype == 'mic2':
-                m2 = re.search('(-f|--format(=)?)\s*(?P<format>\w+)',
+                m2 = re.search(r'(-f|--format(=)?)\s*(?P<format>\w+)',
                                inline_argv)
             else:
                 return None
@@ -251,8 +251,8 @@ def do_auto(parser, ksfile, argv):
         with open(ksfile, 'r') as rf:
             first_line = rf.readline()
 
-        mic_re = '^#\s*-\*-mic-options-\*-\s+(.*)\s+-\*-mic-options-\*-'
-        mic2_re = '^#\s*-\*-mic2-options-\*-\s+(.*)\s+-\*-mic2-options-\*-'
+        mic_re = r'^#\s*-\*-mic-options-\*-\s+(.*)\s+-\*-mic-options-\*-'
+        mic2_re = r'^#\s*-\*-mic2-options-\*-\s+(.*)\s+-\*-mic2-options-\*-'
 
         result = parse_magic_line(mic_re, first_line, 'mic') \
                  or parse_magic_line(mic2_re, first_line, 'mic2')
old mode 100755 (executable)
new mode 100644 (file)
index d24616b..0666d1f
@@ -163,7 +163,7 @@ class ConfigMgr(object):
 
             return
 
-        parser = configparser.SafeConfigParser()
+        parser = configparser.ConfigParser()
         parser.read(siteconf)
 
         for section in parser.sections():
@@ -177,7 +177,7 @@ class ConfigMgr(object):
 
         # check and normalize the scheme of proxy url
         if self.create['proxy']:
-            m = re.match('^(\w+)://.*', self.create['proxy'])
+            m = re.match(r'^(\w+)://.*', self.create['proxy'])
             if m:
                 scheme = m.group(1)
                 if scheme not in ('http', 'https', 'ftp', 'socks'):
index 5867d93e941bb1cba9a7352300690dc6ddc27475..44b8dfd9c35ad259d55943128754cbc878870573 100644 (file)
@@ -221,7 +221,7 @@ def sync_mic_conf(bootstrap, conf = '/etc/mic/mic.conf'):
     # auto select backend
     with open(_path(conf), 'r') as rf:
         conf_str = rf.read()
-    conf_str = re.sub("pkgmgr\s*=\s*.*", "pkgmgr=auto", conf_str)
+    conf_str = re.sub(r"pkgmgr\s*=\s*.*", "pkgmgr=auto", conf_str)
     with open(_path(conf), 'w') as wf:
         wf.write(conf_str)
 
@@ -259,7 +259,7 @@ def sync_mic(bootstrap, binpth = '/usr/bin/mic',
     # auto select backend
     with open(_path(conf), 'r') as rf:
         conf_str = rf.read()
-    conf_str = re.sub("pkgmgr\s*=\s*.*", "pkgmgr=auto", conf_str)
+    conf_str = re.sub(r"pkgmgr\s*=\s*.*", "pkgmgr=auto", conf_str)
     with open(_path(conf), 'w') as wf:
         wf.write(conf_str)
 
old mode 100755 (executable)
new mode 100644 (file)
index 25c6bb0..b52b617
@@ -51,9 +51,9 @@ from mic.utils import rpmmisc
 from mic.utils.safeurl import SafeURL
 
 
-RPM_RE  = re.compile("(.*)\.(.*) (.*)-(.*)")
+RPM_RE  = re.compile(r"(.*)\.(.*) (.*)-(.*)")
 RPM_FMT = "%(name)s.%(arch)s %(version)s-%(release)s"
-SRPM_RE = re.compile("(.*)-(\d+.*)-(\d+\.\d+).src.rpm")
+SRPM_RE = re.compile(r"(.*)-(\d+.*)-(\d+\.\d+).src.rpm")
 
 
 def build_name(kscfg, release=None, prefix = None, suffix = None):
@@ -341,7 +341,7 @@ def selinux_check(arch, fstypes):
 
 def get_image_type(path):
     def _get_extension_name(path):
-        match = re.search("(?<=\.)\w+$", path)
+        match = re.search(r"(?<=\.)\w+$", path)
         if match:
             return match.group(0)
         else:
index a4c4962166f95d9a831f938a8e87d2106a13e839..210d0b302368d728e7e271ccda7c67c519e86139 100644 (file)
@@ -114,7 +114,7 @@ class RPMInstallCallback:
                     rpmloc = h
                     hdr = readRpmHeader(self.ts, h)
 
-                m = re.match("(.*)-(\d+.*)-(\d+\.\d+)\.(.+)\.rpm", os.path.basename(rpmloc))
+                m = re.match(r"(.*)-(\d+.*)-(\d+\.\d+)\.(.+)\.rpm", os.path.basename(rpmloc))
                 if m:
                     pkgname = m.group(1)
                 else:
@@ -163,7 +163,7 @@ class RPMInstallCallback:
                     except:
                         rpmloc = h
 
-                    m = re.match("(.*)-(\d+.*)-(\d+\.\d+)\.(.+)\.rpm", os.path.basename(rpmloc))
+                    m = re.match(r"(.*)-(\d+.*)-(\d+\.\d+)\.(.+)\.rpm", os.path.basename(rpmloc))
                     if m:
                         pkgname = m.group(1)
                     else:
@@ -204,7 +204,7 @@ class RPMInstallCallback:
                 except:
                     rpmloc = h
 
-                m = re.match("(.*)-(\d+.*)-(\d+\.\d+)\.(.+)\.rpm", os.path.basename(rpmloc))
+                m = re.match(r"(.*)-(\d+.*)-(\d+\.\d+)\.(.+)\.rpm", os.path.basename(rpmloc))
                 if m:
                     pkgname = m.group(1)
                 else:
index e5b35dc16d3f99cb4fb0c1065cd635e8be1646be..66d2b8c8dead5744eee7f835e36c477345b4319a 100644 (file)
@@ -133,7 +133,7 @@ class RawPlugin(ImagerPlugin):
             #  2      3400531968B  3656384511B  255852544B   primary  linux-swap(v1)
             #  3      3656384512B  3720347647B  63963136B    primary  fat16          boot, lba
 
-            partition_info = re.split("\s+", line)
+            partition_info = re.split(r"\s+", line)
 
             size = partition_info[3].split("B")[0]