From 121694f616515988828b3dad8608a9cc3298f0ec Mon Sep 17 00:00:00 2001 From: Till Maas Date: Sun, 7 Jul 2013 23:27:31 +0200 Subject: Apply some pep8 whitespace adjustments --- fedora-easy-karma.py | 75 +++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 33 deletions(-) (limited to 'fedora-easy-karma.py') diff --git a/fedora-easy-karma.py b/fedora-easy-karma.py index 8ff350d..17596e3 100755 --- a/fedora-easy-karma.py +++ b/fedora-easy-karma.py @@ -44,10 +44,16 @@ import yum from fedora.client.bodhi import BodhiClient -class FEK_helper(object): +class FEK_helper(object): @staticmethod - def bodhi_update_str(update, bodhi_base_url="https://admin.fedoraproject.org/updates/", bugzilla_bug_url="https://bugzilla.redhat.com/", test_cases_url="https://fedoraproject.org/wiki/", wrap_bugs=True, width=80): + def bodhi_update_str( + update, + bodhi_base_url="https://admin.fedoraproject.org/updates/", + bugzilla_bug_url="https://bugzilla.redhat.com/", + test_cases_url="https://fedoraproject.org/wiki/", + wrap_bugs=True, + width=80): # copy update to avoid side effects values = dict(update) @@ -67,11 +73,14 @@ class FEK_helper(object): " Submitter: %(submitter)s\n" " Submitted: %(date_submitted)s\n" "%(comments)s" - "\n%(update_url)s" - ) + "\n%(update_url)s") values["header_line"] = "=" * width - values["title"] = "\n".join(wrap(update["title"].replace(",", ", "), width=width, initial_indent=" "*5, subsequent_indent=" "*5)) + values["title"] = "\n".join( + wrap(update["title"].replace(",", ", "), + width=width, + initial_indent=" " * 5, + subsequent_indent=" " * 5)) if update["updateid"]: values["updateid"] = " Update ID: %s\n" % update["updateid"] @@ -99,7 +108,7 @@ class FEK_helper(object): for bug in update["bugs"]: bz_id = bug["bz_id"] if bugzilla_bug_url: - bz_id = "%s%d" % ( bugzilla_bug_url, bz_id) + bz_id = "%s%d" % (bugzilla_bug_url, bz_id) bz_title = bug["title"] bugs.append("%s - %s" % (bz_id, bz_title)) @@ -121,7 +130,6 @@ class FEK_helper(object): else: values["notes"] = "" - if len(update["comments"]): val = " Comments: " comments = [] @@ -146,7 +154,6 @@ class FEK_helper(object): else: values["comments"] = "" - if update["updateid"]: url_path = "%s/%s" % (update["release"]["name"], update["updateid"]) else: @@ -160,7 +167,6 @@ class FEK_helper(object): def wrap_paragraphs(paragraphs, width=67, subsequent_indent=(" "*11 + ": "), second_column_indent=0): return ("\n%s" % subsequent_indent).join(map(lambda p: "\n".join(wrap(p, width=width, subsequent_indent=(subsequent_indent + " " * second_column_indent))), paragraphs)) - @staticmethod def wrap_paragraphs_prefix(paragraphs, first_prefix, width=80, extra_newline=False): if isinstance(paragraphs, basestring): @@ -191,7 +197,7 @@ class FEK_helper(object): return ("\n%s" % subsequent_indent).join(output) -USAGE="""usage: %prog [options] [pattern, ..] +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 @@ -220,9 +226,14 @@ Please send bug reports and feature requests to For patches please use 'git send-email'. """ + class FedoraEasyKarma(object): def __init__(self): - usage = FEK_helper.wrap_paragraphs_prefix(USAGE, first_prefix="", width=80, extra_newline=False) + usage = FEK_helper.wrap_paragraphs_prefix( + USAGE, + first_prefix="", + width=80, + extra_newline=False) parser = OptionParser(usage=usage) parser.add_option("", "--bodhi-cached", dest="bodhi_cached", help="Use cached bodhi query", action="store_true", default=False) @@ -274,15 +285,14 @@ class FedoraEasyKarma(object): self.options.releasever = my.conf.yumvar["releasever"] release = "%s%s" % (self.options.product, self.options.releasever) - self.options.datadir = os.path.expanduser(self.options.datadir) - - installed_testing_builds = {} now = datetime.datetime.now() - installed_max_days = datetime.timedelta(self.options.installed_max_days) - installed_min_days = datetime.timedelta(self.options.installed_min_days) + installed_max_days = datetime.timedelta( + self.options.installed_max_days) + installed_min_days = datetime.timedelta( + self.options.installed_min_days) self.info("Getting list of installed packages...") self.debug("starting yum query") @@ -298,7 +308,9 @@ class FedoraEasyKarma(object): else: installed_testing_builds[build] = [pkg] - cachefile_name = os.path.join(self.options.datadir, "bodhi-cache-%s.cpickle" % release) + cachefile_name = os.path.join( + self.options.datadir, + "bodhi-cache-%s.cpickle" % release) if self.options.bodhi_cached: self.debug("reading bodhi cache") try: @@ -309,10 +321,14 @@ class FedoraEasyKarma(object): print "Cannot access bodhi cache file: %s" % cachefile_name sys.exit(ioe.errno) else: - self.info("Waiting for Bodhi for a list of packages in updates-testing (%s)..." % release) + self.info("Waiting for Bodhi for a list of packages in " + "updates-testing (%s)..." % release) self.debug("starting bodhi query") try: - testing_updates = bc.query(release=release, status="testing", limit=1000) + testing_updates = bc.query( + release=release, + status="testing", + limit=1000) # There is no clear indication which Exceptions bc.query() might # throw, therefore catch all (python-fedora-0.3.32.3-1.fc19) except Exception as e: @@ -328,7 +344,11 @@ class FedoraEasyKarma(object): # extend list of updates with updates that are going to testing to # support manually installed rpms from koji try: - pending_updates = bc.query(release=release, status="pending", request="testing", limit=1000) + pending_updates = bc.query( + release=release, + status="pending", + request="testing", + limit=1000) # There is no clear indication which Exceptions bc.query() might # throw, therefore catch all (python-fedora-0.3.32.3-1.fc19) except Exception as e: @@ -349,7 +369,6 @@ class FedoraEasyKarma(object): pickle.dump(testing_updates, outfile, -1) outfile.close() - ignorefile_name = os.path.join(self.options.datadir, "ignore.cpickle") previously_ignored_updates = [] self.debug("reading ignore file %s" % ignorefile_name) @@ -381,7 +400,8 @@ class FedoraEasyKarma(object): builds.sort() if not builds: - print "No testing packages found, you can run 'yum update --enablerepo=\"*-testing\"' to install some" + print "No testing packages found, you can run "\ + "'yum update --enablerepo=\"*-testing\"' to install some" for build in builds: update = testing_builds[build] @@ -444,7 +464,6 @@ class FedoraEasyKarma(object): pickle.dump(ignored_updates, outfile, -1) outfile.close() - def already_commented(self, update, user): for comment in update["comments"]: # :TODO:WORKAROUND: @@ -458,9 +477,6 @@ class FedoraEasyKarma(object): return True return False - - - def debug(self, message, update_timestamp=True): if self.options.debug: now = datetime.datetime.now() @@ -483,7 +499,6 @@ class FedoraEasyKarma(object): def info(self, message): sys.stderr.write("%s\n" % message) - def match_any(self, patterns, names): for name in list(itertools.chain(*names)): for pattern in patterns: @@ -491,11 +506,9 @@ class FedoraEasyKarma(object): return True return False - def warning(self, message): sys.stderr.write("Warning: %s\n" % message) - def raw_input(self, prompt, default="", add_to_history=True): def pre_input_hook(): readline.insert_text(default) @@ -513,8 +526,6 @@ class FedoraEasyKarma(object): except ValueError: pass - - def send_comment(self, bc, update, comment, karma): orig_retries = bc.retries bc.retries = 1 @@ -533,8 +544,6 @@ class FedoraEasyKarma(object): return (False, 'too many errors') - - if __name__ == "__main__": try: FedoraEasyKarma() -- cgit