rm deps, fix formatting
Remove unneeded deps and some whitespace related formatting based on flake8 output. Signed-off-by: Pratyush Desai <pratyush.desai@liberta.casa>
This commit is contained in:
parent
28978abce3
commit
13ce17653a
25
plugin.py
25
plugin.py
@ -28,19 +28,13 @@
|
|||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
from humanize import ordinal
|
|
||||||
from supybot import utils, plugins, ircutils, callbacks, world, conf, log
|
from supybot import utils, plugins, ircutils, callbacks, world, conf, log
|
||||||
from supybot.commands import *
|
from supybot.commands import *
|
||||||
|
|
||||||
|
|
||||||
from num2words import num2words
|
from num2words import num2words
|
||||||
import dateutil.parser
|
|
||||||
import json
|
|
||||||
import requests
|
|
||||||
import pickle
|
import pickle
|
||||||
import sys
|
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -69,6 +63,7 @@ METHODS = {
|
|||||||
"smoked": ["Smoked"]
|
"smoked": ["Smoked"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class Tripsit(callbacks.Plugin):
|
class Tripsit(callbacks.Plugin):
|
||||||
"""Harm-Reduction tools from tripsit's tripbot and the tripsitwiki"""
|
"""Harm-Reduction tools from tripsit's tripbot and the tripsitwiki"""
|
||||||
threaded = True
|
threaded = True
|
||||||
@ -115,7 +110,7 @@ class Tripsit(callbacks.Plugin):
|
|||||||
if nick in self.db:
|
if nick in self.db:
|
||||||
self.db[nick]['timezone'] = timezone
|
self.db[nick]['timezone'] = timezone
|
||||||
else:
|
else:
|
||||||
self.db[nick] = {'timezone': timezone }
|
self.db[nick] = {'timezone': timezone}
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
except pytz.UnknownTimeZoneError:
|
except pytz.UnknownTimeZoneError:
|
||||||
irc.error(_('Unknown timezone'), Raise=True)
|
irc.error(_('Unknown timezone'), Raise=True)
|
||||||
@ -155,7 +150,7 @@ class Tripsit(callbacks.Plugin):
|
|||||||
dose_td = datetime.timedelta(hours=int(ago[0:2]), minutes=int(ago[2:4]))
|
dose_td = datetime.timedelta(hours=int(ago[0:2]), minutes=int(ago[2:4]))
|
||||||
dose_td_s = dose_td.total_seconds()
|
dose_td_s = dose_td.total_seconds()
|
||||||
time = time - dose_td
|
time = time - dose_td
|
||||||
doseLog = {'time': time, 'dose': dose, 'drug': name, 'method': method }
|
doseLog = {'time': time, 'dose': dose, 'drug': name, 'method': method}
|
||||||
doses = self.db[nick].get('doses')
|
doses = self.db[nick].get('doses')
|
||||||
if doses:
|
if doses:
|
||||||
doses.append(doseLog)
|
doses.append(doseLog)
|
||||||
@ -172,7 +167,7 @@ class Tripsit(callbacks.Plugin):
|
|||||||
dose_td = datetime.timedelta(hours=int(ago[0:2]), minutes=int(ago[2:4]))
|
dose_td = datetime.timedelta(hours=int(ago[0:2]), minutes=int(ago[2:4]))
|
||||||
dose_td_s = dose_td.total_seconds()
|
dose_td_s = dose_td.total_seconds()
|
||||||
time = time - dose_td
|
time = time - dose_td
|
||||||
doseLog = {'time': time, 'dose': dose, 'drug': name, 'method': method }
|
doseLog = {'time': time, 'dose': dose, 'drug': name, 'method': method}
|
||||||
doses = [doseLog]
|
doses = [doseLog]
|
||||||
self.db[nick] = {'timezone': timezone, 'doses': doses}
|
self.db[nick] = {'timezone': timezone, 'doses': doses}
|
||||||
|
|
||||||
@ -190,7 +185,7 @@ class Tripsit(callbacks.Plugin):
|
|||||||
@wrap([optional('positiveInt')])
|
@wrap([optional('positiveInt')])
|
||||||
def undose(self, irc, msg, args, entry):
|
def undose(self, irc, msg, args, entry):
|
||||||
"""<n>
|
"""<n>
|
||||||
|
|
||||||
removes your last dose entry, if <n> is provided then
|
removes your last dose entry, if <n> is provided then
|
||||||
deletes the nth last dose
|
deletes the nth last dose
|
||||||
"""
|
"""
|
||||||
@ -253,8 +248,8 @@ class Tripsit(callbacks.Plugin):
|
|||||||
dose_time = lastdose['time']
|
dose_time = lastdose['time']
|
||||||
timezone = self.db[nick]['timezone']
|
timezone = self.db[nick]['timezone']
|
||||||
tz = pytz.timezone(str(timezone))
|
tz = pytz.timezone(str(timezone))
|
||||||
time = datetime.datetime.now(tz=tz)
|
time = datetime.datetime.now(tz = tz)
|
||||||
since_dose = time - dose_time
|
since_dose= time - dose_time
|
||||||
since_dose_seconds = since_dose.total_seconds()
|
since_dose_seconds = since_dose.total_seconds()
|
||||||
if history:
|
if history:
|
||||||
history = num2words(history, to='ordinal')
|
history = num2words(history, to='ordinal')
|
||||||
@ -279,7 +274,7 @@ class Tripsit(callbacks.Plugin):
|
|||||||
try:
|
try:
|
||||||
rangecheck = self.db[nick]['doses'][-int(history)]
|
rangecheck = self.db[nick]['doses'][-int(history)]
|
||||||
irc.reply(f"Your last {history} doses logged are:", private=True)
|
irc.reply(f"Your last {history} doses logged are:", private=True)
|
||||||
for number in range(history,0,-1):
|
for number in range(history, 0, -1):
|
||||||
lastdose = self.db[nick]['doses'][-int(number)]
|
lastdose = self.db[nick]['doses'][-int(number)]
|
||||||
dose = lastdose['dose']
|
dose = lastdose['dose']
|
||||||
drug = lastdose['drug']
|
drug = lastdose['drug']
|
||||||
@ -315,7 +310,7 @@ class Tripsit(callbacks.Plugin):
|
|||||||
doselogs = self.db[nick]['doses']
|
doselogs = self.db[nick]['doses']
|
||||||
for doselog in doselogs:
|
for doselog in doselogs:
|
||||||
if doselog["drug"] == drug:
|
if doselog["drug"] == drug:
|
||||||
for i,c in enumerate(doselog["dose"]):
|
for i, c in enumerate(doselog["dose"]):
|
||||||
if not c.isdigit():
|
if not c.isdigit():
|
||||||
break
|
break
|
||||||
num += int(doselog["dose"][:i])
|
num += int(doselog["dose"][:i])
|
||||||
@ -323,7 +318,7 @@ class Tripsit(callbacks.Plugin):
|
|||||||
irc.reply(f"You have dosed a total of {num}{unit} amount of {drug}")
|
irc.reply(f"You have dosed a total of {num}{unit} amount of {drug}")
|
||||||
else:
|
else:
|
||||||
irc.error(f"No doses saved for {nick}")
|
irc.error(f"No doses saved for {nick}")
|
||||||
|
|
||||||
Class = Tripsit
|
Class = Tripsit
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user