[PATCH 1/4] Slap an r"" on some strings to help them be identified as a regex.

Chris Lumens clumens at redhat.com
Wed Jun 19 13:58:47 UTC 2013


---
 pyanaconda/bootloader.py                | 6 +++---
 pyanaconda/network.py                   | 2 +-
 pyanaconda/ui/gui/spokes/langsupport.py | 2 +-
 pyanaconda/ui/gui/spokes/welcome.py     | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index bb0775f..be89e15 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -99,7 +99,7 @@ def parse_serial_opt(arg):
     Also note that the kernel assumes 1 stop bit; this can't be changed.
     """
     opts = serial_opts()
-    m = re.match('\d+', arg)
+    m = re.match(r'\d+', arg)
     if m is None:
         return opts
     opts.speed = m.group()
@@ -2061,8 +2061,8 @@ class ZIPL(BootLoader):
                 #     Preparing boot device: dasdb (0200).
                 #     Preparing boot device: dasdl.
                 # We want to extract the device name and pass that.
-                name = re.sub(".+?: ", "", line)
-                self.stage1_name = re.sub("(\s\(.+\))?\.$", "", name)
+                name = re.sub(r".+?: ", "", line)
+                self.stage1_name = re.sub(r"(\s\(.+\))?\.$", "", name)
 
         if not self.stage1_name:
             raise BootLoaderError("could not find IPL device")
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index 2e93f1c..e0952ae 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -56,7 +56,7 @@ DEFAULT_HOSTNAME = "localhost.localdomain"
 
 # part of a valid hostname between two periods (cannot start nor end with '-')
 # for more info about '(?!-)' and '(?<!-)' see 're' module documentation
-HOSTNAME_PART_RE = re.compile("(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)
+HOSTNAME_PART_RE = re.compile(r"(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)
 
 ifcfglog = None
 def setup_ifcfg_log():
diff --git a/pyanaconda/ui/gui/spokes/langsupport.py b/pyanaconda/ui/gui/spokes/langsupport.py
index 8e90cb7..b071c01 100644
--- a/pyanaconda/ui/gui/spokes/langsupport.py
+++ b/pyanaconda/ui/gui/spokes/langsupport.py
@@ -137,7 +137,7 @@ class LangsupportSpoke(NormalSpoke):
         return retval
 
     def _add_language(self, store, native, english, setting, selected, additional):
-        store.append(['<span lang="%s">%s</span>' % (re.sub('\..*', '', setting), native),
+        store.append(['<span lang="%s">%s</span>' % (re.sub(r'\..*', '', setting), native),
                      english, setting, selected, additional])
 
     def _select_language(self, store, language):
diff --git a/pyanaconda/ui/gui/spokes/welcome.py b/pyanaconda/ui/gui/spokes/welcome.py
index 9a1f678..5c3a47f 100644
--- a/pyanaconda/ui/gui/spokes/welcome.py
+++ b/pyanaconda/ui/gui/spokes/welcome.py
@@ -259,7 +259,7 @@ class WelcomeLanguageSpoke(StandaloneSpoke):
         self._languageStoreFilter.refilter()
 
     def _addLanguage(self, store, native, english, setting):
-        lang = '<span lang="%s">%s</span>' % (re.sub('\..*', '', setting), native)
+        lang = '<span lang="%s">%s</span>' % (re.sub(r'\..*', '', setting), native)
         store.append([lang, english, setting, False])
 
     def _matchesEntry(self, model, itr, *args):
-- 
1.8.1.2



More information about the anaconda-patches mailing list