Skip to content

Commit

Permalink
Reformat all files with black, with --skip-string-normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaudcolas committed May 20, 2019
1 parent e71fed5 commit 3b7f13a
Show file tree
Hide file tree
Showing 554 changed files with 26,636 additions and 13,514 deletions.
21 changes: 17 additions & 4 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@


def pytest_addoption(parser):
parser.addoption('--deprecation', choices=['all', 'pending', 'imminent', 'none'], default='pending')
parser.addoption(
'--deprecation',
choices=['all', 'pending', 'imminent', 'none'],
default='pending',
)
parser.addoption('--postgres', action='store_true')
parser.addoption('--elasticsearch', action='store_true')

Expand All @@ -21,11 +25,17 @@ def pytest_configure(config):
warnings.simplefilter('default', PendingDeprecationWarning)
elif deprecation == 'pending':
# Show all deprecation warnings from wagtail
warnings.filterwarnings('default', category=DeprecationWarning, module=only_wagtail)
warnings.filterwarnings('default', category=PendingDeprecationWarning, module=only_wagtail)
warnings.filterwarnings(
'default', category=DeprecationWarning, module=only_wagtail
)
warnings.filterwarnings(
'default', category=PendingDeprecationWarning, module=only_wagtail
)
elif deprecation == 'imminent':
# Show only imminent deprecation warnings from wagtail
warnings.filterwarnings('default', category=DeprecationWarning, module=only_wagtail)
warnings.filterwarnings(
'default', category=DeprecationWarning, module=only_wagtail
)
elif deprecation == 'none':
# Deprecation warnings are ignored by default
pass
Expand All @@ -41,14 +51,17 @@ def pytest_configure(config):
# Activate a language: This affects HTTP header HTTP_ACCEPT_LANGUAGE sent by
# the Django test client.
from django.utils import translation

translation.activate("en")

from wagtail.tests.settings import MEDIA_ROOT, STATIC_ROOT

shutil.rmtree(STATIC_ROOT, ignore_errors=True)
shutil.rmtree(MEDIA_ROOT, ignore_errors=True)


def pytest_unconfigure(config):
from wagtail.tests.settings import MEDIA_ROOT, STATIC_ROOT

shutil.rmtree(STATIC_ROOT, ignore_errors=True)
shutil.rmtree(MEDIA_ROOT, ignore_errors=True)
35 changes: 18 additions & 17 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

if not on_rtd: # only import and set the theme if we're building docs locally
import sphinx_rtd_theme

html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

Expand All @@ -35,6 +36,7 @@
# be configured
os.environ['DJANGO_SETTINGS_MODULE'] = 'wagtail.tests.settings'
import django

django.setup()

# Use SQLite3 database engine so it doesn't attempt to use psycopg2 on RTD
Expand All @@ -49,10 +51,7 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
]
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx']

if not on_rtd:
extensions.append('sphinxcontrib.spelling')
Expand Down Expand Up @@ -131,7 +130,10 @@

# sphinx.ext.intersphinx settings
intersphinx_mapping = {
'django': ('https://docs.djangoproject.com/en/stable/', 'https://docs.djangoproject.com/en/stable/_objects/')
'django': (
'https://docs.djangoproject.com/en/stable/',
'https://docs.djangoproject.com/en/stable/_objects/',
)
}


Expand All @@ -144,7 +146,6 @@
# html_theme_options = {}



# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
# html_title = None
Expand Down Expand Up @@ -221,10 +222,8 @@
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
Expand All @@ -233,8 +232,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'Wagtail.tex', u'Wagtail Documentation',
u'Torchbox', 'manual'),
('index', 'Wagtail.tex', u'Wagtail Documentation', u'Torchbox', 'manual')
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -262,10 +260,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'wagtail', u'Wagtail Documentation',
[u'Torchbox'], 1)
]
man_pages = [('index', 'wagtail', u'Wagtail Documentation', [u'Torchbox'], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand All @@ -277,9 +272,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'Wagtail', u'Wagtail Documentation',
u'Torchbox', 'Wagtail', 'One line description of project.',
'Miscellaneous'),
(
'index',
'Wagtail',
u'Wagtail Documentation',
u'Torchbox',
'Wagtail',
'One line description of project.',
'Miscellaneous',
)
]

# Documents to append as an appendix to all manuals.
Expand Down
23 changes: 16 additions & 7 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@

def make_parser():
parser = argparse.ArgumentParser()
parser.add_argument('--deprecation', choices=['all', 'pending', 'imminent', 'none'], default='imminent')
parser.add_argument(
'--deprecation',
choices=['all', 'pending', 'imminent', 'none'],
default='imminent',
)
parser.add_argument('--postgres', action='store_true')
parser.add_argument('--elasticsearch2', action='store_true')
parser.add_argument('--elasticsearch5', action='store_true')
Expand All @@ -36,11 +40,17 @@ def runtests():
warnings.simplefilter('default', PendingDeprecationWarning)
elif args.deprecation == 'pending':
# Show all deprecation warnings from wagtail
warnings.filterwarnings('default', category=DeprecationWarning, module=only_wagtail)
warnings.filterwarnings('default', category=PendingDeprecationWarning, module=only_wagtail)
warnings.filterwarnings(
'default', category=DeprecationWarning, module=only_wagtail
)
warnings.filterwarnings(
'default', category=PendingDeprecationWarning, module=only_wagtail
)
elif args.deprecation == 'imminent':
# Show only imminent deprecation warnings from wagtail
warnings.filterwarnings('default', category=DeprecationWarning, module=only_wagtail)
warnings.filterwarnings(
'default', category=DeprecationWarning, module=only_wagtail
)
elif args.deprecation == 'none':
# Deprecation warnings are ignored by default
pass
Expand All @@ -63,9 +73,7 @@ def runtests():
del os.environ['ELASTICSEARCH_URL']

