From 7336b511eab38ea11bc1b007e0dc42b1ccf9c371 Mon Sep 17 00:00:00 2001 From: "FunnyMan3595 (Charlie Nolan)" Date: Thu, 28 Aug 2008 16:57:14 -0500 Subject: [PATCH] Trimming whitespace at end of line, removing unneeded print statements. --- basic_commands.py | 4 ++-- common.py | 2 +- connection.py | 3 +-- globals.py | 4 ++-- hal.py | 2 +- panic.py | 6 +++--- reminders.py | 26 +++++++++++++------------- safety.py | 2 +- threadsafe_sched.py | 12 ++++++------ urllib2.py | 8 ++++---- web.py | 4 ---- whois.py | 2 +- 12 files changed, 35 insertions(+), 40 deletions(-) diff --git a/basic_commands.py b/basic_commands.py index 4641ca9..f4d3291 100644 --- a/basic_commands.py +++ b/basic_commands.py @@ -135,12 +135,12 @@ commands["set-perm"] = (perms.ircop, set_perm) def tell_commands(who, where, args, user_perms): "$commands: Shows you all the stuff you can do." - command_list = [command for command in commands + command_list = [command for command in commands if " " not in command if commands[command][0] <= user_perms] command_list.sort() commands_str = ", ".join(command_list) - reply(who, where, + reply(who, where, "Available commands at your permission level: " + commands_str) commands['commands'] = (perms.voice, tell_commands, "I want perms.") diff --git a/common.py b/common.py index a7c9ccd..65f0c8c 100644 --- a/common.py +++ b/common.py @@ -11,7 +11,7 @@ def get_timestamp(when=None): def resize(list_or_tuple, length): '''Creates a new list or tuple of length 'length', using as many elements from - list_or_tuple as possible and right-padding with "". Does not modify + list_or_tuple as possible and right-padding with "". Does not modify list_or_tuple.''' if len(list_or_tuple) < length: if type(list_or_tuple) == list: diff --git a/connection.py b/connection.py index 9e9af25..8b772ae 100644 --- a/connection.py +++ b/connection.py @@ -45,7 +45,6 @@ def flood_protect(who, where, is_first): user = irclib.nm_to_n(who) whois.userhost_callbacks[user] = (do_kickban, ("Hal", where, "Flooding.")) hal.connection.userhost([user]) - print user last_messages = {} #@safe @@ -100,7 +99,7 @@ def got_msg(conn, event): else: command = "factoid implicit" args = msg - got_command(who, where, command, args) + got_command(who, where, command, args) got_msg = safe(got_msg) irc.add_global_handler("privmsg", got_msg) irc.add_global_handler("pubmsg", got_msg) diff --git a/globals.py b/globals.py index cbb5d6b..8a31b9e 100644 --- a/globals.py +++ b/globals.py @@ -56,8 +56,8 @@ except IOError: def save(who=None, where=None, args=None): pickled = pickle(( - SAVE_VERSION, - (my_users, factoid_dbs, locked_dbs, reminder_dbs, + SAVE_VERSION, + (my_users, factoid_dbs, locked_dbs, reminder_dbs, subscription_dbs, unlower, poke_via_msg, factoids_on, kill_channels) )) diff --git a/hal.py b/hal.py index 06fa97b..b463f84 100755 --- a/hal.py +++ b/hal.py @@ -5,7 +5,7 @@ import globals, connection, whois, basic_commands, web, factoids, reminders, pan from perms import Perms -from connection import debug_console, process_events +from connection import debug_console, process_events from reminders import run_reminders thread.start_new_thread(debug_console, ()) thread.start_new_thread(run_reminders, ()) diff --git a/panic.py b/panic.py index 122f8f4..7e87cd3 100644 --- a/panic.py +++ b/panic.py @@ -33,11 +33,11 @@ def unpanic(who, where, args): if len(buffer) < buffer_size: buffer.append(user) else: - hal.connection.mode(where, "+%s %s" % (("v" * buffer_size), + hal.connection.mode(where, "+%s %s" % (("v" * buffer_size), " ".join(buffer))) buffer = [user] if buffer: - hal.connection.mode(where, "+%s %s" % (("v" * len(buffer)), + hal.connection.mode(where, "+%s %s" % (("v" * len(buffer)), " ".join(buffer))) commands['unpanic'] = (perms.op, unpanic) @@ -63,7 +63,7 @@ def server_ban(who, where, args): commands['server-ban'] = (perms.ircop, server_ban) def do_server_ban(nm, who, where, reason): - hal.connection.privmsg("OperServ", "AKILL ADD +0 *@%s %s (%s)" % + hal.connection.privmsg("OperServ", "AKILL ADD +0 *@%s %s (%s)" % (irclib.nm_to_h(nm), reason, who)) hal.connection.send_raw("KILL %s %s (%s)" % (irclib.nm_to_n(nm), reason, who)) diff --git a/reminders.py b/reminders.py index a516b01..d76b0cb 100644 --- a/reminders.py +++ b/reminders.py @@ -40,13 +40,13 @@ def describe_reminder(reminder): reminder_res = {"add": re.compile(r'^"((?:[^"]|\")*)" +at +([^"]*)$', re.IGNORECASE), "set": re.compile(r'^(\d+) +(\w+) +(.*)$', re.IGNORECASE), - "repeat h+:mm": re.compile(r'^(\d+) +every +(\d+):(\d\d)$', + "repeat h+:mm": re.compile(r'^(\d+) +every +(\d+):(\d\d)$', re.IGNORECASE), - "repeat x units": re.compile(r'^(\d+) +every +(\d+) +' + + "repeat x units": re.compile(r'^(\d+) +every +(\d+) +' + r'(week|day|hour|minute)s?$', re.IGNORECASE), "repeat off": re.compile(r'^(\d+) +(off|disable|stop|never|none' - +r'|remove)$', + +r'|remove)$', re.IGNORECASE) } @@ -70,7 +70,7 @@ def fire_reminder(where, reminders, reminder): curtime = time.time() if when < (curtime - 60): delay = curtime - when - reply('', where, "Reminder delayed by %d minutes: %s" % (delay // 60, + reply('', where, "Reminder delayed by %d minutes: %s" % (delay // 60, message), all=True) else: delay = 0 @@ -87,7 +87,7 @@ def fire_reminder(where, reminders, reminder): if not poke_via_msg.get(who, False)] if poke_list: poke_str = ", ".join(poke_list) - reply("", where, poke_str + ": I'm in yer reminders, informin' you.", + reply("", where, poke_str + ": I'm in yer reminders, informin' you.", all=True) for who in inform_us: if poke_via_msg.get(who, False): @@ -114,7 +114,7 @@ def add_reminder(who, where, reminders, reminder): schedule_reminder(real_where(who, where), reminders, reminder) reply(who, where, "Reminder %d added." % len(reminders)) else: - reply(who, where, + reply(who, where, "I'm sorry, %s, I'm afraid I can't do that. You're limited to 10." % who) @@ -156,7 +156,7 @@ def reminder(who, where, reminder_args): reminder = reminders[which] del reminders[which] cancel_reminder(real_where(who, where), reminders, reminder) - reply(who, where, "Deleted reminder %d: %s" % + reply(who, where, "Deleted reminder %d: %s" % (which+1, describe_reminder(reminder))) elif command in ("list", "show"): if len(reminders) > 5: @@ -221,8 +221,8 @@ def reminder(who, where, reminder_args): reply(who, where, "Repeating continuously sounds like a bad idea.") return reminder[3] = 60 * (minutes + 60 * hours) - reply(who, where, - "Reminder number %d now repeating every %d hours and %d minutes." + reply(who, where, + "Reminder number %d now repeating every %d hours and %d minutes." % (which+1, hours, minutes)) elif parse_units: (whichstr, numstr, unit) = parsed.groups() @@ -235,12 +235,12 @@ def reminder(who, where, reminder_args): reply(who, where, "I don't know that unit.") return reminder[3] = num * time_units[unit] - reply(who, where, "Reminder number %d now repeating every %d %ss." + reply(who, where, "Reminder number %d now repeating every %d %ss." % (which+1, num, unit)) else: # parse_off reminder[3] = 0 reply(who, where, "Repeating disabled on reminder %d." % which+1) - + elif command == "help": if not args: reply(who, where, "To get help on a specific command, type $reminder " \ @@ -286,7 +286,7 @@ def subscribe(who, where, args): reply(who, where, "Don't you think subscribing to reminders that are" + " already in PM is a bit... pointless?") return - + unlower[irc_lower(who)] = who subscriptions = get_subscription_db(who, where) targets = [target.strip() for target in args.split(",")] @@ -303,7 +303,7 @@ def subscribe(who, where, args): reply(who, where, "You're already subscribed.") commands['subscribe'] = (perms.voice, subscribe) -def unsubscribe(who, where, args): +def unsubscribe(who, where, args): "$unsubscribe : Unsubscribes you from the (comma-separated) list of reminder groups." subscriptions = get_subscription_db(who, where) targets = [target.strip() for target in args.split(",")] diff --git a/safety.py b/safety.py index 53a2a81..ef32771 100644 --- a/safety.py +++ b/safety.py @@ -18,7 +18,7 @@ def safe_call(func, args): except Exception, e: if isinstance(e, SystemExit): raise - buffer = Buffer("Exception in function %s at %s:\n" + buffer = Buffer("Exception in function %s at %s:\n" % (func.__name__, get_timestamp())) traceback.print_exc(file=buffer) logging.getLogger().error(buffer.data) diff --git a/threadsafe_sched.py b/threadsafe_sched.py index 87b74ae..e1600fb 100644 --- a/threadsafe_sched.py +++ b/threadsafe_sched.py @@ -3,7 +3,7 @@ # FunnyMan3595 (Charlie Nolan); All Rights Rexerved. # The intent is to add this to the Python standard library, which -# may require a transfer of copyright. Until such addition occurs, +# may require a transfer of copyright. Until such addition occurs, # special permission is granted to distribute, run, and otherwise use # this module as though it were part of that library, provided that # this notice is maintained. @@ -15,7 +15,7 @@ convert_instructions for more information. Each instance of this class manages its own queue. The methods of this class are thread-safe and can be called from -other threads while the scheduler is running. Only one scheduled +other threads while the scheduler is running. Only one scheduled event will run at a time, but be careful of race conditions if other threads work with the same resources. @@ -43,7 +43,7 @@ functions or methods can be used by omitting the argument when calling enter or enterabs, which defaults it to (). """ -# TODO: Fix the description of argument passing. It's just +# TODO: Fix the description of argument passing. It's just # func(*args), so I'm guessing the terminology is left over from when # that had another meaning. I've patched it to be more accurate, but # it's clumsy. @@ -58,11 +58,11 @@ harder. You need to make four changes: 1. The delay function should call .condition.release before any real-time delay delay occurs, to minimize delays to other threads. -If you can convert to real-time, you should probably just call +If you can convert to real-time, you should probably just call .condition.wait(real_time) instead. 2. You must implement a wake function that causes the delay function -to return prematurely, as soon as is practical. If you use +to return prematurely, as soon as is practical. If you use .condition.wait in the delay function, you can leave this as the default (.condition.notify). Otherwise, you may wish to consider using a Condition of your own, from module "threading". @@ -150,7 +150,7 @@ class scheduler: def empty(self): """Check whether the queue is empty. - Note: .empty() and anything that depends on it should be + Note: .empty() and anything that depends on it should be surrounded by .condition.acquire() and .condition.release() if multiple threads are running. diff --git a/urllib2.py b/urllib2.py index d8d5569..9e90e96 100644 --- a/urllib2.py +++ b/urllib2.py @@ -713,7 +713,7 @@ class AbstractDigestAuthHandler: # prompting for the information. Crap. This isn't great # but it's better than the current 'repeat until recursion # depth exceeded' approach - raise HTTPError(req.get_full_url(), 401, "digest auth failed", + raise HTTPError(req.get_full_url(), 401, "digest auth failed", headers, None) else: self.retried += 1 @@ -788,7 +788,7 @@ class AbstractDigestAuthHandler: else: # XXX handle auth-int. pass - + # XXX should the partial digests be encoded too? base = 'username="%s", realm="%s", nonce="%s", uri="%s", ' \ @@ -830,7 +830,7 @@ class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler): def http_error_401(self, req, fp, code, msg, headers): host = urlparse.urlparse(req.get_full_url())[1] - retry = self.http_error_auth_reqed('www-authenticate', + retry = self.http_error_auth_reqed('www-authenticate', host, req, headers) self.reset_retry_count() return retry @@ -842,7 +842,7 @@ class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler): def http_error_407(self, req, fp, code, msg, headers): host = req.get_host() - retry = self.http_error_auth_reqed('proxy-authenticate', + retry = self.http_error_auth_reqed('proxy-authenticate', host, req, headers) self.reset_retry_count() return retry diff --git a/web.py b/web.py index 7a8c481..35e9086 100644 --- a/web.py +++ b/web.py @@ -13,7 +13,6 @@ def title(who, where, args, all=False): reply(who, where, "[%s]" % (html.get_title(args)), all) except Exception, e: #if not html.is_webpage(args): - print e reply(who, where, "Error retrieving URL '%s'." % args, all) title = troggie(title) title = throttle("web", quiet=True)(title) @@ -29,7 +28,6 @@ def calc(who, where, args): try: reply(who, where, "Google says: %s" % html.google_calc(args), all=True) except Exception, e: - print e reply(who, where, "Ewwww... Google barfed on me.", all=True) #calc = troggie(calc) calc = web_throttle(calc) @@ -41,7 +39,6 @@ def google(who, where, args): url = html.first_google(args) reply(who, where, "Google says: %s [%s]." % (url, html.get_title(url)), all=True) except Exception, e: - print e reply(who, where, "Ewwww... Google barfed on me.", all=True) #google = troggie(google) google = web_throttle(google) @@ -70,7 +67,6 @@ def onr(who, where, args, comic=None): url = html.first_onr(args, comic) reply(who, where, "OhNoRobot.com says: %s [%s]." % (url, html.get_title(url)), all=True) except Exception, e: - print e reply(who, where, "Oh no! No luck.", all=True) onr = web_throttle(onr) commands['onr'] = (perms.voice, onr) diff --git a/whois.py b/whois.py index a36ebe6..1a069ad 100644 --- a/whois.py +++ b/whois.py @@ -11,7 +11,7 @@ def voice_or_better(channel): from connection import hal if channel in hal.channels: chan = hal.channels[channel] - dicts = (chan.voiceddict, chan.hopdict, chan.operdict, chan.admindict, + dicts = (chan.voiceddict, chan.hopdict, chan.operdict, chan.admindict, chan.ownerdict) return multiunion(*[ircdict_to_set(d) for d in dicts]) else: -- 2.11.4.GIT