Use startswith and endswith to simplify code.
Fix typos from the previous commit.
purge string module from emerge (WarnerBro)
fix "" " " bug (WarnerBro)
another annoy space bug (WarnerBro)
purge string module from repoman (WarnerBro)
purge string from portage.py, fix minor bug in portage_util (WarnerBro)
Fix a typo.
Fix a typo.
Revert accidentally modified joins.
Fix more typos.
Fix another typo.
Add a few pretty basic comments on writing code, particularly things
that portage used to do (and still does) that are...a bit out of style
;) (WarnerBro)
ignore py[co] in tests (WarnerBro)
remove the last of the string module from portage.py (WarnerBro)
svn path=/main/branches/prefix/; revision=5622
--- /dev/null
+Code Guidelines
+---------------
+A few code guidelines to try to stick to, please comment of none of these make
+sense, they are pretty basic and mostly apply to old code. However for people
+who are looking at current code, they make take up bad habits that exist in the
+current codebase.
+
+Strings
+-------
+Try not to use the functions in the string module, they are deprecated.
+
+string.join(<iterable>," ")
+
+should be replaced with:
+
+" ".join(<iterable>)
+
+and:
+
+string.split(string, delimeter)
+
+should be replaced with:
+
+string.split(delimeter)
+
+Nearly all other methods in string work on string objects and have similar calling
+conventions.
+
+Comparisons
+-----------
+
+if foo == None
+
+should be replaced with:
+
+if foo is not None:
+
+Is not does a reference comparison (address1 = address2 basically) and
+the == forces a by value compare (with __eq__())
+
+Dict Lookups
+------------
+
+Try not to use has_key, you can use
+
+if foo in dict
+
+instead of if dict.has_key(foo)
+
+Also don't do stuff like:
+
+if foo in dict and dict[foo]:
+
+Generally you can do two things here, if you are messing with defaults..
+
+dict.get(foo, some_default)
+
+will try to retrieve foo from dict, if there is a KeyError, will insert foo
+into dict with the value of some_default. This method is preferred in most cases.
+
+You can also do something like:
+
+try:
+ dict[foo]
+ ...stuff here..
+except KeyError:
+ print "holy cow we totally expected a keyerror here"
+
+in most instances however you are only catching the KeyError to set a default,
+in which case you should be using dict.get() or telling the user they are missing
+a required dict key.
if len(sys.argv) > 1:
# for testing
- d.grind ("".join( (sys.argv [1:]))
+ d.grind (" ".join(sys.argv[1:]))
else:
d.grind (portage.settings ['CONFIG_PROTECT'])
del os.environ["PORTAGE_LEGACY_GLOBALS"]
from portage import digraph
-import emergehelp, xpak, commands, errno, re, socket, string, time, types
+import emergehelp, xpak, commands, errno, re, socket, time, types
import output
from output import blue, bold, colorize, darkblue, darkgreen, darkred, green, \
havecolor, nc_len, nocolor, red, teal, turquoise, white, xtermTitle, \
print bold(prompt),
try:
while True:
- response=raw_input("["+string.join([colours[i](responses[i]) for i in range(len(responses))],"/")+"] ")
+ response=raw_input("["+"/".join([colours[i](responses[i]) for i in range(len(responses))])+"] ")
for key in responses:
# An empty response will match the first value in responses.
if response.upper()==key[:len(response)].upper():
for x in libclist:
xs=portage.catpkgsplit(x)
if libcver:
- libcver+=","+string.join(xs[1:], "-")
+ libcver+=","+"-".join(xs[1:])
else:
- libcver=string.join(xs[1:], "-")
+ libcver="-".join(xs[1:])
if libcver==[]:
libcver="unavailable"
raise
mynewlines=[]
for x in mylines:
- myline=string.join(string.split(x))
+ myline=" ".join(x.split())
if not len(myline):
continue
elif myline[0]=="#":
for p in alleb:
mreasons = portage.getmaskingstatus(p,
settings=pkgsettings, portdb=portdb)
- print "- "+p+" (masked by: "+string.join(mreasons, ", ")+")"
+ print "- "+p+" (masked by: "+", ".join(mreasons)+")"
comment = portage.getmaskingreason(p,
settings=pkgsettings, portdb=portdb)
if comment and comment != oldcomment:
for y in pkgmap[x]["selected"]:
print ">>> Unmerging "+y+"..."
emergelog(xterm_titles, "=== Unmerging... ("+y+")")
- mysplit=string.split(y,"/")
+ mysplit=y.split("/")
#unmerge...
retval = portage.unmerge(mysplit[0], mysplit[1], settings["ROOT"],
mysettings, unmerge_action not in ["clean","prune"],
if not os.path.exists(myportdir):
print ">>>",myportdir,"not found, creating it."
os.makedirs(myportdir,0755)
- syncuri=string.rstrip(settings["SYNC"])
+ syncuri=settings["SYNC"].rstrip()
os.umask(0022)
updatecache_flg = False
if myaction == "metadata":
output=commands.getstatusoutput("distcc --version")
if not output[0]:
- print str(string.split(output[1],"\n",1)[0]),
+ print str(output[1].split("\n",1)[0]),
if "distcc" in settings.features:
print "[enabled]"
else:
output=commands.getstatusoutput("ccache -V")
if not output[0]:
- print str(string.split(output[1],"\n",1)[0]),
+ print str(output[1].split("\n",1)[0]),
if "ccache" in settings.features:
print "[enabled]"
else:
else:
print "%-20s %s" % (x+":", "[NOT VALID]")
- libtool_vers = string.join(trees["/"]["vartree"].dbapi.match("sys-devel/libtool"), ",")
+ libtool_vers = ",".join(trees["/"]["vartree"].dbapi.match("sys-devel/libtool"))
if "--verbose" in myopts:
myvars=settings.keys()
time.strftime("%b %d, %Y %H:%M:%S", time.localtime()))
myelogstr=""
if myopts:
- myelogstr=string.join(myopts, " ")
+ myelogstr=" ".join(myopts)
if myaction:
myelogstr+=" "+myaction
if myfiles:
- myelogstr+=" "+string.join(myfiles, " ")
+ myelogstr+=" "+" ".join(myfiles)
emergelog(xterm_titles, " *** emerge " + myelogstr)
def emergeexitsig(signum, frame):
except ImportError:
sys.path.insert(0, "@PORTAGE_BASE@/pym")
import portage
-from threading import *
-from output import red,green,blue,bold
-from random import shuffle
-from time import sleep
-
+import portage_util
def cstrip(mystr,mychars):
newstr = ""
# This associates teh md5 with each file. [md5/size]
md5joins = md5_list[mybn][2].split(",")
- md5joins = " ["+md5_list[mybn][0]+"/"+md5_list[mybn][1]+"],".join(md5joins))
+ md5joins = (" ["+md5_list[mybn][0]+"/"+md5_list[mybn][1]+"],").join(md5joins)
md5joins += " ["+md5_list[mybn][0]+"/"+md5_list[mybn][1]+"]"
portage.writemsg("Colliding md5: %s of %s [%s/%s] and %s\n" % (mybn,mycpv,md5sums[mybn][0],md5sums[mybn][1],md5joins))
map(allowed_filename_chars_set.setdefault, map(chr, range(ord('0'), ord('9')+1)))
map(allowed_filename_chars_set.setdefault, map(chr, map(ord, [".", "-", "_", "+", ":"])))
-import string,signal,re,pickle,tempfile
+import signal,re,pickle,tempfile
os.environ["PORTAGE_LEGACY_GLOBALS"] = "false"
try:
print "|",turquoise(x),
print
print
- print " "+green(string.ljust("Options",20)+" Description")
+ print " "+green("Options".ljust(20)+" Description")
for x in options:
if repoman_shortoptions_rev.has_key(x):
shopt=repoman_shortoptions_rev[x]+", "+x
else:
shopt=" "+x
- print " "+string.ljust(shopt,20),repoman_options[x]
+ print " "+shopt.ljust(20),repoman_options[x]
print
- print " "+green(string.ljust("Modes",20)+" Description")
+ print " "+green("Modes".ljust(20)+" Description")
for x in modes:
- print " "+string.ljust(x,20),modeshelp[x]
+ print " "+x.ljust(20),modeshelp[x]
if helpfulness:
print
- print " "+green(string.ljust("QA keyword",20)+" Description")
+ print " "+green("QA keyword".ljust(20)+" Description")
for x in qacats:
- print " "+string.ljust(x,20),qahelp[x]
+ print " "+x.ljust(20),qahelp[x]
print
if (exitstatus != -1):
sys.exit(exitstatus)
else:
if mymode!="lfull":
continue
- print " "+string.ljust(x,20),
+ print " "+ x.ljust(20),
if stats[x]==0:
print green(`stats[x]`)
continue
myreporoot += mydir[len(portdir_overlay):-1]
if isSvn:
- reposplit=string.split(myreporoot,"/")
+ reposplit=myreporoot.split("/")
else:
- reposplit=string.split(myreporoot,"/")
+ reposplit=myreporoot.split("/")
repolevel=len(reposplit)
# check if it's in $PORTDIR/$CATEGORY/$PN , otherwise bail if commiting.
print red("***")+" Attempting to commit from a packages files directory will be blocked for instance."
print red("***")+" This is intended behaviour, to ensure the manifest is recommited for a package."
print red("***")
- err("Unable to identify level we're commiting from for %s" % string.join(reposplit,'/'))
+ err("Unable to identify level we're commiting from for %s" % '/'.join(reposplit))
startdir=os.getcwd()
try:
uselist=portage.grabfile(portdir+"/profiles/use.desc")
for l in range(0,len(uselist)):
- uselist[l]=string.split(uselist[l])[0]
- for var in string.split(repoman_settings["USE_EXPAND"]):
+ uselist[l]=uselist[l].split()[0]
+ for var in repoman_settings["USE_EXPAND"].split():
vardescs = portage.grabfile(portdir+"/profiles/desc/"+var.lower()+".desc")
for l in range(0, len(vardescs)):
- uselist.append(var.lower() + "_" + string.split(vardescs[l])[0])
+ uselist.append(var.lower() + "_" + vardescs[l].split()[0])
except SystemExit, e:
raise # Need to propogate this
except:
for x in portage.grabfile(descfile):
if x[0]=="#":
continue
- arch=string.split(x)
+ arch=x.split()
if len(arch)!=3:
print "wrong format: \""+red(x)+"\" in "+descfile
continue
for mytype in ("DEPEND", "RDEPEND", "PDEPEND", "LICENSE", "PROVIDE"):
mydepstr = myaux[mytype]
- if (string.find(mydepstr, " ?") != -1):
+ if mydepstr.find(" ?") != -1:
badsyntax.append("'?' preceded by space")
try:
#dofull will be set if we should print a "repoman full" informational message
dofull=0
for x in qacats:
- if not isCvs and not isSvn and (string.find(x, "notadded") != -1):
+ if not isCvs and not isSvn and (x.find("notadded") != -1):
stats[x] = 0
if stats[x]:
dowarn=1
dofail=1
else:
continue
- print " "+string.ljust(x,30),
+ print " "+x.ljust(30),
if stats[x]==0:
print green(`stats[x]`)
continue
To: {"blah":["foo","weee/splat"], "spork":["spatula"]}"""
mygroups={}
for x in mylist:
- xs=string.split(x,seperator)
+ xs=x.split(seperator)
if xs[0]==".":
xs=xs[1:]
if xs[0] not in mygroups.keys():
- mygroups[xs[0]]=[string.join(xs[1:],seperator)]
+ mygroups[xs[0]]=[seperator.join(xs[1:])]
else:
- mygroups[xs[0]]+=[string.join(xs[1:],seperator)]
+ mygroups[xs[0]]+=[seperator.join(xs[1:])]
return mygroups
if mymode!="commit":
if fails["digest.missing"]:
print green("Creating missing digests...")
for x in fails["digest.missing"]:
- xs=string.split(x,"/")
+ xs=x.split("/")
del xs[-2]
- myeb=string.join(xs[:-1],"/")+"/"+xs[-1][7:]
+ myeb="/".join(xs[:-1])+"/"+xs[-1][7:]
if "--pretend" in myoptions:
print "(ebuild "+portdir+"/"+myeb+".ebuild digest)"
else:
myautoadd=[]
if myunadded:
for x in range(len(myunadded)-1,-1,-1):
- xs=string.split(myunadded[x],"/")
+ xs=myunadded[x].split("/")
if xs[-1]=="files":
print "!!! files dir is not added! Please correct this."
sys.exit(-1)
elif len(xs[-1])>=7:
if xs[-1][:7]=="digest-":
del xs[-2]
- myeb=string.join(xs[:-1]+[xs[-1][7:]],"/")+".ebuild"
+ myeb="/".join(xs[:-1]+[xs[-1][7:]])+".ebuild"
if os.path.exists(myeb):
# Ebuild exists for digest... So autoadd it.
myautoadd+=[myunadded[x]]
print ">>> Auto-Adding missing digests..."
if "--pretend" in myoptions:
if isCvs:
- print "(cvs add "+string.join(myautoadd)+")"
+ print "(cvs add "+" ".join(myautoadd)+")"
if isSvn:
- print "(svn add "+string.join(myautoadd)+")"
+ print "(svn add "+" ".join(myautoadd)+")"
retval=0
else:
if isCvs:
- retval=os.system("cvs add "+string.join(myautoadd))
+ retval=os.system("cvs add "+" ".join(myautoadd))
if isSvn:
- retval=os.system("svn add "+string.join(myautoadd))
+ retval=os.system("svn add "+" ".join(myautoadd))
if retval:
print "!!! Exiting on vcs (shell) error code:",retval
sys.exit(retval)
print "Performing a "+green("svn update -u")+" with a little magic grep to check for updates."
retval=getstatusoutput(portage_const.EPREFIX+"/usr/bin/svn status -u 2>&1 | "+portage_const.EPREFIX+"/bin/egrep -v '^. +.*/digest-[^/]+' | "+portage_const.EPREFIX+"/bin/egrep -v '^Status against revision:'")
- mylines=string.split(retval[1], "\n")
+ mylines=retval[1].split("\n")
myupdates=[]
for x in mylines:
if not x:
if myupdates:
print green("Fetching trivial updates...")
if "--pretend" in myoptions:
- print "(cvs/svn up "+string.join(myupdates)+")"
+ print "(cvs/svn up "+" ".join(myupdates)+")"
retval=0
else:
if isCvs:
- retval=os.system("cvs up "+string.join(myupdates))
+ retval=os.system("cvs up "+" ".join(myupdates))
elif isSvn:
- retval=os.system("svn update "+string.join(myupdates))
+ retval=os.system("svn update "+" ".join(myupdates))
if retval!=0:
print "!!! cvs/svn exited with an error. Terminating."
sys.exit(retval)
retval = None
if "--pretend" in myoptions:
if isCvs:
- print "(cvs -q commit -F "+commitmessagefile+")"
+ print "(cvs -q commit -F "+commitmessagefile +" "+ " ".join(myupdates)+")"
if isSvn:
- print "(svn commit -F "+commitmessagefile+")"
+ print "(svn commit -F "+commitmessagefile +" "+ " ".join(myupdates)+")"
retval=0
else:
if isCvs:
- retval=os.system("cvs -q commit -F "+commitmessagefile)
+ retval=os.system("cvs -q commit -F "+commitmessagefile + " " +" ".join(myupdates))
if isSvn:
- retval=os.system("svn commit -F "+commitmessagefile)
- if retval:
- print "!!! Exiting on vcs (shell) error code:",retval
- sys.exit(retval)
+ retval=os.system("svn commit -F "+commitmessagefile + " " +" ".join(myupdates))
+ if retval:
+ print "!!! Exiting on vcs (shell) error code:",retval
+ sys.exit(retval)
# Setup the GPG commands
def gpgsign(filename):
myportdb=portdb)
elif repolevel==2: # In a category dir
for x in myfiles:
- xs=string.split(x,"/")
+ xs=x.split("/")
if xs[0]==".":
xs=xs[1:]
if xs[0] in mydone:
elif repolevel==1: # repo-cvsroot
print green("RepoMan sez:"), "\"You're rather crazy... doing the entire repository.\"\n"
for x in myfiles:
- xs=string.split(x,"/")
+ xs=x.split("/")
if xs[0]==".":
xs=xs[1:]
- if string.join(xs[:2],"/") in mydone:
+ if "/".join(xs[:2]) in mydone:
continue
- mydone.append(string.join(xs[:2],"/"))
+ mydone.append("/".join(xs[:2]))
repoman_settings["O"]=os.path.join(os.getcwd(), x[0], x[1])
portage.digestgen([], repoman_settings, manifestonly=1,
myportdb=portdb)
elif repolevel==2: # In a category dir
mydone=[]
for x in myfiles:
- xs=string.split(x,"/")
+ xs=x.split("/")
if xs[0]==".":
xs=xs[1:]
if xs[0] in mydone:
print green("RepoMan sez:"), "\"You're rather crazy... doing the entire repository.\"\n"
mydone=[]
for x in myfiles:
- xs=string.split(x,"/")
+ xs=x.split("/")
if xs[0]==".":
xs=xs[1:]
- if string.join(xs[:2],"/") in mydone:
+ if "/".join(xs[:2]) in mydone:
continue
- mydone.append(string.join(xs[:2],"/"))
+ mydone.append("/".join(xs[:2]))
repoman_settings["O"] = os.path.join(".", xs[0], xs[1])
gpgsign(os.path.join(repoman_settings["O"], "Manifest"))
except portage_exception.PortageException, e:
if not hasattr(__builtins__, "set"):
from sets import Set as set
-from output import *
+from output import red, yellow, green
import htmllib,HTMLParser,formatter,sys,os,xpak,time,tempfile,base64,urllib2
from portage_const import CACHE_PATH
def get_anchors_by_prefix(self,prefix):
newlist = []
for x in self.PL_anchors:
- if (len(x) >= len(prefix)) and (x[:len(suffix)] == prefix):
+ if x.startswith(prefix):
if x not in newlist:
newlist.append(x[:])
return newlist
def get_anchors_by_suffix(self,suffix):
newlist = []
for x in self.PL_anchors:
- if (len(x) >= len(suffix)) and (x[-len(suffix):] == suffix):
+ if x.endswith(suffix):
if x not in newlist:
newlist.append(x[:])
return newlist
raise
try:
- import copy, errno, os, re, shutil, string, time, types
+ import copy, errno, os, re, shutil, time, types
try:
import cPickle
except ImportError:
def load_mod(name):
- modname = string.join(string.split(name,".")[:-1],".")
+ modname = ".".join(name.split(".")[:-1])
mod = __import__(modname)
components = name.split('.')
for comp in components[1:]:
except IOError, details:
return (None, str(details))
- lines = map(string.strip, lines)
+ lines = [l.strip() for l in lines]
version = ''
#XXX: The following code relies on the ordering of vars within the Makefile
for line in lines:
# split on the '=' then remove annoying whitespace
- items = string.split(line, '=')
- items = map(string.strip, items)
+ items = line.split("=")
+ items = [i.strip() for i in items]
if items[0] == 'VERSION' or \
items[0] == 'PATCHLEVEL':
version += items[1]
# Append the contents of each to the version string, stripping ALL whitespace
for lv in localversions:
- version += string.join(string.split(string.join(grabfile(base_dir+"/"+lv))), "")
+ version += "".join( " ".join( grabfile( base_dir+ "/" + lv ) ).split() )
# Check the .config for a CONFIG_LOCALVERSION and append that too, also stripping whitespace
kernelconfig = getconfig(base_dir+"/.config")
if kernelconfig and kernelconfig.has_key("CONFIG_LOCALVERSION"):
- version += string.join(string.split(kernelconfig["CONFIG_LOCALVERSION"]), "")
+ version += "".join(kernelconfig["CONFIG_LOCALVERSION"].split())
return (version,None)
if self.configdict["defaults"]["ARCH"] not in usesplit:
usesplit.insert(0,self.configdict["defaults"]["ARCH"])
- self.configlist[-1]["USE"]=string.join(usesplit," ")
+ self.configlist[-1]["USE"]= " ".join(usesplit)
self.already_in_regenerate = 0
features = mysettings.features
# XXX: Negative RESTRICT word
droppriv=(droppriv and ("userpriv" in features) and not \
- (("nouserpriv" in string.split(mysettings["RESTRICT"])) or \
- ("userpriv" in string.split(mysettings["RESTRICT"]))))
+ (("nouserpriv" in mysettings["RESTRICT"].split()) or \
+ ("userpriv" in mysettings["RESTRICT"].split())))
if droppriv and not uid and portage_gid and portage_uid:
keywords.update({"uid":portage_uid,"gid":portage_gid,"groups":userpriv_groups,"umask":002})
if sesandbox:
con = selinux.getcontext()
- con = string.replace(con, mysettings["PORTAGE_T"], mysettings["PORTAGE_SANDBOX_T"])
+ con = con.replace(mysettings["PORTAGE_T"], mysettings["PORTAGE_SANDBOX_T"])
selinux.setexec(con)
retval = spawn_func(mystring, env=env, **keywords)
else:
resumecommand=mysettings["RESUMECOMMAND"]
- fetchcommand=string.replace(fetchcommand,"${DISTDIR}",mysettings["DISTDIR"])
- resumecommand=string.replace(resumecommand,"${DISTDIR}",mysettings["DISTDIR"])
+ fetchcommand=fetchcommand.replace("${DISTDIR}",mysettings["DISTDIR"])
+ resumecommand=resumecommand.replace("${DISTDIR}",mysettings["DISTDIR"])
if not can_fetch:
if fetched != 2:
locfetch=fetchcommand
writemsg_stdout(">>> Downloading '%s'\n" % \
re.sub(r'//(.+):.+@(.+)/',r'//\1:*password*@\2/', loc))
- myfetch=string.replace(locfetch,"${URI}",loc)
- myfetch=string.replace(myfetch,"${FILE}",myfile)
+ myfetch=locfetch.replace("${URI}",loc)
+ myfetch=myfetch.replace("${FILE}",myfile)
spawn_keywords = {}
if "userfetch" in mysettings.features and \
if mysettings.selinux_enabled():
con = selinux.getcontext()
- con = string.replace(con, mysettings["PORTAGE_T"], mysettings["PORTAGE_FETCH_T"])
+ con = con.replace(mysettings["PORTAGE_T"], mysettings["PORTAGE_FETCH_T"])
selinux.setexec(con)
myret = portage_exec.spawn_bash(myfetch,
mysettings["ECLASSDIR"] = os.path.join(mysettings["PORTDIR"], "eclass")
mysettings["SANDBOX_LOG"] = mycpv.replace(os.path.sep, "_-_")
- mysettings["PROFILE_PATHS"] = string.join(mysettings.profiles,"\n")+"\n"+CUSTOM_PROFILE_PATH
+ mysettings["PROFILE_PATHS"] = "\n".join(mysettings.profiles)+"\n"+CUSTOM_PROFILE_PATH
mysettings["P"] = mysplit[0]+"-"+mysplit[1]
mysettings["PN"] = mysplit[0]
mysettings["PV"] = mysplit[1]
mysettings["PVR"]=mysplit[1]+"-"+mysplit[2]
if mysettings.has_key("PATH"):
- mysplit=string.split(mysettings["PATH"],":")
+ mysplit=mysettings["PATH"].split(":")
else:
mysplit=[]
if PORTAGE_BIN_PATH not in mysplit:
for vcount in range(len(validcommands)):
if vcount%6 == 0:
writemsg("\n!!! ", noiselevel=-1)
- writemsg(string.ljust(validcommands[vcount], 11), noiselevel=-1)
+ writemsg(validcommands[vcount].ljust(11), noiselevel=-1)
writemsg("\n", noiselevel=-1)
return 1
if use=="yes":
if myuse is None:
#default behavior
- myusesplit = string.split(mysettings["USE"])
+ myusesplit = mysettings["USE"].split()
else:
myusesplit = myuse
# We've been given useflags to use.
"returns file location for this particular package (DEPRECATED)"
if not pkgname:
return ""
- mysplit=string.split(pkgname,"/")
+ mysplit=pkgname.split("/")
psplit=pkgsplit(mysplit[1])
return self.portroot+"/"+mysplit[0]+"/"+psplit[0]+"/"+mysplit[1]+".ebuild"
if aux_cache is not None:
return [aux_cache[x] for x in wants]
cache_me = True
- mysplit = string.split(mycpv,"/")
+ mysplit = mycpv.split("/")
mylist = []
tbz2name = mysplit[1]+".tbz2"
if self.bintree and not self.bintree.isremote(mycpv):
for myprovide in mylines:
mys = catpkgsplit(myprovide)
if not mys:
- mys = string.split(myprovide, "/")
+ mys = myprovide.split("/")
myprovides += [mys[0] + "/" + mys[1]]
return myprovides
except SystemExit, e:
mydig = self.findname2(mycpv)[0]
if not mydig:
return ""
- mydigs = string.split(mydig, "/")[:-1]
- mydig = string.join(mydigs, "/")
-
+ mydigs = mydig.split("/")[:-1]
+ mydig = "/".join(mydigs)
mysplit = mycpv.split("/")
except OSError:
return ""
return [aux_cache[x] for x in mylist]
cache_me = True
global auxdbkeys,auxdbkeylen
- cat,pkg = string.split(mycpv, "/", 1)
+ cat,pkg = mycpv.split("/", 1)
myebuild, mylocation = self.findname2(mycpv, mytree)
writemsg("!!! %s\n" % myebuild, noiselevel=1)
raise KeyError(mycpv)
- myManifestPath = string.join(myebuild.split("/")[:-1],"/")+"/Manifest"
+ myManifestPath = "/".join(myebuild.split("/")[:-1])+"/Manifest"
if "gpg" in self.mysettings.features:
try:
mys = portage_gpg.fileStats(myManifestPath)
sys.exit(1)
if useflags is None:
- useflags = string.split(mysettings["USE"])
+ useflags = mysettings["USE"].split()
myurilist = portage_dep.paren_reduce(myuris)
myurilist = portage_dep.use_reduce(myurilist,uselist=useflags,matchall=all)
noiselevel=-1)
del self.remotepkgs[mypkg]
continue
- mycat=string.strip(self.remotepkgs[mypkg]["CATEGORY"])
+ mycat=self.remotepkgs[mypkg]["CATEGORY"].strip()
fullpkg=mycat+"/"+mypkg[:-5]
mykey=dep_getkey(fullpkg)
try:
def isremote(self,pkgname):
"Returns true if the package is kept remotely."
- mysplit=string.split(pkgname,"/")
+ mysplit=pkgname.split("/")
remote = (not os.path.exists(self.getname(pkgname))) and self.remotepkgs.has_key(mysplit[1]+".tbz2")
return remote
def get_use(self,pkgname):
- mysplit=string.split(pkgname,"/")
+ mysplit=pkgname.split("/")
if self.isremote(pkgname):
- return string.split(self.remotepkgs[mysplit[1]+".tbz2"]["USE"][:])
+ return self.remotepkgs[mysplit[1]+".tbz2"]["USE"][:].split()
tbz2=xpak.tbz2(self.getname(pkgname))
- return string.split(tbz2.getfile("USE"))
+ return tbz2.getfile("USE").split()
def gettbz2(self,pkgname):
"fetches the package from a remote site, if necessary."
print "Fetching '"+str(pkgname)+"'"
- mysplit = string.split(pkgname,"/")
+ mysplit = pkgname.split("/")
tbz2name = mysplit[1]+".tbz2"
if not self.isremote(pkgname):
if (tbz2name not in self.invalids):
myc.close()
pos=1
for line in mylines:
- mydat = string.split(line)
+ mydat = line.split()
# we do this so we can remove from non-root filesystems
# (use the ROOT var to allow maintenance on other partitions)
try:
self.myroot, mydat[1].lstrip(os.path.sep)))
if mydat[0]=="obj":
#format: type, mtime, md5sum
- pkgfiles[string.join(mydat[1:-2]," ")]=[mydat[0], mydat[-1], mydat[-2]]
+ pkgfiles[" ".join(mydat[1:-2])]=[mydat[0], mydat[-1], mydat[-2]]
elif mydat[0]=="dir":
#format: type
- pkgfiles[string.join(mydat[1:])]=[mydat[0] ]
+ pkgfiles[" ".join(mydat[1:])]=[mydat[0] ]
elif mydat[0]=="sym":
#format: type, mtime, dest
x=len(mydat)-1
x=x-1
if splitter==-1:
return None
- pkgfiles[string.join(mydat[1:splitter]," ")]=[mydat[0], mydat[-1], string.join(mydat[(splitter+1):-1]," ")]
+ pkgfiles[" ".join(mydat[1:splitter])]=[mydat[0], mydat[-1], " ".join(mydat[(splitter+1):-1])]
elif mydat[0]=="dev":
#format: type
- pkgfiles[string.join(mydat[1:]," ")]=[mydat[0] ]
+ pkgfiles[" ".join(mydat[1:])]=[mydat[0] ]
elif mydat[0]=="fif":
#format: type
- pkgfiles[string.join(mydat[1:]," ")]=[mydat[0]]
+ pkgfiles[" ".join(mydat[1:])]=[mydat[0]]
else:
return None
except (KeyError,IndexError):
# string.lower is needed because db entries used to be in upper-case. The
# string.lower allows for backwards compatibility.
- if mymd5 != string.lower(pkgfiles[objkey][2]):
+ if mymd5 != pkgfiles[objkey][2].lower():
writemsg_stdout("--- !md5 %s %s\n" % ("obj", obj))
continue
try:
if not os.path.exists(self.dbdir+"/"+name):
return ""
myfile=open(self.dbdir+"/"+name,"r")
- mydata=string.split(myfile.read())
+ mydata=myfile.read().split()
myfile.close()
- return string.join(mydata," ")
+ return " ".join(mydata)
def copyfile(self,fname):
shutil.copyfile(fname,self.dbdir+"/"+os.path.basename(fname))
mylines=myelement.readlines()
myreturn=[]
for x in mylines:
- for y in string.split(x[:-1]):
+ for y in x[:-1].split():
myreturn.append(y)
myelement.close()
return myreturn
sys.stderr.write("Note: Nested use flags without parenthesis (Deprecated)\n")
warned = 1
if warned:
- sys.stderr.write(" --> "+"".join(map(str,[head]+newdeparray))+"\n")
+ sys.stderr.write(" --> "+" ".join(map(str,[head]+newdeparray))+"\n")
# Check that each flag matches
ismatch = True
for x in mylines:
#the split/join thing removes leading and trailing whitespace, and converts any whitespace in the line
#into single spaces.
- myline="".join(x.split())
+ myline=" ".join(x.split())
if not len(myline):
continue
if myline[0]=="#":
final_dict[y] += " "+mydict[y][:]
else:
final_dict[y] = mydict[y][:]
- mydict[y] = "".join(mydict[y].split()) # Remove extra spaces.
+ mydict[y] = " ".join(mydict[y].split()) # Remove extra spaces.
return final_dict
def stack_lists(lists, incremental=1):