Skip to content

Commit

Permalink
[modules] Remove unused imports and variables.
Browse files Browse the repository at this point in the history
Also fixes some formatting.
  • Loading branch information
ari-koivula committed Jun 27, 2013
1 parent 4391ec1 commit 29a17f5
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 45 deletions.
2 changes: 0 additions & 2 deletions bugzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import re
from willie import web, tools
from willie.module import rule
import urllib
import urllib2


def configure(config):
Expand Down
2 changes: 1 addition & 1 deletion dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def dice(bot, trigger):
arr = arr.replace('-', ' - ').replace('+', ' + ').replace('/', ' / ')
arr = arr.replace('*', ' * ').replace('(', ' ( ').replace(')', ' ) ')
arr = arr.replace('^', ' ^ ').replace('()', '').split(' ')
full_string, calc_string = '', ''
full_string = ''

for segment in arr:
#check for dice
Expand Down
11 changes: 5 additions & 6 deletions github.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from datetime import datetime
from urllib2 import HTTPError
import json
import re
from willie import web
from willie.module import commands

Expand Down Expand Up @@ -38,20 +37,20 @@ def configure(config):
@commands('makeissue', 'makebug')
def issue(bot, trigger):
"""Create a GitHub issue, also known as a bug report. Syntax: .makeissue Title of the bug report"""
#check input
# check input
if not trigger.group(2):
return bot.say('Please title the issue')

#Is the Oauth token and repo available?
# Is the Oauth token and repo available?
gitAPI = checkConfig(bot)
if gitAPI == False:
return bot.say('Git module not configured, make sure github.oauth_token and github.repo are defined')

#parse input
# parse input
now = ' '.join(str(datetime.utcnow()).split(' ')).split('.')[0] + ' UTC'
body = 'Submitted by: %s\nFrom channel: %s\nAt %s' % (trigger.nick, trigger.sender, now)
data = {"title": trigger.group(2).encode('utf-8'), "body": body, "labels": ["IRC"]}
#submit
# submit
try:
raw = web.post('https://api.github.com/repos/' + gitAPI[1] + '/issues?access_token=' + gitAPI[0], json.dumps(data))
except HTTPError:
Expand All @@ -68,7 +67,7 @@ def findIssue(bot, trigger):
if not trigger.group(2):
return bot.reply('What are you searching for?')

#Is the Oauth token and repo available?
# Is the Oauth token and repo available?
gitAPI = checkConfig(bot)
if gitAPI == False:
return bot.say('Git module not configured, make sure github.oauth_token and github.repo are defined')
Expand Down
7 changes: 5 additions & 2 deletions ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from willie.module import commands, example


