aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojciech Polak <polak@gnu.org>2014-05-27 20:12:31 +0200
committerWojciech Polak <polak@gnu.org>2014-05-27 20:12:46 +0200
commitbc4a3714123bae0b8f95f8fb08d55a79c334c4cc (patch)
tree275cfad03a30ac3f0b5a13d35e7692e31df9d9ab
parenta90920c8d66e49f57a2adf6bea33b2563b03639f (diff)
downloadglifestream-bc4a3714123bae0b8f95f8fb08d55a79c334c4cc.tar.gz
glifestream-bc4a3714123bae0b8f95f8fb08d55a79c334c4cc.tar.bz2
Minor PEP8 fixes.
-rw-r--r--glifestream/apis/fb.py2
-rw-r--r--glifestream/apis/friendfeed.py4
-rw-r--r--glifestream/apis/twitter.py4
-rw-r--r--glifestream/apis/webfeed.py3
-rw-r--r--glifestream/filters/expand.py20
-rw-r--r--glifestream/gauth/gls_oauth.py1
-rw-r--r--glifestream/gauth/gls_openid.py2
-rw-r--r--glifestream/gauth/views.py2
-rw-r--r--glifestream/stream/admin.py1
-rw-r--r--glifestream/stream/media.py2
-rw-r--r--glifestream/stream/templatetags/media.py2
-rw-r--r--glifestream/stream/views.py12
-rw-r--r--glifestream/urls.py2
-rw-r--r--glifestream/usettings/views.py48
14 files changed, 57 insertions, 48 deletions
diff --git a/glifestream/apis/fb.py b/glifestream/apis/fb.py
index f0cea78..9915ff9 100644
--- a/glifestream/apis/fb.py
+++ b/glifestream/apis/fb.py
@@ -118,7 +118,7 @@ class API:
content += '<a href="%s" rel="nofollow">' \
'<img src="%s" alt="thumbnail" /></a> ' \
% (ent['link'], media.save_image(ent['picture'],
- downscale=True))
+ downscale=True))
if 'description' in ent:
content += '<div class="fb-description">%s</div>' % \
diff --git a/glifestream/apis/friendfeed.py b/glifestream/apis/friendfeed.py
index 8156cbd..82ab1bb 100644
--- a/glifestream/apis/friendfeed.py
+++ b/glifestream/apis/friendfeed.py
@@ -29,8 +29,8 @@ except ImportError:
import simplejson as json
OAUTH_REQUEST_TOKEN_URL = 'https://friendfeed.com/account/oauth/request_token'
-OAUTH_AUTHORIZE_URL = 'https://friendfeed.com/account/oauth/authorize'
-OAUTH_ACCESS_TOKEN_URL = 'https://friendfeed.com/account/oauth/access_token'
+OAUTH_AUTHORIZE_URL = 'https://friendfeed.com/account/oauth/authorize'
+OAUTH_ACCESS_TOKEN_URL = 'https://friendfeed.com/account/oauth/access_token'
class API:
diff --git a/glifestream/apis/twitter.py b/glifestream/apis/twitter.py
index 23326cc..b41c680 100644
--- a/glifestream/apis/twitter.py
+++ b/glifestream/apis/twitter.py
@@ -27,8 +27,8 @@ except ImportError:
import simplejson as json
OAUTH_REQUEST_TOKEN_URL = 'https://api.twitter.com/oauth/request_token'
-OAUTH_AUTHORIZE_URL = 'https://api.twitter.com/oauth/authorize'
-OAUTH_ACCESS_TOKEN_URL = 'https://api.twitter.com/oauth/access_token'
+OAUTH_AUTHORIZE_URL = 'https://api.twitter.com/oauth/authorize'
+OAUTH_ACCESS_TOKEN_URL = 'https://api.twitter.com/oauth/access_token'
class API:
diff --git a/glifestream/apis/webfeed.py b/glifestream/apis/webfeed.py
index 534fdf0..61c8c02 100644
--- a/glifestream/apis/webfeed.py
+++ b/glifestream/apis/webfeed.py
@@ -1,4 +1,4 @@
-# gLifestream Copyright (C) 2009, 2010 Wojciech Polak
+# gLifestream Copyright (C) 2009, 2010, 2014 Wojciech Polak
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
@@ -14,7 +14,6 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
import feedparser
-from django.conf import settings
from glifestream.utils import httpclient
from glifestream.utils.time import mtime, now
from glifestream.utils.html import strip_script
diff --git a/glifestream/filters/expand.py b/glifestream/filters/expand.py
index eae61a1..54369d9 100644
--- a/glifestream/filters/expand.py
+++ b/glifestream/filters/expand.py
@@ -1,4 +1,4 @@
-# gLifestream Copyright (C) 2009, 2010, 2011, 2013 Wojciech Polak
+# gLifestream Copyright (C) 2009, 2010, 2011, 2013, 2014 Wojciech Polak
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
@@ -14,7 +14,6 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
import re
-import urllib
import hashlib
from django.conf import settings
from django.utils.html import strip_tags
@@ -26,6 +25,7 @@ from glifestream.utils import httpclient, oembed
# Short link services
#
+
def __su_subs(m):
try:
res = httpclient.head(m.group(1), m.group(2))
@@ -37,14 +37,15 @@ def __su_subs(m):
def shorturls(text):
"""Expand short URLs."""
return re.sub(r'http://(tinyurl\.com|bit\.ly|goo\.gl|t\.co|is\.gd'
- '|ur1\.ca|2tu\.us|ff\.im|post\.ly|awe\.sm|lnk\.ms|pic\.gd'
- '|tl\.gd|youtu\.be|tiny\.cc|ow\.ly|j\.mp|url4\.eu'
- ')(/[\-\w]+)', __su_subs, smart_unicode(text))
+ r'|ur1\.ca|2tu\.us|ff\.im|post\.ly|awe\.sm|lnk\.ms|pic\.gd'
+ r'|tl\.gd|youtu\.be|tiny\.cc|ow\.ly|j\.mp|url4\.eu'
+ r')(/[\-\w]+)', __su_subs, smart_unicode(text))
#
# Short image services
#
+
def __gen_tai(link, img_src):
return '<p class="thumbnails"><a href="%s" rel="nofollow"><img src="%s" alt="thumbnail" /></a></p>' % (link, img_src)
@@ -115,6 +116,7 @@ def imgloc(s):
# Video services
#
+
def __sv_youtube(m):
if m.start() > 0 and m.string[m.start() - 1] == '"':
return m.group(0)
@@ -221,6 +223,7 @@ def videolinks(s):
# Audio services
#
+
def __sa_ogg(m):
link = m.group(1)
name = m.group(2)
@@ -254,10 +257,10 @@ from cgi import parse_qsl
def __parse_qs(qs, keep_blank_values=0, strict_parsing=0):
- dict = {}
+ d = {}
for name, value in parse_qsl(qs, keep_blank_values, strict_parsing):
- dict[name] = value
- return dict
+ d[name] = value
+ return d
def __sm_googlemaps(m):
@@ -287,6 +290,7 @@ def maplinks(s):
# Summary
#
+
def shorts(s):
s = shorturls(s)
return shortpics(s)
diff --git a/glifestream/gauth/gls_oauth.py b/glifestream/gauth/gls_oauth.py
index 76bf6d0..618a60a 100644
--- a/glifestream/gauth/gls_oauth.py
+++ b/glifestream/gauth/gls_oauth.py
@@ -25,6 +25,7 @@ except ImportError:
class Client:
+
def __init__(self, service, identifier=None, secret=None,
callback_url=None):
if not oauth:
diff --git a/glifestream/gauth/gls_openid.py b/glifestream/gauth/gls_openid.py
index fd03314..9ecac5a 100644
--- a/glifestream/gauth/gls_openid.py
+++ b/glifestream/gauth/gls_openid.py
@@ -74,7 +74,7 @@ def __get_store():
mstore = getattr(settings, 'OPENID_STORE',
'openid.store.filestore.FileOpenIDStore')
i = mstore.rfind('.')
- module, attr = mstore[:i], mstore[i+1:]
+ module, attr = mstore[:i], mstore[i + 1:]
mod = __import__(module, {}, {}, [attr])
cls = getattr(mod, attr)
diff --git a/glifestream/gauth/views.py b/glifestream/gauth/views.py
index 833cdfb..1f0bb06 100644
--- a/glifestream/gauth/views.py
+++ b/glifestream/gauth/views.py
@@ -150,7 +150,7 @@ def xrds(request, **args):
"""
body = xrds_tpl % (request.build_absolute_uri('openid'),
request.build_absolute_uri(
- urlresolvers.reverse('glifestream.usettings.views.openid')))
+ urlresolvers.reverse('glifestream.usettings.views.openid')))
res = HttpResponse(body, content_type='application/xrds+xml')
res['X-Robots-Tag'] = 'noindex'
return res
diff --git a/glifestream/stream/admin.py b/glifestream/stream/admin.py
index e8d4ec5..24aa689 100644
--- a/glifestream/stream/admin.py
+++ b/glifestream/stream/admin.py
@@ -63,6 +63,7 @@ class EntryAdmin (admin.ModelAdmin):
class AdminImageWidget (AdminFileWidget):
+
def render(self, name, value, attrs=None):
output = []
file_name = str(value)
diff --git a/glifestream/stream/media.py b/glifestream/stream/media.py
index 6b67f24..780b562 100644
--- a/glifestream/stream/media.py
+++ b/glifestream/stream/media.py
@@ -121,7 +121,7 @@ def downsave_uploaded_image(file):
def extract_and_register(entry):
- for hash in re.findall('\[GLS-THUMBS\]/([a-f0-9]{40})', entry.content):
+ for hash in re.findall(r'\[GLS-THUMBS\]/([a-f0-9]{40})', entry.content):
md = Media(entry=entry)
md.file.name = get_thumb_info(hash)['rel']
try:
diff --git a/glifestream/stream/templatetags/media.py b/glifestream/stream/templatetags/media.py
index 2e8299f..d6c532b 100644
--- a/glifestream/stream/templatetags/media.py
+++ b/glifestream/stream/templatetags/media.py
@@ -23,6 +23,7 @@ register = Library()
class MediaUrl (template.Node):
+
def render(self, ctx):
url = settings.MEDIA_URL
if 'is_secure' in ctx and ctx['is_secure']:
@@ -37,6 +38,7 @@ def static(parser, token):
class MediaUrlHash (template.Node):
+
def __init__(self, path):
self.path = path
self.hash = None
diff --git a/glifestream/stream/views.py b/glifestream/stream/views.py
index 360726d..96d63b6 100644
--- a/glifestream/stream/views.py
+++ b/glifestream/stream/views.py
@@ -28,7 +28,6 @@ from django.shortcuts import render_to_response
from django.template.loader import render_to_string
from django.template.defaultfilters import fix_ampersands
from django.template.defaultfilters import truncatewords
-from django.contrib.auth.decorators import login_required
from django.utils.translation import ugettext as _
from django.utils.html import escape, strip_spaces_between_tags
from django.views.decorators.cache import never_cache
@@ -101,7 +100,7 @@ def index(request, **args):
page['backtime'] = False
page['title'] = dt
page['subtitle'] = _(
- 'You are currently browsing the archive for %s') % ('<b>'+dt+'</b>')
+ 'You are currently browsing the archive for %s') % ('<b>' + dt + '</b>')
page['robots'] = 'noindex'
if page['backtime']:
@@ -371,10 +370,10 @@ def index(request, **args):
'next': page['start'],
'stream': strip_spaces_between_tags(
render_to_string('stream-pure.html',
- {'entries': entries,
- 'page': page,
- 'authed': authed,
- 'friend': friend})),
+ {'entries': entries,
+ 'page': page,
+ 'authed': authed,
+ 'friend': friend})),
}
if 'nextpage' in page:
d['next'] = page['nextpage']
@@ -477,6 +476,7 @@ def page_not_found(request, **args):
# XHR API
#
+
def api(request, **args):
cmd = args.get('cmd', '')
entry = request.POST.get('entry', None)
diff --git a/glifestream/urls.py b/glifestream/urls.py
index da6928b..f6c7ce8 100644
--- a/glifestream/urls.py
+++ b/glifestream/urls.py
@@ -32,7 +32,7 @@ urlpatterns = patterns(
(r'^public/$', sv.index, {'ctx': 'public'}, 'public'),
(r'^public/(?P<year>\d{4})/$', sv.index, {
- 'ctx': 'public'}),
+ 'ctx': 'public'}),
(r'^public/(?P<year>\d{4})/(?P<month>\d{2})/$', sv.index,
{'ctx': 'public'}),
(r'^public/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$', sv.index,
diff --git a/glifestream/usettings/views.py b/glifestream/usettings/views.py
index d040b80..5c76944 100644
--- a/glifestream/usettings/views.py
+++ b/glifestream/usettings/views.py
@@ -67,6 +67,7 @@ def services(request, **args):
class ListForm (ModelForm):
+
class Meta:
model = List
exclude = ('user',)
@@ -449,6 +450,7 @@ def _import_service(url, title, cls='webfeed'):
# XHR API
#
+
def api(request, **args):
authed = request.user.is_authenticated() and request.user.is_staff
if not authed:
@@ -571,8 +573,8 @@ def api(request, **args):
v = 'user' if s['url'] else 'home'
s['fields'].append({'type': 'select', 'name': 'timeline',
'options': (('user', _('User timeline')),
- ('home', _('Home timeline'))),
- 'value': v, 'label': _('Timeline')})
+ ('home', _('Home timeline'))),
+ 'value': v, 'label': _('Timeline')})
s['fields'].append({'type': 'text', 'name': 'url',
'value': s['url'], 'label': _('ID/Username'),
'deps': {'timeline': 'user'}})
@@ -594,9 +596,9 @@ def api(request, **args):
s['fields'].append({'type': 'select', 'name': 'auth',
'options': (('none', _('none')),
- ('basic', _('Basic')),
- ('oauth', _('OAuth'))),
- 'value': v, 'label': _('Authorization')})
+ ('basic', _('Basic')),
+ ('oauth', _('OAuth'))),
+ 'value': v, 'label': _('Authorization')})
if 'id' in s:
s['fields'].append({'type': 'link', 'name': 'oauth_conf',
@@ -607,42 +609,42 @@ def api(request, **args):
s['fields'].append({'type': 'text', 'name': 'basic_user',
'value': basic_user,
'label': _('Basic username'),
- 'deps': {'auth': 'basic'}})
+ 'deps': {'auth': 'basic'}})
s['fields'].append({'type': 'password', 'name': 'basic_pass',
- 'value': '', 'label': _('Basic password'),
- 'deps': {'auth': 'basic'}})
+ 'value': '', 'label': _('Basic password'),
+ 'deps': {'auth': 'basic'}})
if s['api'] == 'fb':
s['fields'].append({'type': 'text', 'name': 'access_token',
- 'value': s['creds'],
- 'label': _('Access token')})
+ 'value': s['creds'],
+ 'label': _('Access token')})
s['need_fb_accesstoken'] = _('get')
if s['api'] in ('webfeed', 'flickr', 'youtube', 'vimeo'):
s['fields'].append({'type': 'select', 'name': 'display',
- 'options': (('both', _('Title and Contents')),
- ('content', _('Contents only')),
- ('title', _('Title only'))),
- 'value': s['display'],
- 'label': _("Display entries'")})
+ 'options': (('both', _('Title and Contents')),
+ ('content', _('Contents only')),
+ ('title', _('Title only'))),
+ 'value': s['display'],
+ 'label': _("Display entries'")})
s['fields'].append({'type': 'checkbox', 'name': 'public',
- 'checked': s['public'], 'label': _('Public'),
- 'hint': _('Public services are visible to anyone.')})
+ 'checked': s['public'], 'label': _('Public'),
+ 'hint': _('Public services are visible to anyone.')})
s['fields'].append({'type': 'checkbox', 'name': 'home',
- 'checked': s['home'], 'label': _('Home'),
- 'hint': _('If unchecked, this stream will be still active, but hidden and thus visible only via custom lists.')})
+ 'checked': s['home'], 'label': _('Home'),
+ 'hint': _('If unchecked, this stream will be still active, but hidden and thus visible only via custom lists.')})
if s['api'] != 'selfposts':
s['fields'].append({'type': 'checkbox', 'name': 'active',
- 'checked': s['active'], 'label': _('Active'),
- 'hint': _('If not active, this service will not be further updated.')})
+ 'checked': s['active'], 'label': _('Active'),
+ 'hint': _('If not active, this service will not be further updated.')})
if 'creds' in s:
del s['creds']
- s['action'] = request.build_absolute_uri();
+ s['action'] = request.build_absolute_uri()
s['save'] = _('Save')
s['cancel'] = _('Cancel')
@@ -654,7 +656,7 @@ def api(request, **args):
try:
service = Service.objects.get(id=id)
mod = __import__('glifestream.apis.%s' %
- service.api, {}, {}, ['API'])
+ service.api, {}, {}, ['API'])
mod_api = getattr(mod, 'API')
api = mod_api(service, False, False)
api.run()

Return to:

Send suggestions and report system problems to the System administrator.