| |
@@ -17,6 +17,7 @@
|
| |
# along with fedora-easy-karma. If not, see <http://www.gnu.org/licenses/>.
|
| |
|
| |
# standard python modules
|
| |
+ import argparse
|
| |
import datetime
|
| |
import fnmatch
|
| |
import itertools
|
| |
@@ -31,7 +32,6 @@
|
| |
import colored
|
| |
import dnf
|
| |
import munch
|
| |
- from optparse import OptionParser
|
| |
import requests
|
| |
from textwrap import wrap
|
| |
|
| |
@@ -274,38 +274,30 @@
|
| |
|
| |
return ("\n%s" % subsequent_indent).join(output)
|
| |
|
| |
- USAGE = """usage: %prog [options] [pattern, ..]
|
| |
-
|
| |
- You will be asked for every package installed from updates-testing to provide
|
| |
- feedback using karma points. If patterns are provided, you will be only
|
| |
- prompted for updates related to packages or builds that match any of the
|
| |
- patterns. Possible wildcards are *, ?, [seq] and [!seq] as explained at
|
| |
- http://docs.python.org/library/fnmatch.html
|
| |
+ USAGE = """
|
| |
+ You will be asked for every package installed from updates-testing to
|
| |
+ provide feedback using karma points. If patterns are provided, you will be
|
| |
+ only prompted for updates related to packages or builds that match any of
|
| |
+ the patterns. Possible wildcards are *, ?, [seq] and [!seq]. More is about
|
| |
+ the wildcards is explained at <http://docs.python.org/library/fnmatch.html>.
|
| |
|
| |
Possible values in the karma prompt:
|
| |
-1,0 or 1: Assign the respective karma value to the update
|
| |
- i: Ignore the update in the future
|
| |
- Other inputs will skip the update.
|
| |
-
|
| |
- After assigning karma to the update, a comment needs to be provided, otherwise
|
| |
- the update will be skipped.
|
| |
+ i: Ignore the update in the future
|
| |
+ Other inputs will skip the update.
|
| |
|
| |
Note:
|
| |
- <CTRL>-<D> on an empty prompt exits the program.
|
| |
- If you use a default comment, '<CTRL>-<X> <backspace>' can be used to delete
|
| |
- the default comment to easily enter a custom one.
|
| |
+ * <CTRL>-<D> exits the program when used on empty prompt.
|
| |
+ * <CTRL>-<X> + <backspace> deletes the default comment to enter a new one.
|
| |
|
| |
For further documentation, please visit:
|
| |
https://fedoraproject.org/wiki/Fedora_Easy_Karma
|
| |
|
| |
- Copyright 2010-2017 Till Maas and others
|
| |
- fedora-easy-karma is distributed under the terms of the GNU General Public
|
| |
- License
|
| |
- The source is available at:
|
| |
- https://pagure.io/fedora-easy-karma
|
| |
+ Copyright 2010-2025 Till Maas and others. Fedora-easy-karma is distributed under
|
| |
+ the terms of the GNU General Public License. The source is available at
|
| |
+ <https://pagure.io/fedora-easy-karma>.
|
| |
"""
|
| |
|
| |
-
|
| |
class PkgHelper(object):
|
| |
def __init__(self):
|
| |
self.my = dnf.Base()
|
| |
@@ -332,175 +324,152 @@
|
| |
width=80,
|
| |
extra_newline=False)
|
| |
|
| |
- parser = OptionParser(usage=usage)
|
| |
- parser.add_option("",
|
| |
- "--bodhi-cached", dest="bodhi_cached",
|
| |
+ parser = argparse.ArgumentParser(description=usage, formatter_class=argparse.RawDescriptionHelpFormatter)
|
| |
+ parser.add_argument("--bodhi-cached", dest="bodhi_cached",
|
| |
help="Use cached bodhi query",
|
| |
action="store_true",
|
| |
default=False)
|
| |
- parser.add_option("",
|
| |
- "--bodhi-update-cache",
|
| |
+ parser.add_argument("--bodhi-update-cache",
|
| |
dest="bodhi_update_cache",
|
| |
help="Update bodhi query cache",
|
| |
action="store_true",
|
| |
default=False)
|
| |
- parser.add_option("",
|
| |
- "--critpath-only",
|
| |
+ parser.add_argument("--critpath-only",
|
| |
dest="critpath_only",
|
| |
help="Only consider unapproved critpath updates",
|
| |
action="store_true",
|
| |
default=False)
|
| |
- parser.add_option("",
|
| |
- "--datadir",
|
| |
+ parser.add_argument("--datadir",
|
| |
dest="datadir",
|
| |
help="Directory to store cache or ignore data, "
|
| |
- "default: %default",
|
| |
+ "default: %(default)s",
|
| |
default=f"{config_dir}/fedora-easy-karma")
|
| |
- parser.add_option("",
|
| |
- "--debug",
|
| |
+ parser.add_argument("--debug",
|
| |
dest="debug",
|
| |
help="Enable debug output",
|
| |
action="store_true",
|
| |
default=False)
|
| |
- parser.add_option("",
|
| |
- "--default-comment",
|
| |
+ parser.add_argument("--default-comment",
|
| |
dest="default_comment",
|
| |
- help="Default comment to use, default: %default",
|
| |
+ help="Default comment to use, default: %(default)s",
|
| |
default="",
|
| |
metavar="COMMENT")
|
| |
- parser.add_option("",
|
| |
- "--default-karma",
|
| |
+ parser.add_argument("--default-karma",
|
| |
dest="default_karma",
|
| |
- help="Default karma to use, default: %default",
|
| |
+ help="Default karma to use, default: %(default)s",
|
| |
default="",
|
| |
metavar="KARMA")
|
| |
- parser.add_option("",
|
| |
- "--no-color",
|
| |
+ parser.add_argument("--no-color",
|
| |
dest="no_color",
|
| |
help="Do not colorize output",
|
| |
action="store_true",
|
| |
default=False)
|
| |
- parser.add_option("",
|
| |
- "--no-ignore-own",
|
| |
+ parser.add_argument("--no-ignore-own",
|
| |
dest="ignore_own",
|
| |
help="Do not ignore own updates.",
|
| |
action="store_false",
|
| |
default=True)
|
| |
- parser.add_option("",
|
| |
- "--include-commented",
|
| |
+ parser.add_argument("--include-commented",
|
| |
dest="include_commented",
|
| |
help="Also ask for more comments on updates that "
|
| |
"already got a comment from you, this is "
|
| |
"enabled if patterns are provided",
|
| |
action="store_true",
|
| |
default=False)
|
| |
- parser.add_option("",
|
| |
- "--include-ignored",
|
| |
+ parser.add_argument("--include-ignored",
|
| |
dest="include_ignored",
|
| |
help="Also ask for comments on updates that have "
|
| |
"been ignored previously.",
|
| |
action="store_true",
|
| |
default=False)
|
| |
- parser.add_option("",
|
| |
- "--installed-max-days",
|
| |
+ parser.add_argument("--installed-max-days",
|
| |
dest="installed_max_days",
|
| |
help="Only check packages installed within the last "
|
| |
- "XX days, default: %default",
|
| |
+ "XX days, default: %(default)d",
|
| |
metavar="DAYS",
|
| |
default=28,
|
| |
- type="int")
|
| |
- parser.add_option("",
|
| |
- "--installed-min-days",
|
| |
+ type=int)
|
| |
+ parser.add_argument("--installed-min-days",
|
| |
dest="installed_min_days",
|
| |
help="Only check packages installed for at least "
|
| |
- "XX days, default: %default",
|
| |
+ "XX days, default: %(default)d",
|
| |
metavar="DAYS",
|
| |
default=0,
|
| |
- type="int")
|
| |
- parser.add_option("",
|
| |
- "--ipdb",
|
| |
+ type=int)
|
| |
+ parser.add_argument("--ipdb",
|
| |
dest="ipdb",
|
| |
help="Launch ipbd for debugging",
|
| |
action="store_true",
|
| |
default=False)
|
| |
- parser.add_option("",
|
| |
- "--list-rpms-only",
|
| |
+ parser.add_argument("--list-rpms-only",
|
| |
dest="list_rpms_only",
|
| |
help="Only list affected rpms",
|
| |
action="store_true",
|
| |
default=False)
|
| |
- parser.add_option("",
|
| |
- "--pages",
|
| |
+ parser.add_argument("--pages",
|
| |
dest="pages",
|
| |
help="Clear terminal before each new presented update",
|
| |
action="store_true",
|
| |
default=False)
|
| |
- parser.add_option("",
|
| |
- "--product",
|
| |
+ parser.add_argument("--product",
|
| |
dest="product",
|
| |
help="product to query Bodhi for, 'F' for Fedora, "
|
| |
- "'EL-' for EPEL, default: %default",
|
| |
+ "'EL-' for EPEL, default: %(default)s",
|
| |
default="F")
|
| |
- parser.add_option("",
|
| |
- "--releasever",
|
| |
+ parser.add_argument("--releasever",
|
| |
dest="releasever",
|
| |
help="releasever to query Bodhi for, "
|
| |
"default: releasever from dnf",
|
| |
default=None)
|
| |
- parser.add_option("",
|
| |
- "--retries",
|
| |
+ parser.add_argument("--retries",
|
| |
dest="retries",
|
| |
help="Number if retries when submitting a comment "
|
| |
- "in case of an error, default: %default",
|
| |
+ "in case of an error, default: %(default)d",
|
| |
default=3,
|
| |
- type="int")
|
| |
- parser.add_option("",
|
| |
- "--skip-bodhi-comments",
|
| |
+ type=int)
|
| |
+ parser.add_argument("--skip-bodhi-comments",
|
| |
dest="skip_bodhi_comments",
|
| |
help="Do not show comments created by bodhi",
|
| |
action="store_true",
|
| |
default=False)
|
| |
- parser.add_option("",
|
| |
- "--wrap-bugs",
|
| |
+ parser.add_argument("--wrap-bugs",
|
| |
dest="wrap_bugs",
|
| |
help="Apply line-wrapping to bugs",
|
| |
action="store_true",
|
| |
default=False)
|
| |
- parser.add_option("",
|
| |
- "--wrap-rpms",
|
| |
+ parser.add_argument("--wrap-rpms",
|
| |
dest="wrap_rpms",
|
| |
help="Apply line-wrapping to list of installed rpms",
|
| |
action="store_true",
|
| |
default=False)
|
| |
- parser.add_option("",
|
| |
- "--wrap-width",
|
| |
+ parser.add_argument("--wrap-width",
|
| |
dest="wrap_width",
|
| |
help="Width to use for line wrapping of updates, "
|
| |
- "default: %default",
|
| |
+ "default: %(default)d",
|
| |
default=80,
|
| |
- type="int")
|
| |
- parser.add_option("",
|
| |
- "--bodhi-request-limit",
|
| |
+ type=int)
|
| |
+ parser.add_argument("--bodhi-request-limit",
|
| |
dest="bodhi_request_limit",
|
| |
help="Maximum number of updates to request at "
|
| |
- "once from Bodhi, default: %default",
|
| |
+ "once from Bodhi, default: %(default)d",
|
| |
default=25,
|
| |
- type="int")
|
| |
- parser.add_option("",
|
| |
- "--oraculum-endpoint",
|
| |
+ type=int)
|
| |
+ parser.add_argument("--oraculum-endpoint",
|
| |
dest="oraculum_endpoint",
|
| |
help="Specify URL for oraculum instance",
|
| |
default="https://packager-dashboard.fedoraproject.org/api/v1/libkarma/")
|
| |
- parser.add_option("",
|
| |
- "--no-cache",
|
| |
+ parser.add_argument("--no-cache",
|
| |
dest="oraculum_disabled",
|
| |
help="Bypass oraculum and force fetch from bodhi",
|
| |
action="store_true",
|
| |
default=False)
|
| |
+ parser.add_argument("pattern",
|
| |
+ help="Show only updates matching one or more package name patterns",
|
| |
+ nargs="*")
|
| |
|
| |
- (self.options, args) = parser.parse_args()
|
| |
+ self.options = parser.parse_args()
|
| |
|
| |
- if args:
|
| |
+ if self.options.pattern:
|
| |
self.options.include_commented = True
|
| |
|
| |
if self.options.debug:
|
| |
@@ -689,13 +658,13 @@
|
| |
b in installed_testing_builds])
|
| |
)
|
| |
|
| |
- if args:
|
| |
+ if self.options.pattern:
|
| |
installed_pkgs_names = ["%(name)s" % pkg for pkg in
|
| |
installed_pkgs]
|
| |
# remove version and release
|
| |
affected_builds_names = ["-".join(b.split("-")[:-2]) for b
|
| |
in affected_builds]
|
| |
- if not self.match_any(args, [installed_pkgs_names,
|
| |
+ if not self.match_any(self.options.pattern, [installed_pkgs_names,
|
| |
affected_builds_names]):
|
| |
continue
|
| |
installed_rpms = [
|
| |
The previous version used the optparse module that has been deprecated
for some time already and Pylint would constantly warn about it.
The PR replaces optparse with argparse while retaining the logic
to add searching patterns on the CLI, similarly to other CLI tools,
such as ls, etc.
Fixes: https://pagure.io/fedora-easy-karma/issue/41