def configure(config):
"""
Expand All @@ -33,6 +34,7 @@ def configure(config):
config.add_section('ip')
config.interactive_add('ip', 'GeoIP_db_path', 'Full path to the GeoIP database', None)


def _decompress(source, target, delete_after_decompression = True):
""" Decompress a GZip file """
f_in = gzip.open(source, 'rb')
Expand All @@ -43,6 +45,7 @@ def _decompress(source, target, delete_after_decompression = True):
if delete_after_decompression:
os.remove(source)


def _find_geoip_db(bot):
""" Find the GeoIP database """
config = bot.config
Expand All @@ -53,8 +56,8 @@ def _find_geoip_db(bot):
else:
bot.debug('ip', 'GeoIP path configured but DB not found in configured path', 'warning')
if (os.path.isfile(os.path.join(bot.config.homedir, 'GeoLiteCity.dat')) and
os.path.isfile(os.path.join(bot.config.homedir, 'GeoIPASNum.dat'))):
return bot.config.homedir
os.path.isfile(os.path.join(bot.config.homedir, 'GeoIPASNum.dat'))):
return bot.config.homedir
elif (os.path.isfile(os.path.join('/usr/share/GeoIP', 'GeoLiteCity.dat')) and
os.path.isfile(os.path.join('/usr/share/GeoIP', 'GeoIPASNum.dat'))):
return '/usr/share/GeoIP'
Expand Down
3 changes: 1 addition & 2 deletions isup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from willie import web
from willie.module import commands
import re


@commands('isup')
Expand All @@ -26,7 +25,7 @@ def isup(bot, trigger):
site = 'http://' + site
try:
response = web.get(site)
except Exception as e:
except Exception:
bot.say(site + ' looks down from here.')
return

Expand Down
3 changes: 1 addition & 2 deletions meetbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def configure(config):
config.interactive_add('meetbot', 'meeting_log_path', "Path to meeting logs storage directory (should be an absolute path, accessible on a webserver)")
config.interactive_add('meetbot', 'meeting_log_baseurl', "Base URL for the meeting logs directory (eg. http://example.com/logs)")

meetings_dict = Ddict(dict) # Saves metadata about currently running meetings
"""
meetings_dict is a 2D dict.
Expand All @@ -39,8 +40,6 @@ def configure(config):
Using channel as the meeting ID as there can't be more than one meeting in a channel at the same time.
"""

meetings_dict = Ddict(dict) # Saves metadata about currently running meetings
meeting_log_path = '' # To be defined on meeting start as part of sanity checks, used by logging functions so we don't have to pass them bot
meeting_log_baseurl = '' # To be defined on meeting start as part of sanity checks, used by logging functions so we don't have to pass them bot

Expand Down
3 changes: 1 addition & 2 deletions radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from xml.dom.minidom import parseString
import willie.web as web
from willie.module import commands
import xml.dom.minidom


def configure(config):
Expand All @@ -34,7 +33,7 @@ def getAPI(bot, trigger):
#contact the 'heavyweight' XML API
try:
raw = web.get(radioURL % 'stats')
except Exception as e:
except Exception:
bot.say('The radio is not responding to the stats request.')
return 0

Expand Down
2 changes: 1 addition & 1 deletion remind.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pytz import timezone, all_timezones_set
import pytz
import codecs
from datetime import tzinfo, timedelta, datetime
from datetime import datetime
from willie.module import commands, example, NOLIMIT


Expand Down
3 changes: 1 addition & 2 deletions rss.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
from willie.module import commands, priority
import feedparser
import socket
import sys
import time

DEBUG = False
socket.setdefaulttimeout(10)
INTERVAL = 10 # seconds between checking for new updates
STOP = False
#This is reset in setup().
# This is reset in setup().
SUB = ('%s',)


Expand Down
2 changes: 0 additions & 2 deletions tell.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
"""

import os
import re
import time
import datetime
import pytz
import random
import threading
from willie.tools import Nick
from willie.module import commands, nickname_commands, rule, priority, example
Expand Down
1 change: 0 additions & 1 deletion tld.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from willie import web
from willie.module import commands, example
import re
import urllib2

uri = 'https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains'
r_tag = re.compile(r'<(?!!)[^>]+>')
Expand Down
4 changes: 1 addition & 3 deletions translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
http://willie.dftba.net
"""

import re
from willie import web
from willie.module import rule, commands, priority, example
from time import sleep
import urllib2
import json
import random
Expand Down Expand Up @@ -163,7 +161,7 @@ def mangle(bot, trigger):
global mangle_lines
long_lang_list = ['fr', 'de', 'es', 'it', 'no', 'he', 'la', 'ja', 'cy', 'ar', 'yi', 'zh', 'nl', 'ru', 'fi', 'hi', 'af', 'jw', 'mr', 'ceb', 'cs', 'ga', 'sv', 'eo', 'el', 'ms', 'lv']
lang_list = []
for index in range(0, 8):
for __ in range(0, 8):
lang_list = get_random_lang(long_lang_list, lang_list)
random.shuffle(lang_list)
if trigger.group(2) is None:
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""

from datetime import datetime
from subprocess import *
from subprocess import Popen, PIPE
import willie


Expand Down
13 changes: 5 additions & 8 deletions weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@
http://willie.dftba.net
"""

import re
import urllib
import json
from willie import web
from willie.module import commands, example
from lxml import etree
import feedparser


