Changed how variable replacement works.

This commit is contained in:
bjschuma 2010-02-28 15:44:40 -05:00
parent 3d89fc26a0
commit 54bd397584
7 changed files with 48 additions and 16 deletions

View File

@ -36,7 +36,9 @@ def runCmd(input):
def varCheck(cmd):
split = cmd.split('=', 1)
if len(split)==2 and len(split[0].split())==1:
var = "$" + split[0].strip()
var = split[0].strip()
if not var[0]=="$":
var = "$" + var
write("Using variable: "+var, 2)
return ( var, split[1].strip() )
else:
@ -45,18 +47,13 @@ def varCheck(cmd):
# Replace variables in the command with their real values
def varReplace(cmd):
split = cmd.split()
out = ""
for index,word in enumerate(split):
if index > 0:
out += " "
if vars.has(word)==True:
new = str(vars[word])
write(word + " => " + new, 2)
out += new
else:
out += word
return out
for key in vars.keys():
v = "`"+key+"`"
if cmd.find(v) > -1:
new = str(vars[key])
write(key + " => " + new, 2)
cmd = cmd.replace(v, new)
return cmd
# Replace aliases with their real values

View File

@ -47,7 +47,7 @@ class PluginLoader:
# Load the module into our module array
write("Attempting to load "+mod, 2)
#try:
self.loadmod(split[0], os.path.join(dir,mod))
self.loadmod(split[0], dir)
#except:
# error("Error loading "+mod)

View File

@ -25,7 +25,6 @@ global settings
global manager
global vars
vars = dict.Dict()
#global events
def setSession():
@ -48,6 +47,7 @@ def parseInput():
try:
opts, args = getopt.getopt(input, optc, long)
settings["verbose"] = 0
settings["plugpath"] = []
for opt in opts:
if (opt[0]=="-p") or (opt[0]=="--path"):
settings["plugpath"] += [opt[1]]

View File

@ -26,7 +26,7 @@ class Settings(dict.Dict):
def setdefaults(self):
write("Setting default values",1)
self['user'] = os.path.expanduser("~")
self['plugpath'] = ["plugins", "extra"]
self['plugpath'] += ["plugins", "extra"]
self['arch'] = platform
self['appname'] = "scion"
write(self,3)

31
src/plugins/sess.py Normal file
View File

@ -0,0 +1,31 @@
# Basic plugin class
__author__="bjschuma"
__date__ ="$Feb 26, 2010 9:13:54 PM$"
from bt import plugin
from bt.message import write
import session
class Plugin(plugin.Plugin):
def __init__(self):
plugin.Plugin.__init__(self)
self.help = "Display information about the current session"
self.usage = "session [list]"
def list(self,args):
if args[0] == "settings":
write(session.aliases)
def run(self, args=None):
if args==None or len(args)<2:
write(usage)
if args[0]=="list":
self.list(args[1:])

2
src/tests/test5.2.scion Normal file
View File

@ -0,0 +1,2 @@
echo Second file started
echo $a

2
src/tests/test5.scion Normal file
View File

@ -0,0 +1,2 @@
$a = test
exec file tests/test5.2.scion