if args.bench:
benchmarks = [
'wagtail.admin.tests.benches',
]
benchmarks = ['wagtail.admin.tests.benches']

argv = [sys.argv[0], 'test', '-v2'] + benchmarks + rest
else:
Expand All @@ -75,6 +83,7 @@ def runtests():
execute_from_command_line(argv)
finally:
from wagtail.tests.settings import STATIC_ROOT, MEDIA_ROOT

shutil.rmtree(STATIC_ROOT, ignore_errors=True)
shutil.rmtree(MEDIA_ROOT, ignore_errors=True)

Expand Down
9 changes: 5 additions & 4 deletions scripts/get-translator-credits.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

authors_by_locale = defaultdict(set)

file_listing = subprocess.Popen('find ../wagtail -iname *.po', shell=True, stdout=subprocess.PIPE)
file_listing = subprocess.Popen(
'find ../wagtail -iname *.po', shell=True, stdout=subprocess.PIPE
)

for file_listing_line in file_listing.stdout:
filename = file_listing_line.strip()
Expand Down Expand Up @@ -35,9 +37,7 @@
raise Exception("No 'Translators:' heading found in %s" % filename)


LANGUAGE_OVERRIDES = {
'tet': 'Tetum',
}
LANGUAGE_OVERRIDES = {'tet': 'Tetum'}


def get_language_name(locale_string):
Expand All @@ -46,6 +46,7 @@ def get_language_name(locale_string):
except KeyError:
return Locale.parse(locale_string).english_name


language_names = [
(get_language_name(locale_string), locale_string)
for locale_string in authors_by_locale.keys()
Expand Down
13 changes: 2 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,12 @@
'Jinja2>=2.8,<3.0',
'boto3>=1.4,<1.5',
'freezegun>=0.3.8',

# For coverage and PEP8 linting
'coverage>=3.7.0',
'flake8>=3.6.0',
'isort==4.2.5',
'flake8-blind-except==0.1.1',
'flake8-print==2.0.2',

# For templates linting
'jinjalint>=0.5',
]
Expand Down Expand Up @@ -102,18 +100,11 @@
'Topic :: Internet :: WWW/HTTP :: Site Management',
],
install_requires=install_requires,
extras_require={
'testing': testing_extras,
'docs': documentation_extras
},
extras_require={'testing': testing_extras, 'docs': documentation_extras},
entry_points="""
[console_scripts]
wagtail=wagtail.bin.wagtail:main
""",
zip_safe=False,
cmdclass={
'sdist': sdist,
'bdist_egg': check_bdist_egg,
'assets': assets,
},
cmdclass={'sdist': sdist, 'bdist_egg': check_bdist_egg, 'assets': assets},
)
39 changes: 28 additions & 11 deletions wagtail/admin/action_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

class ActionMenuItem(metaclass=MediaDefiningClass):
"""Defines an item in the actions drop-up on the page creation/edit view"""

order = 100 # default order index if one is not specified on init
template = 'wagtailadmin/pages/action_menu/menu_item.html'

Expand All @@ -35,16 +36,18 @@ def is_shown(self, request, context):
'parent_page' (if view = 'create') = the parent page of the page being created
'user_page_permissions' = a UserPagePermissionsProxy for the current user, to test permissions against
"""
return (context['view'] == 'create' or not context['page'].locked)
return context['view'] == 'create' or not context['page'].locked

def get_context(self, request, parent_context):
"""Defines context for the template, overridable to use more data"""
context = parent_context.copy()
context.update({
context.update(
{
'label': self.label,
'url': self.get_url(request, context),
'name': self.name,
})
}
)
return context

def get_url(self, request, context):
Expand All @@ -61,16 +64,22 @@ class PublishMenuItem(ActionMenuItem):

def is_shown(self, request, context):
if context['view'] == 'create':
return context['user_page_permissions'].for_page(context['parent_page']).can_publish_subpage()
return (
context['user_page_permissions']
.for_page(context['parent_page'])
.can_publish_subpage()
)
else: # view == 'edit' or 'revisions_revert'
return (
not context['page'].locked
and context['user_page_permissions'].for_page(context['page']).can_publish()
and context['user_page_permissions']
.for_page(context['page'])
.can_publish()
)

def get_context(self, request, parent_context):
context = super().get_context(request, parent_context)
context['is_revision'] = (context['view'] == 'revisions_revert')
context['is_revision'] = context['view'] == 'revisions_revert'
return context


Expand All @@ -95,7 +104,9 @@ def is_shown(self, request, context):
return (
context['view'] == 'edit'
and not context['page'].locked
and context['user_page_permissions'].for_page(context['page']).can_unpublish()
and context['user_page_permissions']
.for_page(context['page'])
.can_unpublish()
)

def get_url(self, request, context):
Expand Down Expand Up @@ -146,7 +157,9 @@ class PageActionMenu:
def __init__(self, request, **kwargs):
self.request = request
self.context = kwargs
self.context['user_page_permissions'] = UserPagePermissionsProxy(self.request.user)
self.context['user_page_permissions'] = UserPagePermissionsProxy(
self.request.user
)

self.menu_items = [
menu_item
Expand All @@ -160,13 +173,17 @@ def __init__(self, request, **kwargs):
hook(self.menu_items, self.request, self.context)

def render_html(self):
return render_to_string(self.template, {
return render_to_string(
self.template,
{
'show_menu': bool(self.menu_items),
'rendered_menu_items': [
menu_item.render_html(self.request, self.context)
for menu_item in self.menu_items
]
}, request=self.request)
],
},
request=self.request,
)

@cached_property
def media(self):
Expand Down

0 comments on commit 3b7f13a

Please sign in to comment.