diff options
author | Tim Harder <radhermit@gmail.com> | 2015-02-13 20:45:20 -0800 |
---|---|---|
committer | Tim Harder <radhermit@gmail.com> | 2015-02-13 20:45:20 -0800 |
commit | b65a228489a11a6a23e0866e1c6d64099f91f5e1 (patch) | |
tree | 6f623d315ba6d490bdf5465fdba0396cde3c2df2 | |
parent | use partial() from functools instead of snakeoil.currying (diff) | |
download | pkgcore-b65a228489a11a6a23e0866e1c6d64099f91f5e1.tar.gz pkgcore-b65a228489a11a6a23e0866e1c6d64099f91f5e1.tar.bz2 pkgcore-b65a228489a11a6a23e0866e1c6d64099f91f5e1.zip |
more functools.partial import updates
-rw-r--r-- | pkgcore/config/basics.py | 10 | ||||
-rw-r--r-- | pkgcore/ebuild/eapi.py | 2 | ||||
-rw-r--r-- | pkgcore/ebuild/portageq.py | 7 | ||||
-rw-r--r-- | pkgcore/ebuild/profiles.py | 14 | ||||
-rw-r--r-- | pkgcore/merge/engine.py | 30 | ||||
-rw-r--r-- | pkgcore/operations/__init__.py | 9 | ||||
-rw-r--r-- | pkgcore/scripts/pconfig.py | 5 | ||||
-rw-r--r-- | pkgcore/scripts/pplugincache.py | 6 | ||||
-rw-r--r-- | pkgcore/util/commandline.py | 16 |
9 files changed, 56 insertions, 43 deletions
diff --git a/pkgcore/config/basics.py b/pkgcore/config/basics.py index 5139422c..281e75d7 100644 --- a/pkgcore/config/basics.py +++ b/pkgcore/config/basics.py @@ -16,7 +16,9 @@ __all__ = ( "str_to_str", "str_to_bool", "str_to_int", "parse_config_file", ) -from snakeoil import compatibility, currying +from functools import partial + +from snakeoil import compatibility from snakeoil.demandload import demandload from pkgcore.config import errors, configurable @@ -556,11 +558,11 @@ def convert_hybrid(central, value, arg_type): # "Invalid name" (pylint thinks these are module-level constants) # pylint: disable-msg=C0103 -HardCodedConfigSection = currying.partial( +HardCodedConfigSection = partial( FakeIncrementalDictConfigSection, convert_asis) -ConfigSectionFromStringDict = currying.partial( +ConfigSectionFromStringDict = partial( FakeIncrementalDictConfigSection, convert_string) -AutoConfigSection = currying.partial( +AutoConfigSection = partial( FakeIncrementalDictConfigSection, convert_hybrid) diff --git a/pkgcore/ebuild/eapi.py b/pkgcore/ebuild/eapi.py index 21ccffbc..12b373bc 100644 --- a/pkgcore/ebuild/eapi.py +++ b/pkgcore/ebuild/eapi.py @@ -5,7 +5,7 @@ from snakeoil import mappings, weakrefs, klass from snakeoil.demandload import demandload demandload( - "snakeoil.currying:partial", + "functools:partial", "pkgcore.ebuild:atom", "pkgcore.log:logger", ) diff --git a/pkgcore/ebuild/portageq.py b/pkgcore/ebuild/portageq.py index 136eb4e9..d72af339 100644 --- a/pkgcore/ebuild/portageq.py +++ b/pkgcore/ebuild/portageq.py @@ -6,7 +6,8 @@ from snakeoil.demandload import demandload from pkgcore.util import commandline demandload( - 'snakeoil:osutils,currying', + 'functools:partial', + 'snakeoil:osutils', "pkgcore.ebuild:atom,conditionals,eapi", "pkgcore.restrictions.boolean:AndRestriction", "pkgcore.util:packages", @@ -39,9 +40,7 @@ def default_portageq_args(parser): def make_atom(value): - return commandline.DelayedValue( - currying.partial(_render_atom, value), - 100) + return commandline.DelayedValue(partial(_render_atom, value), 100) def _render_atom(value, namespace, attr): a = namespace.atom_kls(value) diff --git a/pkgcore/ebuild/profiles.py b/pkgcore/ebuild/profiles.py index 0400075e..7ed335f7 100644 --- a/pkgcore/ebuild/profiles.py +++ b/pkgcore/ebuild/profiles.py @@ -7,10 +7,11 @@ __all__ = ( ) import errno +from functools import partial from itertools import chain import os -from snakeoil import caching, compatibility, currying, klass, sequences +from snakeoil import caching, compatibility, klass, sequences from snakeoil.bash import iter_read_bash, read_bash_dict from snakeoil.containers import InvertedContains from snakeoil.demandload import demandload @@ -66,7 +67,7 @@ def load_property(filename, handler=iter_read_bash, fallback=(), """ def f(func): f2 = klass.jit_attr_named('_%s' % (func.__name__,)) - return f2(currying.partial( + return f2(partial( _load_and_invoke, func, filename, handler, fallback, read_func, allow_recurse, eapi_optional)) return f @@ -120,7 +121,7 @@ def _load_and_invoke(func, filename, handler, fallback, read_func, compatibility.raise_from(ProfileError(profile_path, filename, e)) -_make_incrementals_dict = currying.partial(IncrementalsDict, const.incrementals) +_make_incrementals_dict = partial(IncrementalsDict, const.incrementals) def _open_utf8(path, *args): try: @@ -567,7 +568,7 @@ class ProfileStack(object): @klass.jit_attr def make_virtuals_repo(self): - return currying.partial(AliasedVirtuals, self.virtuals) + return partial(AliasedVirtuals, self.virtuals) @klass.jit_attr def provides_repo(self): @@ -576,8 +577,9 @@ class ProfileStack(object): d.setdefault(pkg.category, {}).setdefault(pkg.package, []).append(pkg.fullver) intermediate_parent = PkgProvidedParent() - obj = SimpleTree(d, pkg_klass=currying.partial(PkgProvided, - intermediate_parent), livefs=True, frozen=True, repo_id='provided') + obj = SimpleTree( + d, pkg_klass=partial(PkgProvided, intermediate_parent), + livefs=True, frozen=True, repo_id='provided') intermediate_parent._parent_repo = obj if not d: diff --git a/pkgcore/merge/engine.py b/pkgcore/merge/engine.py index 5965e606..4dd84c5c 100644 --- a/pkgcore/merge/engine.py +++ b/pkgcore/merge/engine.py @@ -13,6 +13,7 @@ __all__ = ("alias_cset", "map_new_cset_livefs", "MergeEngine") # post merge triggers # ordering? +from functools import partial import operator from pkgcore.fs import contents, livefs @@ -21,7 +22,8 @@ from pkgcore.merge.const import REPLACE_MODE, INSTALL_MODE, UNINSTALL_MODE from pkgcore.operations import observer as observer_mod from pkgcore.plugin import get_plugins -from snakeoil import compatibility, currying, data_source +from snakeoil import compatibility, data_source +from snakeoil.currying import post_curry from snakeoil.demandload import demandload from snakeoil.mappings import LazyValDict, ImmutableDict, StackedDict from snakeoil.osutils import normpath @@ -62,13 +64,13 @@ class MergeEngine(object): install_csets = { "install_existing": "get_install_livefs_intersect", "resolved_install": map_new_cset_livefs, - 'new_cset': currying.partial(alias_cset, 'raw_new_cset'), - "install": currying.partial(alias_cset, 'new_cset'), - "replace": currying.partial(alias_cset, 'new_cset'), + 'new_cset': partial(alias_cset, 'raw_new_cset'), + "install": partial(alias_cset, 'new_cset'), + "replace": partial(alias_cset, 'new_cset'), } uninstall_csets = { - "uninstall_existing": currying.partial(alias_cset, "uninstall"), - "uninstall": currying.partial(alias_cset, "old_cset"), + "uninstall_existing": partial(alias_cset, "uninstall"), + "uninstall": partial(alias_cset, "old_cset"), "old_cset": "get_uninstall_livefs_intersect", } replace_csets = dict(install_csets) @@ -138,7 +140,7 @@ class MergeEngine(object): self.regenerate_csets() for x in hooks: - setattr(self, x, currying.partial(self.execute_hook, x)) + setattr(self, x, partial(self.execute_hook, x)) @classmethod def install(cls, tempdir, pkg, offset=None, observer=None, @@ -161,13 +163,13 @@ class MergeEngine(object): csets = dict(cls.install_csets) if "raw_new_cset" not in csets: - csets["raw_new_cset"] = currying.post_curry(cls.get_pkg_contents, pkg) + csets["raw_new_cset"] = post_curry(cls.get_pkg_contents, pkg) o = cls(INSTALL_MODE, tempdir, hooks, csets, cls.install_csets_preserve, observer, offset=offset, disable_plugins=disable_plugins) if o.offset != '/': # wrap the results of new_cset to pass through an offset generator - o.cset_sources["raw_new_cset"] = currying.post_curry( + o.cset_sources["raw_new_cset"] = post_curry( o.generate_offset_cset, o.cset_sources["raw_new_cset"]) o.new = pkg @@ -194,13 +196,13 @@ class MergeEngine(object): csets = dict(cls.uninstall_csets) if "raw_old_cset" not in csets: - csets["raw_old_cset"] = currying.post_curry(cls.get_pkg_contents, pkg) + csets["raw_old_cset"] = post_curry(cls.get_pkg_contents, pkg) o = cls(UNINSTALL_MODE, tempdir, hooks, csets, cls.uninstall_csets_preserve, observer, offset=offset, disable_plugins=disable_plugins) if o.offset != '/': # wrap the results of new_cset to pass through an offset generator - o.cset_sources["old_cset"] = currying.post_curry( + o.cset_sources["old_cset"] = post_curry( o.generate_offset_cset, o.cset_sources["old_cset"]) o.old = pkg @@ -229,8 +231,8 @@ class MergeEngine(object): csets = dict(cls.replace_csets) - csets.setdefault('raw_old_cset', currying.post_curry(cls.get_pkg_contents, old)) - csets.setdefault('raw_new_cset', currying.post_curry(cls.get_pkg_contents, new)) + csets.setdefault('raw_old_cset', post_curry(cls.get_pkg_contents, old)) + csets.setdefault('raw_new_cset', post_curry(cls.get_pkg_contents, new)) o = cls(REPLACE_MODE, tempdir, hooks, csets, cls.replace_csets_preserve, observer, offset=offset, disable_plugins=disable_plugins) @@ -239,7 +241,7 @@ class MergeEngine(object): for k in ("raw_old_cset", "raw_new_cset"): # wrap the results of new_cset to pass through an # offset generator - o.cset_sources[k] = currying.post_curry( + o.cset_sources[k] = post_curry( o.generate_offset_cset, o.cset_sources[k]) o.old = old diff --git a/pkgcore/operations/__init__.py b/pkgcore/operations/__init__.py index 467eb869..3bc7d480 100644 --- a/pkgcore/operations/__init__.py +++ b/pkgcore/operations/__init__.py @@ -13,7 +13,10 @@ Basically it's a crappy form of zope interfaces; converting to zope.interfaces may occur down the line if dependencies can be kept as minimal as possible. """ -from snakeoil import klass, currying, compatibility +from functools import partial + +from snakeoil import klass, compatibility +from snakeoil.currying import pretty_docs from pkgcore.operations import observer as _observer @@ -71,9 +74,9 @@ class base(object): compatibility.raise_from(exc_class(name)) def _wrap_exception(self, functor, name): - f = currying.partial( + f = partial( self._recast_exception_decorator, self.__casting_exception__, name, functor) - return currying.pretty_docs(f) + return pretty_docs(f) def _setup_api(self): recast_exc = self.__casting_exception__ diff --git a/pkgcore/scripts/pconfig.py b/pkgcore/scripts/pconfig.py index 781cafed..03dfbcdc 100644 --- a/pkgcore/scripts/pconfig.py +++ b/pkgcore/scripts/pconfig.py @@ -12,7 +12,8 @@ __all__ = ( "dump_uncollapsed", "dump_uncollapsed_main" ) -from snakeoil import currying +from functools import partial + from snakeoil.demandload import demandload from pkgcore.config import errors, basics @@ -131,7 +132,7 @@ describe_class = subparsers.add_parser( description="describe the arguments a class needs, how to use it in a config") describe_class.add_argument( "target_class", action='store', - type=currying.partial(commandline.python_namespace_type, attribute=True), + type=partial(commandline.python_namespace_type, attribute=True), help="The class to inspect and output details about") @describe_class.bind_main_func def describe_class_main(options, out, err): diff --git a/pkgcore/scripts/pplugincache.py b/pkgcore/scripts/pplugincache.py index f3441522..c933eadf 100644 --- a/pkgcore/scripts/pplugincache.py +++ b/pkgcore/scripts/pplugincache.py @@ -6,7 +6,9 @@ __all__ = ("argparser", "main") -from snakeoil import lists, currying +from functools import partial + +from snakeoil import lists from pkgcore import plugin, plugins from pkgcore.util import commandline @@ -16,7 +18,7 @@ argparser = commandline.mk_argparser( description=__doc__.split('\n', 1)[0]) argparser.add_argument( "packages", nargs="*", action='store', - type=currying.partial(commandline.python_namespace_type, module=True), + type=partial(commandline.python_namespace_type, module=True), default=[plugins], help="python namespace(s) to regenerate plugins for. If none are " "specified, pkgcore.plugins is updated") diff --git a/pkgcore/util/commandline.py b/pkgcore/util/commandline.py index fe0ed93d..74e52490 100644 --- a/pkgcore/util/commandline.py +++ b/pkgcore/util/commandline.py @@ -20,13 +20,14 @@ __all__ = ( ) import argparse +from functools import partial from importlib import import_module import logging import optparse import os.path import sys -from snakeoil import compatibility, formatters, currying, modules +from snakeoil import compatibility, formatters, modules from snakeoil.demandload import demandload from pkgcore.config import load_config, errors @@ -140,7 +141,7 @@ class Delayed(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): setattr(namespace, self.dest, DelayedParse( - currying.partial(self.target, parser, namespace, values, option_string), + partial(self.target, parser, namespace, values, option_string), self.priority)) @@ -174,8 +175,9 @@ class StoreConfigObject(argparse._StoreAction): raise ValueError("config_type must specified, and be a string") if kwargs.pop("get_default", False): - kwargs["default"] = DelayedValue(currying.partial(self.store_default, - self.config_type, option_string=kwargs.get('option_strings', [None])[0]), + kwargs["default"] = DelayedValue( + partial(self.store_default, self.config_type, + option_string=kwargs.get('option_strings', [None])[0]), self.priority) self.store_name = kwargs.pop("store_name", False) @@ -214,7 +216,7 @@ class StoreConfigObject(argparse._StoreAction): def __call__(self, parser, namespace, values, option_string=None): setattr(namespace, self.dest, DelayedParse( - currying.partial(self._real_call, parser, namespace, values, option_string), + partial(self._real_call, parser, namespace, values, option_string), self.priority)) def _get_sections(self, config, namespace): @@ -270,7 +272,7 @@ class StoreConfigObject(argparse._StoreAction): if priority is None: priority = cls.default_priority return DelayedValue( - currying.partial(cls._lazy_load_object, config_type, key), + partial(cls._lazy_load_object, config_type, key), priority) @staticmethod @@ -385,7 +387,7 @@ class DelayedDefault(DelayedValue): def wipe(cls, attrs, priority): if isinstance(attrs, basestring): attrs = (attrs,) - return cls(currying.partial(cls._wipe, attrs), priority) + return cls(partial(cls._wipe, attrs), priority) @staticmethod def _wipe(attrs, namespace, triggering_attr): |