for x in make_conf_paths:
mygcfg = getconfig(x,
tolerant=tolerant, allow_sourcing=True,
- expand=make_conf)
+ expand=make_conf, recursive=True)
if mygcfg is not None:
make_conf.update(mygcfg)
make_conf_count += 1
for x in make_conf_paths:
mygcfg.update(getconfig(x,
tolerant=tolerant, allow_sourcing=True,
- expand=expand_map) or {})
+ expand=expand_map, recursive=True) or {})
# Don't allow the user to override certain variables in make.conf
profile_only_variables = self.configdict["defaults"].get(
atoms.append(pkg_orig)
return atoms
+def _recursive_basename_filter(f):
+ return not f.startswith(".") and not f.endswith("~")
+
def grablines(myfilename, recursive=0, remember_source_file=False):
mylines=[]
if recursive and os.path.isdir(myfilename):
raise
dirlist.sort()
for f in dirlist:
- if not f.startswith(".") and not f.endswith("~"):
+ if _recursive_basename_filter(f):
mylines.extend(grablines(
os.path.join(myfilename, f), recursive, remember_source_file))
else:
_invalid_var_name_re = re.compile(r'^\d|\W')
-def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
+def getconfig(mycfg, tolerant=False, allow_sourcing=False, expand=True,
+ recursive=False):
+
if isinstance(expand, dict):
# Some existing variable definitions have been
# passed in, for use in substitutions.
else:
expand_map = {}
mykeys = {}
+
+ if recursive and os.path.isdir(mycfg):
+ # Use source commands so that syntax error messages
+ # can display real file names and line numbers.
+ recursive_files = []
+ for parent, dirs, files in os.walk(mycfg):
+ try:
+ parent = _unicode_decode(parent,
+ encoding=_encodings['fs'], errors='strict')
+ except UnicodeDecodeError:
+ continue
+ for fname_enc in dirs[:]:
+ try:
+ fname = _unicode_decode(fname_enc,
+ encoding=_encodings['fs'], errors='strict')
+ except UnicodeDecodeError:
+ dirs.remove(fname_enc)
+ continue
+ if fname in VCS_DIRS or not _recursive_basename_filter(fname):
+ dirs.remove(fname_enc)
+ for fname in files:
+ try:
+ fname = _unicode_decode(fname,
+ encoding=_encodings['fs'], errors='strict')
+ except UnicodeDecodeError:
+ pass
+ else:
+ if _recursive_basename_filter(fname):
+ fname = os.path.join(parent, fname)
+ if os.path.isfile(fname):
+ recursive_files.append(fname)
+ recursive_files.sort()
+ if not expand:
+ expand_map = False
+ for fname in recursive_files:
+ mykeys.update(getconfig(fname, tolerant=tolerant,
+ allow_sourcing=allow_sourcing, expand=expand_map,
+ recursive=False) or {})
+ return mykeys
+
f = None
try:
# NOTE: shlex doesn't support unicode objects with Python 2