From: Brian Dolbec <dolsen@gentoo.org>
To: gentoo-catalyst@lists.gentoo.org
Subject: Re: [gentoo-catalyst] [PATCH] lint: drop use of deprecated string module
Date: Mon, 5 Oct 2015 23:22:12 -0700 [thread overview]
Message-ID: <20151005232212.542383d1.dolsen@gentoo.org> (raw)
In-Reply-To: <1444103301-14607-1-git-send-email-vapier@gentoo.org>
On Mon, 5 Oct 2015 23:48:21 -0400
Mike Frysinger <vapier@gentoo.org> wrote:
> Replace string.join() with ' '.join() and string.replace(var, ...)
> with var.replace(...) as the string module is deprecated. No real
> functional changes here otherwise.
> ---
> catalyst/base/stagebase.py | 33
> ++++++++++++++++----------------- catalyst/support.py
> | 8 ++++---- catalyst/targets/livecd_stage1.py | 3 +--
> 3 files changed, 21 insertions(+), 23 deletions(-)
>
> diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
> index 8a7456e..432ad5c 100644
> --- a/catalyst/base/stagebase.py
> +++ b/catalyst/base/stagebase.py
> @@ -1,6 +1,5 @@
>
> import os
> -import string
> import imp
> import types
> import shutil
> @@ -312,7 +311,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
> if "install_mask" in self.settings:
> if
> type(self.settings["install_mask"])!=types.StringType:
> self.settings["install_mask"]=\
> -
> string.join(self.settings["install_mask"])
> + '
> '.join(self.settings["install_mask"])
> def set_spec_prefix(self):
> self.settings["spec_prefix"]=self.settings["target"]
> @@ -596,7 +595,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
> self.settings["portage_overlay"]=\
> self.settings["portage_overlay"].split()
> print "portage_overlay directories are set
> to: \""+\
> -
> string.join(self.settings["portage_overlay"])+"\""
> + '
> '.join(self.settings["portage_overlay"])+"\""
> def set_overlay(self):
> if self.settings["spec_prefix"]+"/overlay" in
> self.settings: @@ -1134,7 +1133,7 @@ class StageBase(TargetBase,
> ClearBase, GenBase): if myusevars:
> myf.write("# These are the USE and
> USE_EXPAND flags that were used for\n# building in addition to what
> is provided by the profile.\n") myusevars = sorted(set(myusevars))
> -
> myf.write('USE="'+string.join(myusevars)+'"\n')
> + myf.write('USE="' + '
> '.join(myusevars) + '"\n') if '-*' in myusevars:
> print "\nWarning!!! "
> print "\tThe use of -* in
> "+self.settings["spec_prefix"]+\ @@ -1148,7 +1147,7 @@ class
> StageBase(TargetBase, ClearBase, GenBase):
> if myuseexpandvars:
> for hostuseexpand in myuseexpandvars:
> -
> myf.write(hostuseexpand+'="'+string.join(myuseexpandvars[hostuseexpand])+'"\n')
> + myf.write(hostuseexpand +
> '="' + ' '.join(myuseexpandvars[hostuseexpand]) + '"\n')
> myf.write('PORTDIR="%s"\n' %
> self.settings['portdir']) myf.write('DISTDIR="%s"\n' %
> self.settings['distdir']) @@ -1354,16 +1353,16 @@ class
> StageBase(TargetBase, ClearBase, GenBase): self.env['clst_' +
> opt.upper()] = "true" continue
> """ Sanitize var names by doing "s|/-.|_|g"
> """
> - varname="clst_"+string.replace(x,"/","_")
> - varname=string.replace(varname,"-","_")
> - varname=string.replace(varname,".","_")
> + varname = "clst_" + x.replace("/", "_")
> + varname = varname.replace("-", "_")
> + varname = varname.replace(".", "_")
> if type(self.settings[x])==types.StringType:
> """ Prefix to prevent namespace
> clashes """ #os.environ[varname]=self.settings[x]
> self.env[varname]=self.settings[x]
> elif type(self.settings[x])==types.ListType:
> -
> #os.environ[varname]=string.join(self.settings[x])
> -
> self.env[varname]=string.join(self.settings[x])
> + #os.environ[varname] = '
> '.join(self.settings[x])
> + self.env[varname] = '
> '.join(self.settings[x]) elif
> type(self.settings[x])==types.BooleanType: if self.settings[x]:
> self.env[varname] = "true"
> @@ -1377,15 +1376,15 @@ class StageBase(TargetBase, ClearBase,
> GenBase): if x in ["compress_definitions",
> "decompress_definitions"]:
> continue
> - self.env[varname] =
> string.join(self.settings[x].keys())
> + self.env[varname] = '
> '.join(self.settings[x].keys()) for y in self.settings[x].keys():
> - varname2 =
> "clst_"+string.replace(y,"/","_")
> - varname2 =
> string.replace(varname2,"-","_")
> - varname2 =
> string.replace(varname2,".","_")
> + varname2 = "clst_" +
> y.replace("/", "_")
> + varname2 =
> varname2.replace("-", "_")
> + varname2 =
> varname2.replace(".", "_") if type(self.settings[x][y]) ==
> types.StringType: self.env[varname2] = self.settings[x][y]
> elif
> type(self.settings[x][y]) == types.ListType:
> - self.env[varname2] =
> string.join(self.settings[x][y])
> + self.env[varname2] =
> ' '.join(self.settings[x][y]) elif type(self.settings[x][y]) ==
> types.BooleanType: if self.settings[x][y]:
> self.env[varname]
> = "true" @@ -1464,7 +1463,7 @@ class StageBase(TargetBase, ClearBase,
> GenBase): things like "<" to remain intact
> """
> myunmerge[x]="'"+myunmerge[x]+"'"
> - myunmerge=string.join(myunmerge)
> + myunmerge = ' '.join(myunmerge)
>
> """ Before cleaning, unmerge stuff
> """ try:
> @@ -1588,7 +1587,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
> "/kernelopts"]
>
> if type(myopts) != types.StringType:
> - myopts = string.join(myopts)
> + myopts = ' '.join(myopts)
> self.env[kname+"_kernelopts"]=myopts
>
> else:
> diff --git a/catalyst/support.py b/catalyst/support.py
> index 78942a7..5563a15 100644
> --- a/catalyst/support.py
> +++ b/catalyst/support.py
> @@ -1,7 +1,7 @@
>
> import glob
> import sys
> -import string
> +import string # pylint: disable=deprecated-module
> import os
> import types
> import re
> @@ -52,7 +52,7 @@ def read_from_clst(file):
> return -1
> #raise CatalystError("Could not open file "+file)
> for line in myf.readlines():
> - #line = string.replace(line, "\n", "") # drop newline
> + #line = line.replace("\n", "") # drop newline
> myline = myline + line
> myf.close()
> return myline
> @@ -67,7 +67,7 @@ def list_bashify(mylist):
> # surround args with quotes for passing to bash,
> # allows things like "<" to remain intact
> mypack[x]="'"+mypack[x]+"'"
> - mypack=string.join(mypack)
> + mypack = ' '.join(mypack)
> return mypack
>
>
> @@ -80,7 +80,7 @@ def list_to_string(mylist):
> # surround args with quotes for passing to bash,
> # allows things like "<" to remain intact
> mypack[x]=mypack[x]
> - mypack=string.join(mypack)
> + mypack = ' '.join(mypack)
> return mypack
>
>
> diff --git a/catalyst/targets/livecd_stage1.py
> b/catalyst/targets/livecd_stage1.py index d5645e8..af59ed7 100644
> --- a/catalyst/targets/livecd_stage1.py
> +++ b/catalyst/targets/livecd_stage1.py
> @@ -5,7 +5,6 @@ LiveCD stage1 target
>
> import os
> import types
> -import string
>
>
> from catalyst.support import (normpath,
> @@ -70,6 +69,6 @@ class livecd_stage1(StageBase):
> def set_pkgcache_path(self):
> if "pkgcache_path" in self.settings:
> if type(self.settings["pkgcache_path"]) !=
> types.StringType:
> -
> self.settings["pkgcache_path"]=normpath(string.join(self.settings["pkgcache_path"]))
> +
> self.settings["pkgcache_path"]=normpath('
> '.join(self.settings["pkgcache_path"])) else:
> StageBase.set_pkgcache_path(self)
:D I've been putting off doing these for far too long. I had too many
patches queued and bigger problems to fix/recode... I did however do
any I had other code changes to do involving them. It use to be much
worse ;)
--
Brian Dolbec <dolsen>
prev parent reply other threads:[~2015-10-06 6:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-06 3:48 [gentoo-catalyst] [PATCH] lint: drop use of deprecated string module Mike Frysinger
2015-10-06 6:22 ` Brian Dolbec [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151005232212.542383d1.dolsen@gentoo.org \
--to=dolsen@gentoo.org \
--cc=gentoo-catalyst@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox