Skip to content

Commit

Permalink
pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
tino097 committed Sep 26, 2017
1 parent 9ba6f08 commit 4207cfe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
18 changes: 9 additions & 9 deletions ckan/lib/helpers.py
Expand Up @@ -20,19 +20,16 @@
import uuid

from paste.deploy import converters
from webhelpers.html import HTML, literal, tags, tools
from webhelpers.html import HTML, literal, tags
from webhelpers import paginate
import webhelpers.text as whtext
import webhelpers.date as date
from markdown import markdown
from bleach import clean as clean_html, ALLOWED_TAGS, ALLOWED_ATTRIBUTES
from pylons import url as _pylons_default_url
from ckan.common import config, is_flask_request
from flask import redirect as _flask_redirect
from ckan.common import config
from routes import redirect_to as _routes_redirect_to
from routes import url_for as _routes_default_url_for
from flask import url_for as _flask_default_url_for
from werkzeug.routing import BuildError as FlaskRouteBuildError
import i18n

import ckan.exceptions
Expand Down Expand Up @@ -180,10 +177,7 @@ def redirect_to(*args, **kw):
if _url.startswith('/'):
_url = str(config['ckan.site_url'].rstrip('/') + _url)

if is_flask_request():
return _flask_redirect(_url)
else:
return _routes_redirect_to(_url)
return _routes_redirect_to(_url)


@maintain.deprecated('h.url is deprecated please use h.url_for')
Expand Down Expand Up @@ -509,6 +503,7 @@ def pop_messages(self):
def are_there_messages(self):
return bool(session.get(self.session_key))


flash = _Flash()
# this is here for backwards compatability
_flash = flash
Expand Down Expand Up @@ -1068,6 +1063,7 @@ def linked_gravatar(email_hash, size=100, default=None):
'%s</a>' % gravatar(email_hash, size, default)
)


_VALID_GRAVATAR_DEFAULTS = ['404', 'mm', 'identicon', 'monsterid',
'wavatar', 'retro']

Expand Down Expand Up @@ -1498,6 +1494,7 @@ def process_names(items):
items.append(item)
return items


# these are the types of objects that can be followed
_follow_objects = ['dataset', 'user', 'group']

Expand Down Expand Up @@ -1826,6 +1823,7 @@ def get_request_param(parameter_name, default=None):
searches. '''
return request.params.get(parameter_name, default)


# find all inner text of html eg `<b>moo</b>` gets `moo` but not of <a> tags
# as this would lead to linkifying links if they are urls.
RE_MD_GET_INNER_HTML = re.compile(
Expand Down Expand Up @@ -2135,6 +2133,7 @@ def SI_number_span(number):
+ '">')
return output + formatters.localised_SI_number(number) + literal('</span>')


# add some formatter functions
localised_number = formatters.localised_number
localised_SI_number = formatters.localised_SI_number
Expand Down Expand Up @@ -2235,6 +2234,7 @@ def get_site_statistics():
logic.get_action('organization_list')({}, {}))
return stats


_RESOURCE_FORMATS = None


Expand Down
11 changes: 4 additions & 7 deletions ckan/tests/test_none_root.py
@@ -1,19 +1,16 @@
# encoding: utf-8

from ckan.common import config
from pylons import config
import ckan.plugins as p
import ckan.config.middleware as middleware
import webtest
import ckan.tests.helpers as helpers


class TestNoneRootCKAN():
@helpers.change_config(u'ckan.root_path', u'/data/{{LANG}}')
def test_resource_url(self):
wsgiapp = middleware.make_app(config[u'global_conf'], **config)
app = webtest.TestApp(wsgiapp)
app = helpers._get_test_app()

p.load(u'example_theme_v15_fanstatic')
content = app.get(u'/en/base.html')
assert u'example_theme.css' in content
assert u'example_theme.min.css' in content
assert u'href="/data/fanstatic/example_theme' in content
p.unload(u'example_theme_v15_fanstatic')
4 changes: 2 additions & 2 deletions ckanext/example_igroupform/tests/test_controllers.py
Expand Up @@ -136,7 +136,7 @@ def test_save(self):
response = submit_and_follow(app, form, env, 'save')
# check correct redirect
assert_equal(response.req.url,
'http://localhost/%s/saved' % custom_group_type)
'http://test.ckan.net/%s/saved' % custom_group_type)
# check saved ok
group = model.Group.by_name(u'saved')
assert_equal(group.title, u'')
Expand Down Expand Up @@ -172,7 +172,7 @@ def test_save(self):
response = submit_and_follow(app, form, env, 'save')
# check correct redirect
assert_equal(response.req.url,
'http://localhost/%s/saved' % group_type)
'http://test.ckan.net/%s/saved' % group_type)
# check saved ok
group = model.Group.by_name(u'saved')
assert_equal(group.title, u'')
Expand Down

0 comments on commit 4207cfe

Please sign in to comment.