From: W. Trevor King Date: Fri, 30 Apr 2010 10:21:32 +0000 (-0400) Subject: Pulled subdirs() functionality into it's own fn in site_init.py. X-Git-Tag: v1.0~392 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4fac8fa10365351e28507465a67a203e2ce6ff8e;p=thesis.git Pulled subdirs() functionality into it's own fn in site_init.py. --- diff --git a/tex/site_cons/site_init.py b/tex/site_cons/site_init.py index 6e72e42..d72a79d 100644 --- a/tex/site_cons/site_init.py +++ b/tex/site_cons/site_init.py @@ -1,14 +1,18 @@ import os.path import SCons.Node.FS + +def subdirs(env, *args, **kwargs): + for subdir in env.fs.Glob(env.subst(args[0]), *args[1:], **kwargs): + if isinstance(subdir, SCons.Node.FS.Dir): + yield subdir + def include_child_SConscripts(env, SConscript): """Get all the nested SConscripts in that may alter and pass back the environment. They may also add thesis subdependencies to that environment. """ - for subdir in env.Glob('*'): - if not isinstance(subdir, SCons.Node.FS.Dir): - continue # subdir isn't a directory + for subdir in subdirs(env, '*'): var_sconscript_path = os.path.join(subdir.abspath, 'SConscript') src_sconscript_path = os.path.join(subdir.srcnode().abspath, @@ -38,14 +42,10 @@ def check_exec(context, executible): return result def _recursive_glob_dir(env, *args, **kwargs): + assert len(args) > 0 glob_results = env.fs.Glob(env.subst(args[0]), *args[1:], **kwargs) - assert 'pattern' not in kwargs, kwargs # or we'd need subdir_kwargs - subdirs = [] - for subdir in env.fs.Glob(env.subst('*'), *args[1:], **kwargs): - if not isinstance(subdir, SCons.Node.FS.Dir): - continue # subdir isn't a directory - subdirs.append(subdir) - return (subdirs, glob_results) + sds = list(subdirs(env, ['*']+args[1:], **kwargs)) + return (sds, glob_results) def recursive_glob(env, *args, **kwargs): dir_stack = [kwargs.pop('cwd', None)]