except Exception as e:
raise portage.exception.ParseError(str(e)+" in "+mycfg)
return mykeys
-
-#cache expansions of constant strings
-cexpand={}
+
def varexpand(mystring, mydict=None):
if mydict is None:
mydict = {}
- newstring = cexpand.get(" "+mystring, None)
- if newstring is not None:
- return newstring
"""
new variable expansion code. Preserves quotes, handles \n, etc.
insing=0
indoub=0
pos=1
- newstring=" "
+ newstring = ""
while (pos<len(mystring)):
if (mystring[pos]=="'") and (mystring[pos-1]!="\\"):
if (indoub):
while mystring[pos] in validchars:
if (pos+1)>=len(mystring):
if braced:
- cexpand[mystring]=""
return ""
else:
pos=pos+1
myvarname=mystring[myvstart:pos]
if braced:
if mystring[pos]!="}":
- cexpand[mystring]=""
return ""
else:
pos=pos+1
if len(myvarname)==0:
- cexpand[mystring]=""
return ""
numvars=numvars+1
if myvarname in mydict:
else:
newstring=newstring+mystring[pos]
pos=pos+1
- if numvars==0:
- cexpand[mystring]=newstring[1:]
- return newstring[1:]
+
+ return newstring
# broken and removed, but can still be imported
pickle_write = None