diff options
author | 2015-10-07 04:37:09 -0400 | |
---|---|---|
committer | 2015-10-07 04:37:09 -0400 | |
commit | 56bfb6c2fbb15dbc1b9bd2b618a47cc82d5f9a6c (patch) | |
tree | d29f79fabf481e08690a455170d052429f9982c6 | |
parent | lint: remove unused imports. (diff) | |
download | grss-56bfb6c2fbb15dbc1b9bd2b618a47cc82d5f9a6c.tar.gz grss-56bfb6c2fbb15dbc1b9bd2b618a47cc82d5f9a6c.tar.bz2 grss-56bfb6c2fbb15dbc1b9bd2b618a47cc82d5f9a6c.zip |
lint: use raw strings with regexes.
-rw-r--r-- | grs/Interpret.py | 6 | ||||
-rw-r--r-- | grs/Kernel.py | 6 | ||||
-rw-r--r-- | grs/Populate.py | 2 | ||||
-rw-r--r-- | grs/Rotator.py | 4 | ||||
-rw-r--r-- | grs/WorldConf.py | 8 |
5 files changed, 13 insertions, 13 deletions
diff --git a/grs/Interpret.py b/grs/Interpret.py index fd36650..db5bdd4 100644 --- a/grs/Interpret.py +++ b/grs/Interpret.py @@ -162,14 +162,14 @@ class Interpret(Daemon): line_number += 1 # Skip lines with initial # as comments. - m = re.search('^(#).*$', l) + m = re.search(r'^(#).*$', l) if m: continue # For a release run, execute every line of the build script. # For an update run, exexute only lines with a leading +. ignore_stamp = False - m = re.search('^(\+)(.*)$', l) + m = re.search(r'^(\+)(.*)$', l) if m: # There is a leading +, so remove it and skip if doing an update run ignore_stamp = self.update_run @@ -187,7 +187,7 @@ class Interpret(Daemon): # single 'verb', or a 'verb obj' pair. While restrictive, # its good enough for now. try: - m = re.search('(\S+)\s+(\S+)', l) + m = re.search(r'(\S+)\s+(\S+)', l) verb = m.group(1) obj = m.group(2) except AttributeError: diff --git a/grs/Kernel.py b/grs/Kernel.py index 559aa57..a8205ba 100644 --- a/grs/Kernel.py +++ b/grs/Kernel.py @@ -47,18 +47,18 @@ class Kernel(): # The version line looks like the following: # Linux/x86 4.0.6-hardened-r2 Kernel Configuration # The 2nd group contains the version. - m = re.search('^#\s+(\S+)\s+(\S+).+$', version_line) + m = re.search(r'^#\s+(\S+)\s+(\S+).+$', version_line) gentoo_version = m.group(2) try: # Either the verison is of the form '4.0.6-hardened-r2' with two -'s - m = re.search('(\S+?)-(\S+?)-(\S+)', gentoo_version) + m = re.search(r'(\S+?)-(\S+?)-(\S+)', gentoo_version) vanilla_version = m.group(1) flavor = m.group(2) revision = m.group(3) pkg_name = flavor + '-sources-' + vanilla_version + '-' + revision except AttributeError: # Or the verison is of the form '4.0.6-hardened' with one - - m = re.search('(\S+?)-(\S+)', gentoo_version) + m = re.search(r'(\S+?)-(\S+)', gentoo_version) vanilla_version = m.group(1) flavor = m.group(2) pkg_name = flavor + '-sources-' + vanilla_version diff --git a/grs/Populate.py b/grs/Populate.py index a1822ee..3271cb7 100644 --- a/grs/Populate.py +++ b/grs/Populate.py @@ -64,7 +64,7 @@ class Populate(): cycled_files = {} for dirpath, dirnames, filenames in os.walk(self.workdir): for f in filenames: - m = re.search('^(.+)\.CYCLE\.(\d+)', f) + m = re.search(r'^(.+)\.CYCLE\.(\d+)', f) if m: filename = m.group(1) cycle_no = int(m.group(2)) diff --git a/grs/Rotator.py b/grs/Rotator.py index a1282b2..9daf7d2 100644 --- a/grs/Rotator.py +++ b/grs/Rotator.py @@ -45,7 +45,7 @@ class Rotator(): objs = glob.glob('%s.*' % obj) indexed_obj = {} for o in objs: - m = re.search('^.+\.(\d+)$', o) + m = re.search(r'^.+\.(\d+)$', o) indexed_obj[int(m.group(1))] = o count = list(indexed_obj.keys()) count.sort() @@ -58,7 +58,7 @@ class Rotator(): except NotADirectoryError: os.unlink(current_obj) continue - m = re.search('^(.+)\.\d+$', current_obj) + m = re.search(r'^(.+)\.\d+$', current_obj) next_obj = '%s.%d' % (m.group(1), c+1) shutil.move(current_obj, next_obj) diff --git a/grs/WorldConf.py b/grs/WorldConf.py index c5882bf..b55110f 100644 --- a/grs/WorldConf.py +++ b/grs/WorldConf.py @@ -53,7 +53,7 @@ class WorldConf(): config.read(CONST.WORLD_CONFIG) for s in config.sections(): for (directory, value) in config[s].items(): - p_slot_atom = re.sub('[/:]', '_', s) + p_slot_atom = re.sub(r'[/:]', '_', s) dpath = os.path.join(CONST.PORTAGE_CONFIGDIR, directory) fpath = os.path.join(dpath, p_slot_atom) os.makedirs(dpath, mode=0o755, exist_ok=True) @@ -84,18 +84,18 @@ class WorldConf(): cpv = portdb.cp_list(p)[0] slotvar = portdb.aux_get(cpv, ['SLOT'])[0] try: - m = re.search('(.+?)\/(.+)', slotvar) + m = re.search(r'(.+?)\/(.+)', slotvar) slot = m.group(1) except AttributeError: slot = slotvar - slot_atoms.append(re.sub('[/:]', '_', '%s:%s' % (p, slot))) + slot_atoms.append(re.sub(r'[/:]', '_', '%s:%s' % (p, slot))) # Also let's get a list of all the possible canonical file names config = configparser.RawConfigParser(delimiters=':', allow_no_value=True, comment_prefixes=None) config.read(CONST.WORLD_CONFIG) canon = [] for s in config.sections(): - p_slot_atom = re.sub('[/:]', '_', s) + p_slot_atom = re.sub(r'[/:]', '_', s) canon.append(p_slot_atom) # Walk through all files in /etc/portage and remove any files for uninstalled pkgs. |