diff options
author | Tim Harder <radhermit@gmail.com> | 2017-12-18 23:37:21 -0500 |
---|---|---|
committer | Tim Harder <radhermit@gmail.com> | 2017-12-19 00:17:24 -0500 |
commit | a4c59906aafbbf2b8e29ef28d08ee4ca754312df (patch) | |
tree | 40a6f4ab2ab2af4799624685623f66243765cf3e | |
parent | update GetDirProxy name to DirProxy (diff) | |
download | pkgcore-a4c59906aafbbf2b8e29ef28d08ee4ca754312df.tar.gz pkgcore-a4c59906aafbbf2b8e29ef28d08ee4ca754312df.tar.bz2 pkgcore-a4c59906aafbbf2b8e29ef28d08ee4ca754312df.zip |
pclean config: move debug support into the domain class
-rw-r--r-- | src/pkgcore/ebuild/domain.py | 66 | ||||
-rw-r--r-- | src/pkgcore/scripts/pclean.py | 47 |
2 files changed, 49 insertions, 64 deletions
diff --git a/src/pkgcore/ebuild/domain.py b/src/pkgcore/ebuild/domain.py index c0e0016a..c8eb83ab 100644 --- a/src/pkgcore/ebuild/domain.py +++ b/src/pkgcore/ebuild/domain.py @@ -122,20 +122,6 @@ def generate_filter(masks, unmasks, *extra): return packages.AndRestriction(disable_inst_caching=True, finalize=True, *(r + extra)) -def _read_config_file(path): - """Read all the data files under a given path.""" - try: - for fs_obj in iter_scan(path, follow_symlinks=True): - if not fs_obj.is_reg or '/.' in fs_obj.location: - continue - for lineno, line, in iter_read_bash( - fs_obj.location, allow_line_cont=True, enum_line=True): - yield line, lineno, fs_obj.location - except EnvironmentError as e: - if e.errno != errno.ENOENT: - raise_from(Failure("failed reading %r: %s" % (filename, e))) - - def load_property(filename, parsing_func=None, fallback=()): """Decorator simplifying parsing config files to generate a domain property. @@ -160,6 +146,20 @@ def load_property(filename, parsing_func=None, fallback=()): return f +def _read_config_file(path): + """Read all the data files under a given path.""" + try: + for fs_obj in iter_scan(path, follow_symlinks=True): + if not fs_obj.is_reg or '/.' in fs_obj.location: + continue + for lineno, line, in iter_read_bash( + fs_obj.location, allow_line_cont=True, enum_line=True): + yield line, lineno, fs_obj.location + except EnvironmentError as e: + if e.errno != errno.ENOENT: + raise_from(Failure("failed reading %r: %s" % (filename, e))) + + # ow ow ow ow ow ow.... # this manages a *lot* of crap. so... this is fun. # @@ -179,6 +179,9 @@ class domain(config_domain): 'PORTAGE_TMPDIR', 'DISTCC_PATH', 'DISTCC_DIR', 'CCACHE_DIR'): _types[_thing] = 'str' + # control adding debug info (line/lineno/path) to config file parsed output + _debug = False + # TODO this is missing defaults pkgcore_config_type = ConfigHint( _types, typename='domain', @@ -330,34 +333,55 @@ class domain(config_domain): @load_property("package.mask", package_masks) def pkg_masks(self, data): - return tuple(x[0] for x in data) + if self._debug: + return tuple(data) + else: + return tuple(x[0] for x in data) @load_property("package.unmask", package_masks) def pkg_unmasks(self, data): - return tuple(x[0] for x in data) + if self._debug: + return tuple(data) + else: + return tuple(x[0] for x in data) # TODO: deprecated, remove in 0.11 @load_property("package.keywords", package_keywords_splitter) def pkg_keywords(self, data): - return tuple((x[0], x[1]) for x in data) + if self._debug: + return tuple(data) + else: + return tuple((x[0], x[1]) for x in data) @load_property("package.accept_keywords", package_keywords_splitter) def pkg_accept_keywords(self, data): - return tuple((x[0], x[1]) for x in data) + if self._debug: + return tuple(data) + else: + return tuple((x[0], x[1]) for x in data) @load_property("package.license", package_keywords_splitter) def pkg_licenses(self, data): - return tuple((x[0], x[1]) for x in data) + if self._debug: + return tuple(data) + else: + return tuple((x[0], x[1]) for x in data) @load_property("package.use", package_keywords_splitter) def pkg_use(self, data): - return tuple((x[0], split_negations(x[1])) for x in data) + if self._debug: + return tuple(data) + else: + return tuple((x[0], split_negations(x[1])) for x in data) @load_property("package.env", fallback=None) def pkg_env(self, data): func = partial(package_env_splitter, self.ebuild_hook_dir) data = ifilter(None, (func(*x) for x in data)) - return tuple((x[0], x[1]) for x in data) + if self._debug: + return tuple(data) + else: + return tuple((x[0], x[1]) for x in data) @klass.jit_attr def bashrcs(self): diff --git a/src/pkgcore/scripts/pclean.py b/src/pkgcore/scripts/pclean.py index 003d167d..ab11e407 100644 --- a/src/pkgcore/scripts/pclean.py +++ b/src/pkgcore/scripts/pclean.py @@ -28,7 +28,6 @@ demandload( 'snakeoil.osutils:listdir_dirs,listdir_files,pjoin', 'snakeoil.sequences:iflatten_instance,split_negations', 'pkgcore:fetch', - 'pkgcore.ebuild:atom,domain@domain_mod', 'pkgcore.package:errors', 'pkgcore.repository.util:SimpleTree', 'pkgcore.util:parserestrict', @@ -211,44 +210,6 @@ def _setup_restrictions(namespace): namespace.restrict = boolean.AndRestriction(*namespace.restrict) -class config_domain(object): - - def __init__(self, domain): - self._domain = domain - - @domain_mod.load_property("package.mask", domain_mod.package_masks) - def pkg_masks(self, data): - return tuple(data) - - @domain_mod.load_property("package.unmask", domain_mod.package_masks) - def pkg_unmasks(self, data): - return tuple(data) - - @domain_mod.load_property("package.keywords", domain_mod.package_keywords_splitter) - def pkg_keywords(self, data): - return tuple(data) - - @domain_mod.load_property("package.accept_keywords", domain_mod.package_keywords_splitter) - def pkg_accept_keywords(self, data): - return tuple(data) - - @domain_mod.load_property("package.license", domain_mod.package_keywords_splitter) - def pkg_licenses(self, data): - return tuple(data) - - @domain_mod.load_property("package.use", domain_mod.package_keywords_splitter) - def pkg_use(self, data): - return tuple(data) - - @domain_mod.load_property("package.env", fallback=None) - def pkg_env(self, data): - func = partial(domain_mod.package_env_splitter, self.ebuild_hook_dir) - data = ifilter(None, (func(*x) for x in data)) - return tuple(data) - - __getattr__ = klass.GetAttrProxy("_domain") - - config = subparsers.add_parser( 'config', parents=(shared_opts,), description='remove config file settings') @@ -256,9 +217,7 @@ config = subparsers.add_parser( def config_main(options, out, err): installed_repos = options.domain.all_installed_repos all_repos_raw = options.domain.all_repos_raw - - # wrap actual domain in our verbose domain - domain = config_domain(options.domain) + domain = options.domain def iter_restrict(iterable): for x in iterable: @@ -274,7 +233,9 @@ def config_main(options, out, err): attrs = {} for name in domain_attrs: - # force JIT-ed attr refresh to use custom domain methods + # enable debug output (line/lineno/path data) for config data + domain._debug = True + # force JIT-ed attr refresh to provide debug data setattr(domain, '_jit_' + name, klass._singleton_kls) # filter excluded, matching restricts from the data stream attrs[name] = iter_restrict(getattr(domain, name)) |