def setup(bot):
#Having a db means pref's exists. Later, we can just use `if bot.db`.
# Having a db means pref's exists. Later, we can just use `if bot.db`.
if bot.db and not bot.db.preferences.has_columns('woeid'):
bot.db.preferences.add_columns(['woeid'])

Expand Down Expand Up @@ -48,8 +45,8 @@ def get_cover(parsed):
except KeyError:
return 'unknown'
text = condition['text']
code = int(condition['code'])
#TODO parse code to get those little icon thingies.
# code = int(condition['code'])
# TODO parse code to get those little icon thingies.
return text


Expand Down Expand Up @@ -82,8 +79,8 @@ def get_wind(parsed):
kph = float(wind_data['speed'])
except ValueError:
kph = -1
#Incoming data isn't a number, default to zero.
#This is a dirty fix for issue #218
# Incoming data isn't a number, default to zero.
# This is a dirty fix for issue #218
speed = int(round(kph / 1.852, 0))
degrees = int(wind_data['direction'])
if speed < 1:
Expand Down
2 changes: 1 addition & 1 deletion wiktionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def wiktionary(bot, trigger):
bot.reply('You must tell me what to look up!')
return

etymology, definitions = wikt(word)
_etymology, definitions = wikt(word)
if not definitions:
bot.say("Couldn't get any definitions for %s." % word)
return
Expand Down
18 changes: 9 additions & 9 deletions youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ def ytget(bot, trigger, uri):
vid_id = video_entry['id']['$t'].split(':')
vid_id = vid_id[len(vid_id) - 1] # last item is the actual ID
vid_info['link'] = 'http://youtu.be/' + vid_id
except KeyError as e:
except KeyError:
vid_info['link'] = 'N/A'

try:
vid_info['title'] = video_entry['title']['$t']
except KeyError as e:
except KeyError:
vid_info['title'] = 'N/A'

#get youtube channel
try:
vid_info['uploader'] = video_entry['author'][0]['name']['$t']
except KeyError as e:
except KeyError:
vid_info['uploader'] = 'N/A'

#get upload time in format: yyyy-MM-ddThh:mm:ss.sssZ
Expand All @@ -64,7 +64,7 @@ def ytget(bot, trigger, uri):
vid_info['uploaded'] = '%s/%s/%s, %s:%s' % (upraw[8:10], upraw[5:7],
upraw[0:4], upraw[11:13],
upraw[14:16])
except KeyError as e:
except KeyError:
vid_info['uploaded'] = 'N/A'

#get duration in seconds
Expand All @@ -88,33 +88,33 @@ def ytget(bot, trigger, uri):
vid_info['length'] = vid_info['length'] + ' '
if seconds:
vid_info['length'] = vid_info['length'] + str(seconds) + 'secs'
except KeyError as e:
except KeyError:
vid_info['length'] = 'N/A'

#get views
try:
views = video_entry['yt$statistics']['viewCount']
vid_info['views'] = str('{0:20,d}'.format(int(views))).lstrip(' ')
except KeyError as e:
except KeyError:
vid_info['views'] = 'N/A'

#get comment count
try:
comments = video_entry['gd$comments']['gd$feedLink']['countHint']
vid_info['comments'] = str('{0:20,d}'.format(int(comments))).lstrip(' ')
except KeyError as e:
except KeyError:
vid_info['comments'] = 'N/A'

#get likes & dislikes
try:
likes = video_entry['yt$rating']['numLikes']
vid_info['likes'] = str('{0:20,d}'.format(int(likes))).lstrip(' ')
except KeyError as e:
except KeyError:
vid_info['likes'] = 'N/A'
try:
dislikes = video_entry['yt$rating']['numDislikes']
vid_info['dislikes'] = str('{0:20,d}'.format(int(dislikes))).lstrip(' ')
except KeyError as e:
except KeyError:
vid_info['dislikes'] = 'N/A'
return vid_info

Expand Down

0 comments on commit 29a17f5

Please sign in to comment.