fix _glob and template glob()

This commit is contained in:
Will Woods 2011-05-10 17:46:37 -04:00
parent b6a0b2351c
commit e77f142847

View File

@ -63,10 +63,10 @@ def findkernels(root="/", kdir="boot"):
return kernels return kernels
def _glob(glob, root="", fatal=True): def _glob(globpat, root="", fatal=True):
files_found = glob.glob(os.path.join(root, glob)) files_found = glob.glob(os.path.join(root, globpat))
if fatal and not files_found: if fatal and not files_found:
raise IOError, "nothing matching %s" % os.path.join(root, glob) raise IOError, "nothing matching %s" % os.path.join(root, globpat)
return files_found return files_found
def _exists(path, root=""): def _exists(path, root=""):
@ -95,7 +95,7 @@ class BaseBuilder(object):
logger.info(" %s: %s", key, val) logger.info(" %s: %s", key, val)
# set up functions for template # set up functions for template
tvars.setdefault('exists', lambda p: _exists(p, root=tvars['inroot'])) tvars.setdefault('exists', lambda p: _exists(p, root=tvars['inroot']))
tvars.setdefault('glob', lambda g: glob(g, root=tvars['inroot'])) tvars.setdefault('glob', lambda g: _glob(g, root=tvars['inroot']))
# parse and run the template # parse and run the template
t = LoraxTemplate(directories=[self.templatedir]) t = LoraxTemplate(directories=[self.templatedir])
template = t.parse(tfile, tvars) template = t.parse(tfile, tvars)