Permalink
Browse files

Removed conversions to lists for generators

  • Loading branch information...
atombrella authored and benjaoming committed Nov 22, 2017
1 parent 274b09c commit 697b66e953d921b42851db3831080278bcdced00
@@ -159,9 +159,7 @@ def delete_subtree(self):
@classmethod
def root(cls):
site = Site.objects.get_current()
root_nodes = list(
cls.objects.root_nodes().filter(site=site).select_related_common()
)
root_nodes = cls.objects.root_nodes().filter(site=site).select_related_common()
# We fetch the nodes as a list and use len(), not count() because we need
# to get the result out anyway. This only takes one sql query
no_paths = len(root_nodes)
@@ -90,8 +90,7 @@ def __init__(self, *args, **kwargs):
super(AttachmentArchiveForm, self).__init__(*args, **kwargs)
ordered_fields = ['unzip_archive', 'file']
self.fields.keyOrder = ordered_fields + [k
for k in list(
self.fields.keys())
for k in self.fields.keys()
if k not in ordered_fields]
def clean_file(self):
@@ -243,7 +243,7 @@ def run(self, doc): # noqa
if prettify:
prettify.run(div)
toc = self.markdown.serializer(div)
for pp in list(self.markdown.postprocessors.values()):
for pp in self.markdown.postprocessors.values():
toc = pp.run(toc)
self.markdown.toc = toc
View
@@ -227,7 +227,7 @@ def get_article_path_urls(self):
@staticmethod
def get_plugin_urls():
urlpatterns = []
for plugin in list(registry.get_plugins().values()):
for plugin in registry.get_plugins().values():
slug = getattr(plugin, 'slug', None)
if slug:
article_urlpatterns = plugin.urlpatterns.get('article', [])
@@ -295,8 +295,7 @@ def get_sidebar_form_classes(self):
def get(self, request, *args, **kwargs):
# Generate sidebar forms
self.sidebar_forms = []
for form_id, (plugin, Form) in list(
self.get_sidebar_form_classes().items()):
for form_id, (plugin, Form) in self.get_sidebar_form_classes().items():
if Form:
form = Form(self.article, self.request.user)
setattr(form, 'form_id', form_id)
@@ -308,8 +307,7 @@ def get(self, request, *args, **kwargs):
def post(self, request, *args, **kwargs):
# Generate sidebar forms
self.sidebar_forms = []
for form_id, (plugin, Form) in list(
self.get_sidebar_form_classes().items()):
for form_id, (plugin, Form) in self.get_sidebar_form_classes().items():
if Form:
if form_id == self.request.GET.get('f', None):
form = Form(

0 comments on commit 697b66e

Please sign in to comment.