"more pythonic and more simple" is our motto!

This commit is contained in:
Barış Metin
2005-07-04 16:29:40 +00:00
parent 61bbfeabf4
commit 24c27baf3f
+11 -14
View File
@@ -124,33 +124,30 @@ class PisiBuild:
os.environ.update(evn) os.environ.update(evn)
def compileActionScript(self): def compileActionScript(self):
specdir = os.path.dirname(self.ctx.pspecfile)
scriptfile = os.path.join(specdir, const.actions_file)
try: try:
specdir = os.path.dirname(self.ctx.pspecfile) localSymbols = globalSymbols = {}
self.actionScript = open(os.path.join(specdir, buf = open(scriptfile).read()
const.actions_file)).read() exec compile(buf, "error", "exec") in localSymbols, globalSymbols
except IOError, e: except IOError, e:
ui.error("Action Script: %s\n" % e) ui.error("Unable to read Action Script (%s): %s\n" %(scriptfile,e))
return sys.exit(1)
localSymbols = globalSymbols = {}
try:
exec compile(self.actionScript, "error", "exec") in \
localSymbols, globalSymbols
except SyntaxError, e: except SyntaxError, e:
ui.error ("Error : %s\n" % e) ui.error ("SyntaxError in Action Script (%s): %s\n" %(scriptfile,e))
return sys.exit(1)
self.actionLocals = localSymbols self.actionLocals = localSymbols
self.actionGlobals = globalSymbols self.actionGlobals = globalSymbols
def pkgSrcDir(self): def pkgSrcDir(self):
"""Returns the real path of WorkDir for an unpacked archive.""" """Returns the real path of WorkDir for an unpacked archive."""
join = os.path.join
try: try:
srcdir = self.actionGlobals['WorkDir'] srcdir = self.actionGlobals['WorkDir']
except KeyError: except KeyError:
srcdir = self.spec.source.name + "-" + self.spec.source.version srcdir = self.spec.source.name + "-" + self.spec.source.version
path = join(self.ctx.pkg_work_dir(), srcdir) path = os.path.join(self.ctx.pkg_work_dir(), srcdir)
if not os.path.exists(path): if not os.path.exists(path):
ui.error ("No such file or directory: %s\n" % e) ui.error ("No such file or directory: %s\n" % e)
sys.exit(1) sys.exit(1)