Permalink
Browse files

PEP8 fixes.

  • Loading branch information...
jk0 committed Aug 27, 2013
1 parent cfaf0d6 commit 8c78700a76d33872e60ff8c6feb02b31b432af0a
View
@@ -29,7 +29,7 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage',
- 'sphinx.ext.viewcode']
+ 'sphinx.ext.viewcode']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -185,8 +185,8 @@
# (source start file, target name, title, author, documentclass
# [howto/manual]).
latex_documents = [
- ('index', 'pyhole.tex', u'Pyhole Documentation',
- u'Josh Kearney', 'manual'),
+ ('index', 'pyhole.tex', u'Pyhole Documentation', u'Josh Kearney',
+ 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
View
@@ -19,6 +19,7 @@
import utils
+
def setup_logger(name="Pyhole"):
"""Log handler"""
debug_option = utils.get_option("debug")
@@ -31,14 +32,17 @@ def setup_logger(name="Pyhole"):
log_datefmt = "%H:%M:%S"
logging.basicConfig(level=log_level, format=log_format,
- datefmt=log_datefmt)
+ datefmt=log_datefmt)
- log = logging.handlers.TimedRotatingFileHandler("%s/%s.log" % (log_dir,
- name.lower()), "midnight")
+ log_file = "%s/%s.log"
+ log = logging.handlers.TimedRotatingFileHandler(log_file % (log_dir,
+ name.lower()),
+ "midnight")
log.setLevel(log_level)
formatter = logging.Formatter(log_format, log_datefmt)
log.setFormatter(formatter)
logging.getLogger(name).addHandler(log)
+
def get_logger(name="Pyhole"):
return logging.getLogger(name)
View
@@ -147,7 +147,7 @@ def _init_plugins(*args, **kwargs):
hook_arg = getattr(attr, "_hook_arg", None)
# Append (module, method, arg) tuple
_plugin_hooks[hook_key].append((attr.__module__, attr,
- hook_arg))
+ hook_arg))
def load_user_plugin(plugin, *args, **kwargs):
View
@@ -59,18 +59,21 @@ def keyword_k(self, params=None, **kwargs):
desc = utils.decode_entities(soup.head.title.string)
try:
- status = soup.find("span", {"id":
- "static_bug_status"}).string.strip().capitalize()
- assignee = utils.decode_entities(soup.findAll("span",
- {"class": "vcard"})[0].contents[0].string)
+ status = soup.find("span", {
+ "id":
+ "static_bug_status"}).string.strip().capitalize()
+ assignee = utils.decode_entities(
+ soup.findAll("span", {
+ "class": "vcard"
+ })[0].contents[0].string)
- self.irc.reply("Kernel.org %s [Status: %s, Assignee: %s] %s" %
- (desc, status, assignee, url))
+ msg = "Kernel.org %s [Status: %s, Assignee: %s] %s"
+ self.irc.reply(msg % (desc, status, assignee, url))
except TypeError:
return
@plugin.hook_add_msg_regex(
- "https?:\/\/bugzilla\.kernel\.org\/show\_bug\.cgi\?id\=")
+ "https?:\/\/bugzilla\.kernel\.org\/show\_bug\.cgi\?id\=")
def _watch_for_k_bug_url(self, params=None, **kwargs):
"""Watch for kernel.org Bugzilla bug URLs"""
try:
@@ -27,7 +27,7 @@ def __init__(self, irc):
self.irc = irc
self.name = self.__class__.__name__
self.launchpad = LP.login_anonymously("pyhole", "production",
- utils.get_directory(self.name))
+ utils.get_directory(self.name))
@plugin.hook_add_command("lbugs")
@utils.spawn
@@ -49,7 +49,7 @@ def lbugs(self, params=None, **kwargs):
self._find_bugs(person, proj, False)
else:
self.irc.reply("[...] truncated last %d users" % (
- len(members.members) - i))
+ len(members.members) - i))
break
except KeyError:
self.irc.reply("Unable to find user '%s' in Launchpad" % team)
@@ -70,8 +70,10 @@ def keyword_lp(self, params=None, **kwargs):
task = bug.bug_tasks[len(bug.bug_tasks) - 1]
self.irc.reply("LP %s [Status: %s, Assignee: %s] %s" % (
- task.title, task.status,
- self._find_name(task.assignee_link), bug.web_link))
+ task.title,
+ task.status,
+ self._find_name(task.assignee_link),
+ bug.web_link))
except Exception:
return
@@ -111,11 +113,12 @@ def _find_bugs(self, person, project, single=True):
bugs = project.searchTasks(assignee=person)
for i, bug in enumerate(bugs):
if i <= 4:
- self.irc.reply("LP %s [Assignee: %s] %s" % (bug.title,
- person.display_name, bug.web_link))
+ self.irc.reply("LP %s [Assignee: %s] %s" % (
+ bug.title,
+ person.display_name, bug.web_link))
else:
self.irc.reply("[...] truncated last %d bugs" % (
- len(bugs) - i))
+ len(bugs) - i))
break
if single and i < 1:
View
@@ -36,7 +36,7 @@ def __init__(self, irc):
self.redmine_domain = self.redmine.get("domain")
self.redmine_key = self.redmine.get("key")
self.redmine_url = "https://%s:password@%s" % (
- self.redmine_key, self.redmine_domain)
+ self.redmine_key, self.redmine_domain)
except Exception:
self.disabled = True
@@ -55,7 +55,7 @@ def rbugs(self, params=None, **kwargs):
self._find_issue(issue["id"])
else:
self.irc.reply("[...] truncated last %d bugs" % (
- len(issues) - i))
+ len(issues) - i))
break
else:
if i <= 0:
@@ -87,7 +87,7 @@ def _watch_for_rm_bug_url(self, params=None, **kwargs):
def _find_issues(self, user_id):
"""Find all issues for a Redmine user"""
url = "%s/issues.json?assigned_to_id=%s" % (
- self.redmine_url, user_id)
+ self.redmine_url, user_id)
response = self.irc.fetch_url(url, self.name)
if not response:
return
@@ -108,7 +108,7 @@ def _find_users(self, offset=None):
"""Find all Redmine users"""
if offset:
url = "%s/users.json?limit=100&offset=%d" % (
- self.redmine_url, offset)
+ self.redmine_url, offset)
else:
url = "%s/users.json?limit=100" % self.redmine_url
response = self.irc.fetch_url(url, self.name)
@@ -129,9 +129,13 @@ def _find_issue(self, issue_id):
except Exception:
return
- self.irc.reply("RM %s #%s: %s [Status: %s, Priority: %s, Assignee: %s] "
- "https://%s/issues/%s" % (
- issue["tracker"]["name"], issue["id"], issue["subject"],
- issue["status"]["name"], issue["priority"]["name"],
- issue.get("assigned_to", {}).get("name", "N/A"),
- self.redmine_domain, issue["id"]))
+ msg = "RM %s #%s: %s [Status: %s, Priority: %s, Assignee: %s]" % (
+ issue["tracker"]["name"],
+ issue["id"],
+ issue["subject"],
+ issue["status"]["name"],
+ issue["priority"]["name"],
+ issue.get("assigned_to", {}).get("name", "N/A"))
+ url = "https://%s/issues/%s" % (self.redmine_domain, issue["id"])
+
+ self.irc.reply("%s %s" % (msg, url))
View
@@ -39,7 +39,7 @@ def google(self, params=None, **kwargs):
if params:
query = urllib.urlencode({"q": params})
url = ("http://ajax.googleapis.com/ajax/"
- "services/search/web?v=1.0&%s" % query)
+ "services/search/web?v=1.0&%s" % query)
response = self.irc.fetch_url(url, self.name)
if not response:
return
@@ -49,8 +49,8 @@ def google(self, params=None, **kwargs):
if results:
for r in results:
self.irc.reply("%s: %s" % (
- r["titleNoFormatting"].encode("ascii", "ignore"),
- r["unescapedUrl"]))
+ r["titleNoFormatting"].encode("ascii", "ignore"),
+ r["unescapedUrl"]))
else:
self.irc.reply("No results found: '%s'" % params)
else:
@@ -80,12 +80,12 @@ def imdb(self, params=None, **kwargs):
if len(result) > 3 and len(result.contents[2].attrs) > 0:
id = result.contents[2].attrs[0][1]
title = utils.decode_entities(
- result.contents[2].contents[0])
+ result.contents[2].contents[0])
year = result.contents[2].nextSibling.strip()[0:6]
if not title.startswith("aka") and len(year):
self.irc.reply("%s %s: http://www.imdb.com%s" % (
- title, year, id))
+ title, year, id))
i += 1
elif i >= 4:
break
@@ -110,9 +110,10 @@ def twitter(self, params=None, **kwargs):
results = json_obj["results"]
if results:
for r in results:
- self.irc.reply("@%s: %s" % (r["from_user"],
- utils.decode_entities(
- r["text"].encode("ascii", "ignore"))))
+ self.irc.reply("@%s: %s" % (
+ r["from_user"],
+ utils.decode_entities(r["text"].encode("ascii",
+ "ignore"))))
else:
self.irc.reply("No results found: '%s'" % params)
else:
@@ -135,7 +136,7 @@ def urban(self, params=None, **kwargs):
urban = ""
if len(results):
urban = " ".join(str(x) for x in soup.findAll(
- "div", {"class": "definition"})[0].contents)
+ "div", {"class": "definition"})[0].contents)
if len(urban) > 0:
for i, line in enumerate(urban.split("<br/>")):
@@ -155,8 +156,8 @@ def wikipedia(self, params=None, **kwargs):
"""Search Wikipedia (ex: .wikipedia <query>)"""
if params:
query = urllib.urlencode({"action": "query",
- "generator": "allpages", "gaplimit": 4,
- "gapfrom": params, "format": "xml"})
+ "generator": "allpages", "gaplimit": 4,
+ "gapfrom": params, "format": "xml"})
url = "http://en.wikipedia.org/w/api.php?%s" % query
response = self.irc.fetch_url(url, self.name)
if not response:
@@ -176,7 +177,7 @@ def youtube(self, params=None, **kwargs):
"""Search YouTube (ex: .youtube <query>)"""
if params:
query = urllib.urlencode({"q": params, "v": 2, "max-results": 4,
- "alt": "jsonc"})
+ "alt": "jsonc"})
url = "http://gdata.youtube.com/feeds/api/videos?%s" % query
response = self.irc.fetch_url(url, self.name)
if not response:
View
@@ -46,7 +46,7 @@ def _watch_for_url(self, params=None, **kwargs):
host = self.url[7:]
lookup_sites = ("open.spotify.com", "/open.spotify.com",
- "www.youtube.com", "/www.youtube.com")
+ "www.youtube.com", "/www.youtube.com")
if host.startswith(lookup_sites):
self._find_title(self.url)
@@ -66,7 +66,7 @@ def _find_title(self, url):
if soup.head:
title = utils.decode_entities(soup.head.title.string)
content_type = response.headers.get("Content-Type").split(";",
- 1)[0]
+ 1)[0]
content_size = response.headers.get("Content-Length")
content_size = content_size + " bytes" if content_size else "N/A"
@@ -37,9 +37,10 @@ def __init__(self, irc):
self.versionone_username = self.versionone.get("username")
self.versionone_password = self.versionone.get("password")
self.versionone_url = ("https://%s:%s@%s/%s/VersionOne/"
- "rest-1.v1") % (
- self.versionone_username, self.versionone_password,
- self.versionone_domain, self.versionone_key)
+ "rest-1.v1") % (self.versionone_username,
+ self.versionone_password,
+ self.versionone_domain,
+ self.versionone_key)
except Exception:
self.disabled = True
@@ -142,7 +143,6 @@ def _find_asset(self, type, number):
msg += " [%s]" % ", ".join(attrs)
msg += " https://%s/%s/%s.mvc/Summary?oidToken=%s" % (
- self.versionone_domain, self.versionone_key,
- type, id)
+ self.versionone_domain, self.versionone_key, type, id)
self.irc.reply(msg)
@@ -62,7 +62,11 @@ def weather(self, params=None, **kwargs):
humidity = "N/A%" if len(humidity) > 3 else humidity
result = ("%s%s: %s Humidity: %s Wind: %s %s") % (city,
- zip_code, temp, humidity, wind, condition)
+ zip_code,
+ temp,
+ humidity,
+ wind,
+ condition)
self.irc.reply(result)
else:
View
@@ -58,8 +58,8 @@ def decode_entities(html):
html = re.sub("\n", "", html)
html = re.sub(" +", " ", html)
html = " ".join(str(x).strip() for x in BeautifulStoneSoup(html,
- convertEntities=BeautifulStoneSoup.HTML_ENTITIES).findAll(
- text=True))
+ convertEntities=BeautifulStoneSoup.HTML_ENTITIES).findAll(
+ text=True))
return filter(lambda x: ord(x) > 9 and ord(x) < 127, html)
@@ -77,9 +77,9 @@ def build_options():
"""Generate command line options"""
parser = optparse.OptionParser(version=version.version_string())
parser.add_option("-c", "--config", default=get_conf_file_path(),
- help="specify the path to a configuration file")
+ help="specify the path to a configuration file")
parser.add_option("-d", "--debug", action="store_true",
- help="show debugging output")
+ help="show debugging output")
return parser.parse_args()
View
@@ -27,7 +27,7 @@ def current_git_hash():
"""Return the current git hash"""
git_file = ".git/refs/heads/master"
git_path = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
- os.pardir, os.pardir, git_file))
+ os.pardir, os.pardir, git_file))
if not os.path.exists(git_path):
git_path = os.getcwd() + "/" + git_file
View
@@ -24,5 +24,6 @@
if __name__ == "__main__":
tests = os.path.abspath(os.path.join("tests"))
tests_config = config.Config(stream=sys.stdout, env=os.environ,
- verbosity=3, workingDir=tests, plugins=core.DefaultPluginManager())
+ verbosity=3, workingDir=tests,
+ plugins=core.DefaultPluginManager())
core.run(config=tests_config, argv=sys.argv)

0 comments on commit 8c78700

Please sign in to comment.