* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/util/, src/pkgcore/plugins/, src/pkgcore/scripts/, src/pkgcore/sync/
@ 2022-12-18 19:01 Arthur Zamarin
0 siblings, 0 replies; only message in thread
From: Arthur Zamarin @ 2022-12-18 19:01 UTC (permalink / raw
To: gentoo-commits
commit: 9b78522bac4ee386959caa59b3ce8d580fe497a6
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 2 08:47:37 2022 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun Dec 18 18:58:27 2022 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=9b78522b
remove pkgcore_formatters plugins
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcore/plugins/pkgcore_formatters.py | 19 -------------------
src/pkgcore/scripts/pmerge.py | 19 ++++++++++++++++++-
src/pkgcore/sync/base.py | 19 +++++++++----------
src/pkgcore/util/commandline.py | 25 +++----------------------
4 files changed, 30 insertions(+), 52 deletions(-)
diff --git a/src/pkgcore/plugins/pkgcore_formatters.py b/src/pkgcore/plugins/pkgcore_formatters.py
deleted file mode 100644
index 26a5f7653..000000000
--- a/src/pkgcore/plugins/pkgcore_formatters.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from ..config import basics
-
-pkgcore_plugins = {
- 'global_config': [{
- 'basic': basics.ConfigSectionFromStringDict({
- 'class': 'pkgcore.ebuild.formatter.BasicFormatter',
- }),
- 'pkgcore': basics.ConfigSectionFromStringDict({
- 'class': 'pkgcore.ebuild.formatter.PkgcoreFormatter',
- }),
- 'portage': basics.ConfigSectionFromStringDict({
- 'class': 'pkgcore.ebuild.formatter.PortageFormatter',
- 'default': 'True',
- }),
- 'portage-verbose': basics.ConfigSectionFromStringDict({
- 'class': 'pkgcore.ebuild.formatter.PortageVerboseFormatter',
- }),
- }],
-}
diff --git a/src/pkgcore/scripts/pmerge.py b/src/pkgcore/scripts/pmerge.py
index 4d0f7dfde..ffc13cef9 100644
--- a/src/pkgcore/scripts/pmerge.py
+++ b/src/pkgcore/scripts/pmerge.py
@@ -14,6 +14,7 @@ from snakeoil.cli.exceptions import ExitException
from snakeoil.sequences import iflatten_instance, stable_unique
from snakeoil.strings import pluralism
+from ..config.basics import ConfigSectionFromStringDict
from ..ebuild import resolver, restricts
from ..ebuild.atom import atom
from ..ebuild.misc import run_sanity_checks
@@ -26,8 +27,24 @@ from ..restrictions import packages
from ..restrictions.boolean import OrRestriction
from ..util import commandline, parserestrict
+pmerge_config = ({
+ 'basic': ConfigSectionFromStringDict({
+ 'class': 'pkgcore.ebuild.formatter.BasicFormatter',
+ }),
+ 'pkgcore': ConfigSectionFromStringDict({
+ 'class': 'pkgcore.ebuild.formatter.PkgcoreFormatter',
+ }),
+ 'portage': ConfigSectionFromStringDict({
+ 'class': 'pkgcore.ebuild.formatter.PortageFormatter',
+ 'default': 'True',
+ }),
+ 'portage-verbose': ConfigSectionFromStringDict({
+ 'class': 'pkgcore.ebuild.formatter.PortageVerboseFormatter',
+ }),
+},)
+
argparser = commandline.ArgumentParser(
- domain=True, description=__doc__, script=(__file__, __name__))
+ domain=True, description=__doc__, script=(__file__, __name__), global_config=pmerge_config)
argparser.add_argument(
nargs='*', dest='targets', metavar='TARGET',
action=commandline.StoreTarget, use_sets='sets',
diff --git a/src/pkgcore/sync/base.py b/src/pkgcore/sync/base.py
index de0396a1f..a4d31d3a8 100644
--- a/src/pkgcore/sync/base.py
+++ b/src/pkgcore/sync/base.py
@@ -116,8 +116,8 @@ class Syncer:
uri[1] = f"{proto[0]}//{uri[1]}"
return pwd.getpwnam(uri[0]).pw_uid, os_data.gid, uri[1]
- except KeyError as e:
- raise MissingLocalUser(raw_uri, str(e))
+ except KeyError as exc:
+ raise MissingLocalUser(raw_uri, str(exc))
def sync(self, verbosity=None, force=False):
if self.disabled:
@@ -168,9 +168,9 @@ class ExternalSyncer(Syncer):
def require_binary(bin_name, fatal=True):
try:
return process.find_binary(bin_name)
- except process.CommandNotFound as e:
+ except process.CommandNotFound as exc:
if fatal:
- raise MissingBinary(bin_name, str(e))
+ raise MissingBinary(bin_name, str(exc))
return None
@classmethod
@@ -198,8 +198,7 @@ class ExternalSyncer(Syncer):
if len(chunks) == 1:
return uri
try:
- return "%s//%s::%s" % (
- chunks[0], pwd.getpwuid(os.stat(path).st_uid)[0], chunks[1])
+ return f"{chunks[0]}//{pwd.getpwuid(os.stat(path).st_uid)[0]}::{chunks[1]}"
except KeyError:
# invalid uid, reuse the uri
return uri
@@ -213,8 +212,8 @@ class VcsSyncer(ExternalSyncer):
except FileNotFoundError:
command = self._initial_pull() + self.opts
chdir = None
- except EnvironmentError as e:
- raise PathError(self.basedir, e.strerror) from e
+ except EnvironmentError as exc:
+ raise PathError(self.basedir, exc.strerror) from exc
else:
if not stat.S_ISDIR(st.st_mode):
raise PathError(self.basedir, "isn't a directory")
@@ -243,9 +242,9 @@ class VcsSyncer(ExternalSyncer):
typename='syncer')
def GenericSyncer(basedir, uri, **kwargs):
"""Syncer using the plugin system to find a syncer based on uri."""
- plugins = list(
+ plugins = [
(plug.supports_uri(uri), plug)
- for plug in plugin.get_plugins('syncer'))
+ for plug in plugin.get_plugins('syncer')]
plugins.sort(key=lambda x: x[0])
if not plugins or plugins[-1][0] <= 0:
raise UriError(uri, "no known syncer support")
diff --git a/src/pkgcore/util/commandline.py b/src/pkgcore/util/commandline.py
index 050685b0e..6457b3704 100644
--- a/src/pkgcore/util/commandline.py
+++ b/src/pkgcore/util/commandline.py
@@ -24,7 +24,6 @@ from snakeoil.strings import pluralism
from .. import const
from ..config import load_config
-from ..plugin import get_plugins
from ..repository import errors as repo_errors
from ..restrictions import packages, restriction
from . import parserestrict
@@ -531,8 +530,8 @@ class _ConfigArg(argparse._StoreAction):
class ArgumentParser(arghparse.ArgumentParser):
def __init__(self, suppress=False, help=True, config=True,
- domain=True, script=None, **kwds):
- super().__init__(suppress=suppress, script=script, **kwds)
+ domain=True, global_config=(), **kwds):
+ super().__init__(suppress=suppress, **kwds)
self.register('action', 'parsers', _SubParser)
if not suppress:
@@ -550,26 +549,8 @@ class ArgumentParser(arghparse.ArgumentParser):
loading the system config entirely if one exists.
""")
- if script is not None:
- try:
- _, script_module = script
- except TypeError:
- raise ValueError(
- "invalid script parameter, should be (__file__, __name__)")
- project = script_module.split('.')[0]
- else:
- project = __name__.split('.')[0]
-
- # TODO: figure out a better method for plugin registry/loading
- kwargs = {}
- try:
- plugins = import_module('.plugins', project)
- kwargs['global_config'] = get_plugins('global_config', plugins)
- except ImportError:
- # project doesn't bundle plugins
- pass
self.set_defaults(config=arghparse.DelayedValue(
- partial(store_config, **kwargs)))
+ partial(store_config, global_config=global_config)))
if domain:
_mk_domain(config_opts, help)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-12-18 19:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-18 19:01 [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/util/, src/pkgcore/plugins/, src/pkgcore/scripts/, src/pkgcore/sync/ Arthur Zamarin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox