(filenames, dirs=None)
| 283 | return meta, vars, sections, requires |
| 284 | |
| 285 | def _read_config_imp(filenames, dirs=None): |
| 286 | def _read_config(f): |
| 287 | meta, vars, sections, reqs = parse_config(f, dirs) |
| 288 | # recursively add sections and variables of required libraries |
| 289 | for rname, rvalue in reqs.items(): |
| 290 | nmeta, nvars, nsections, nreqs = _read_config(pkg_to_filename(rvalue)) |
| 291 | |
| 292 | # Update var dict for variables not in 'top' config file |
| 293 | for k, v in nvars.items(): |
| 294 | if not k in vars: |
| 295 | vars[k] = v |
| 296 | |
| 297 | # Update sec dict |
| 298 | for oname, ovalue in nsections[rname].items(): |
| 299 | if ovalue: |
| 300 | sections[rname][oname] += ' %s' % ovalue |
| 301 | |
| 302 | return meta, vars, sections, reqs |
| 303 | |
| 304 | meta, vars, sections, reqs = _read_config(filenames) |
| 305 | |
| 306 | # FIXME: document this. If pkgname is defined in the variables section, and |
| 307 | # there is no pkgdir variable defined, pkgdir is automatically defined to |
| 308 | # the path of pkgname. This requires the package to be imported to work |
| 309 | if not 'pkgdir' in vars and "pkgname" in vars: |
| 310 | pkgname = vars["pkgname"] |
| 311 | if not pkgname in sys.modules: |
| 312 | raise ValueError("You should import %s to get information on %s" % |
| 313 | (pkgname, meta["name"])) |
| 314 | |
| 315 | mod = sys.modules[pkgname] |
| 316 | vars["pkgdir"] = _escape_backslash(os.path.dirname(mod.__file__)) |
| 317 | |
| 318 | return LibraryInfo(name=meta["name"], description=meta["description"], |
| 319 | version=meta["version"], sections=sections, vars=VariableSet(vars)) |
| 320 | |
| 321 | # Trivial cache to cache LibraryInfo instances creation. To be really |
| 322 | # efficient, the cache should be handled in read_config, since a same file can |
no test coverage detected