ran autopep8

This commit is contained in:
Tobin
2015-03-31 00:20:44 -05:00
parent 28c703e5a4
commit 16ab77fc2c
11 changed files with 125 additions and 62 deletions

View File

@@ -11,6 +11,7 @@ from .exceptions import ProgramError
__all__ = ['open_browser', 'clean', 'wrap_text', 'strip_textpad',
'strip_subreddit_url', 'humanize_timestamp', 'open_editor']
def open_editor(data=''):
"""
Open a temporary file using the system's default editor.
@@ -39,6 +40,7 @@ def open_editor(data=''):
return text
def open_browser(url):
"""
Call webbrowser.open_new_tab(url) and redirect stdout/stderr to devnull.
@@ -52,6 +54,7 @@ def open_browser(url):
with open(os.devnull, 'ab+', 0) as null:
subprocess.check_call(args, stdout=null, stderr=null)
def clean(string):
"""
Required reading!
@@ -75,6 +78,7 @@ def clean(string):
string = string.encode(encoding, 'replace')
return string
def wrap_text(text, width):
"""
Wrap text paragraphs to the given character width while preserving newlines.
@@ -87,6 +91,7 @@ def wrap_text(text, width):
out.extend(lines)
return out
def strip_textpad(text):
"""
Attempt to intelligently strip excess whitespace from the output of a
@@ -121,6 +126,7 @@ def strip_textpad(text):
out = '\n'.join(stack)
return out
def strip_subreddit_url(permalink):
"""
Strip a subreddit name from the subreddit's permalink.
@@ -131,6 +137,7 @@ def strip_subreddit_url(permalink):
subreddit = permalink.split('/')[4]
return '/r/{}'.format(subreddit)
def humanize_timestamp(utc_timestamp, verbose=False):
"""
Convert a utc timestamp into a human readable relative-time.
@@ -154,4 +161,4 @@ def humanize_timestamp(utc_timestamp, verbose=False):
if months < 12:
return ('%d months ago' % months) if verbose else ('%dmonth' % months)
years = months // 12
return ('%d years ago' % years) if verbose else ('%dyr' % years)
return ('%d years ago' % years) if verbose else ('%dyr' % years)