Format everything to pep8 guidelines
This commit is contained in:
parent
cd4b65de3d
commit
99fe34a0b1
33 changed files with 142 additions and 107 deletions
|
@ -6,28 +6,30 @@ import re
|
|||
# variables
|
||||
|
||||
colors = collections.OrderedDict([
|
||||
('red', '\x0304'),
|
||||
('ornage', '\x0307'),
|
||||
('yellow', '\x0308'),
|
||||
('green', '\x0309'),
|
||||
('cyan', '\x0303'),
|
||||
('ltblue', '\x0310'),
|
||||
('rylblue','\x0312'),
|
||||
('blue', '\x0302'),
|
||||
('magenta','\x0306'),
|
||||
('pink', '\x0313'),
|
||||
('maroon', '\x0305')
|
||||
('red', '\x0304'),
|
||||
('ornage', '\x0307'),
|
||||
('yellow', '\x0308'),
|
||||
('green', '\x0309'),
|
||||
('cyan', '\x0303'),
|
||||
('ltblue', '\x0310'),
|
||||
('rylblue', '\x0312'),
|
||||
('blue', '\x0302'),
|
||||
('magenta', '\x0306'),
|
||||
('pink', '\x0313'),
|
||||
('maroon', '\x0305')
|
||||
])
|
||||
|
||||
# helper functions
|
||||
|
||||
strip_re = re.compile("(\x03|\x02|\x1f)(?:,?\d{1,2}(?:,\d{1,2})?)?", re.UNICODE)
|
||||
|
||||
|
||||
def strip(text):
|
||||
return strip_re.sub('', text)
|
||||
return strip_re.sub('', text)
|
||||
|
||||
# basic text tools
|
||||
|
||||
|
||||
## TODO: make this capitalize sentences correctly
|
||||
@hook.command("capitalise")
|
||||
@hook.command
|
||||
|
@ -35,21 +37,25 @@ def capitalize(inp):
|
|||
"""capitalize <string> -- Capitalizes <string>."""
|
||||
return inp.capitalize()
|
||||
|
||||
|
||||
@hook.command
|
||||
def upper(inp):
|
||||
"""upper <string> -- Convert string to uppercase."""
|
||||
return inp.upper()
|
||||
|
||||
|
||||
@hook.command
|
||||
def lower(inp):
|
||||
"""lower <string> -- Convert string to lowercase."""
|
||||
return inp.lower()
|
||||
|
||||
|
||||
@hook.command
|
||||
def titlecase(inp):
|
||||
"""title <string> -- Convert string to title case."""
|
||||
return inp.title()
|
||||
|
||||
|
||||
@hook.command
|
||||
def swapcase(inp):
|
||||
"""swapcase <string> -- Swaps the capitalization of <string>."""
|
||||
|
@ -57,21 +63,25 @@ def swapcase(inp):
|
|||
|
||||
# encoding
|
||||
|
||||
|
||||
@hook.command
|
||||
def rot13(inp):
|
||||
"""rot13 <string> -- Encode <string> with rot13."""
|
||||
return inp.encode('rot13')
|
||||
|
||||
|
||||
@hook.command
|
||||
def base64(inp):
|
||||
"""base64 <string> -- Encode <string> with base64."""
|
||||
return inp.encode('base64')
|
||||
|
||||
|
||||
@hook.command
|
||||
def unbase64(inp):
|
||||
"""unbase64 <string> -- Decode <string> with base64."""
|
||||
return inp.decode('base64')
|
||||
|
||||
|
||||
@hook.command
|
||||
def checkbase64(inp):
|
||||
try:
|
||||
|
@ -86,6 +96,7 @@ def checkbase64(inp):
|
|||
else:
|
||||
return '"{}" is not base64 encoded'.format(inp)
|
||||
|
||||
|
||||
@hook.command
|
||||
def unescape(inp):
|
||||
"""unescape <string> -- Unescapes <string>."""
|
||||
|
@ -94,6 +105,7 @@ def unescape(inp):
|
|||
except Exception as e:
|
||||
return "Error: {}".format(e)
|
||||
|
||||
|
||||
@hook.command
|
||||
def escape(inp):
|
||||
"""escape <string> -- Escapes <string>."""
|
||||
|
@ -104,6 +116,7 @@ def escape(inp):
|
|||
|
||||
# length
|
||||
|
||||
|
||||
@hook.command
|
||||
def length(inp):
|
||||
"""length <string> -- gets the length of <string>"""
|
||||
|
@ -111,13 +124,15 @@ def length(inp):
|
|||
|
||||
# reverse
|
||||
|
||||
|
||||
@hook.command
|
||||
def reverse(inp):
|
||||
"""reverse <string> -- reverses <string>."""
|
||||
return inp[::-1]
|
||||
|
||||
|
||||
# hashing
|
||||
|
||||
|
||||
@hook.command
|
||||
def hash(inp):
|
||||
"""hash <string> -- Returns hashes of <string>."""
|
||||
|
@ -126,6 +141,7 @@ def hash(inp):
|
|||
|
||||
# novelty
|
||||
|
||||
|
||||
@hook.command
|
||||
def munge(inp):
|
||||
"""munge <text> -- Munges up <text>."""
|
||||
|
@ -133,6 +149,7 @@ def munge(inp):
|
|||
|
||||
# colors - based on code by Reece Selwood - <https://github.com/hitzler/homero>
|
||||
|
||||
|
||||
@hook.command
|
||||
def rainbow(inp):
|
||||
inp = unicode(inp)
|
||||
|
@ -147,6 +164,7 @@ def rainbow(inp):
|
|||
out += col[i % l][1] + t
|
||||
return out
|
||||
|
||||
|
||||
@hook.command
|
||||
def wrainbow(inp):
|
||||
inp = unicode(inp)
|
||||
|
@ -158,6 +176,7 @@ def wrainbow(inp):
|
|||
out.append(col[i % l][1] + t)
|
||||
return ' '.join(out)
|
||||
|
||||
|
||||
@hook.command
|
||||
def usa(inp):
|
||||
inp = strip(inp)
|
||||
|
@ -167,4 +186,3 @@ def usa(inp):
|
|||
for i, t in enumerate(inp):
|
||||
out += c[i % l] + t
|
||||
return out
|
||||
|
||||
|
|
Reference in a new issue