summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Maas <opensource@till.name>2010-03-06 17:00:35 +0100
committerTill Maas <opensource@till.name>2010-03-06 17:00:35 +0100
commita084cd2c1e9eb49d9691ada2e4e3eb65e955740f (patch)
treeca379d08df161be0ec1e59678c04dcdfdca38f19
parentb67bed1d1b1b1738f8ad072a071fd4751e5ca119 (diff)
downloadfedora-easy-karma-a084cd2c1e9eb49d9691ada2e4e3eb65e955740f.tar.gz
fedora-easy-karma-a084cd2c1e9eb49d9691ada2e4e3eb65e955740f.tar.xz
fedora-easy-karma-a084cd2c1e9eb49d9691ada2e4e3eb65e955740f.zip
add --default-karma, ignore karma in readline hist
-rwxr-xr-xfedora-easy-karma.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/fedora-easy-karma.py b/fedora-easy-karma.py
index f9b6c18..2808e3f 100755
--- a/fedora-easy-karma.py
+++ b/fedora-easy-karma.py
@@ -65,6 +65,7 @@ class FedoraEasyKarma(object):
parser.add_option("", "--bodhi-update-cache", dest="bodhi_update_cache", help="Update bodhi query cache", action="store_true", default=False)
parser.add_option("", "--debug", dest="debug", help="Enable debug output", action="store_true", default=False)
parser.add_option("", "--default-comment", dest="default_comment", help="Default comment to use, default: %default", default="")
+ parser.add_option("", "--default-karma", dest="default_karma", help="Default karma to use, default: %default", default="")
parser.add_option("", "--fas-username", dest="fas_username", help="FAS username", default=None)
parser.add_option("", "--include-commented", dest="include_commented", help="Also ask for more comments on updates that already got a comment from you", action="store_true", default=False)
parser.add_option("", "--installed-max-days", dest="installed_max_days", help="Only check packages installed within the last XX days, default: %default", metavar="DAYS", default=28, type="int")
@@ -169,7 +170,7 @@ class FedoraEasyKarma(object):
print " inst. RPMS: %s\n" % ("\n" + " " * 11 + ": ").join(installed_rpms)
try:
- karma = raw_input("Comment? -1/0/1 ->karma, other -> skip> ")
+ karma = self.raw_input("Comment? -1/0/1 ->karma, other -> skip> ", default=self.options.default_karma, add_to_history=False)
if karma in ["-1", "0", "1"]:
comment = self.raw_input("Comment> ", default=self.options.default_comment)
if comment:
@@ -302,7 +303,7 @@ class FedoraEasyKarma(object):
sys.stderr.write("Warning: %s\n" % message)
- def raw_input(self, prompt, default=""):
+ def raw_input(self, prompt, default="", add_to_history=True):
def pre_input_hook():
readline.insert_text(default)
readline.redisplay()
@@ -312,6 +313,13 @@ class FedoraEasyKarma(object):
return raw_input(prompt)
finally:
readline.set_pre_input_hook(None)
+ if not add_to_history:
+ try:
+ readline.remove_history_item(readline.get_current_history_length() - 1)
+ # raised when CTRL-D is used on first prompt
+ except ValueError:
+ pass
+
def send_comment(self, bc, update, comment, karma):