Permalink
Browse files

fixed pyflakes issues

  • Loading branch information...
ojii committed Mar 2, 2014
1 parent 35f48bb commit 0d7a8bc1b6b4c768833a28bc6ca957e5686e51dc
Showing with 705 additions and 719 deletions.
  1. +2 −2 cms/admin/__init__.py
  2. +4 −5 cms/admin/pageadmin.py
  3. +1 −2 cms/admin/permissionadmin.py
  4. +2 −3 cms/admin/views.py
  5. +5 −16 cms/api.py
  6. +4 −5 cms/appresolver.py
  7. +15 −12 cms/cms_toolbar.py
  8. +22 −15 cms/compat_forms.py
  9. +5 −3 cms/extensions/__init__.py
  10. +7 −3 cms/management/commands/subcommands/uninstall.py
  11. +10 −7 cms/menu.py
  12. +9 −14 cms/models/__init__.py
  13. +10 −10 cms/models/pagemodel.py
  14. +2 −3 cms/models/permissionmodels.py
  15. +14 −7 cms/models/placeholdermodel.py
  16. +13 −11 cms/plugin_pool.py
  17. +1 −1 cms/publisher/__init__.py
  18. +1 −1 cms/signals/permissions.py
  19. +1 −1 cms/sitemaps/__init__.py
  20. +2 −2 cms/templatetags/cms_tags.py
  21. +1 −0 cms/test_utils/compat.py
  22. +14 −15 cms/test_utils/fixtures/menus.py
  23. +1 −1 cms/test_utils/project/brokenpluginapp/cms_plugins.py
  24. +1 −1 cms/test_utils/project/cms_urls_for_apphook_tests.py
  25. +1 −1 cms/test_utils/project/customuserapp/models.py
  26. +2 −1 cms/test_utils/project/emailuserapp/admin.py
  27. +7 −6 cms/test_utils/project/emailuserapp/forms.py
  28. +8 −3 cms/test_utils/project/emailuserapp/models.py
  29. +1 −1 cms/test_utils/project/noadmin_urls.py
  30. +1 −2 cms/test_utils/project/nonroot_urls.py
  31. +1 −1 cms/test_utils/project/placeholderapp/urls.py
  32. +1 −5 cms/test_utils/project/placeholderapp/urls_multi.py
  33. +0 −1 cms/test_utils/project/pluginapp/plugins/meta/__init__.py
  34. +6 −1 cms/test_utils/project/pluginapp/plugins/meta/cms_plugins.py
  35. +1 −1 cms/test_utils/project/sampleapp/ns_urls.py
  36. +1 −1 cms/test_utils/project/sampleapp/urls.py
  37. +1 −1 cms/test_utils/project/sampleapp/urls2.py
  38. +1 −1 cms/test_utils/project/sampleapp/urls_extra.py
  39. +1 −2 cms/test_utils/project/second_urls_for_apphook_tests.py
  40. +1 −1 cms/test_utils/project/third_cms_urls_for_apphook_tests.py
  41. +1 −2 cms/test_utils/project/third_urls_for_apphook_tests.py
  42. +1 −2 cms/test_utils/project/urls_for_apphook_tests.py
  43. +0 −5 cms/test_utils/project/urls_no18n.py
  44. +0 −1 cms/test_utils/runners.py
  45. +127 −129 cms/tests/admin.py
  46. +1 −1 cms/tests/api.py
  47. +19 −17 cms/tests/apphooks.py
  48. +7 −4 cms/tests/check.py
  49. +11 −11 cms/tests/extensions.py
  50. +4 −3 cms/tests/forms.py
  51. +7 −13 cms/tests/frontend.py
  52. +2 −2 cms/tests/i18n.py
  53. +11 −12 cms/tests/management.py
  54. +10 −8 cms/tests/menu.py
  55. +6 −6 cms/tests/multilingual.py
  56. +8 −17 cms/tests/nested_plugins.py
  57. +3 −3 cms/tests/no_i18n.py
  58. +4 −6 cms/tests/nonroot.py
  59. +4 −4 cms/tests/page.py
  60. +65 −70 cms/tests/placeholder.py
  61. +91 −99 cms/tests/plugins.py
  62. +2 −2 cms/tests/po.py
  63. +7 −10 cms/tests/publisher.py
  64. +5 −5 cms/tests/rendering.py
  65. +9 −13 cms/tests/reversion_tests.py
  66. +4 −4 cms/tests/site.py
  67. +1 −2 cms/tests/sitemap.py
  68. +6 −4 cms/tests/staticfiles.py
  69. +14 −18 cms/tests/templatetags.py
  70. +15 −15 cms/tests/toolbar.py
  71. +9 −9 cms/tests/views.py
  72. +8 −5 cms/utils/__init__.py
  73. +8 −5 cms/utils/admin.py
  74. +8 −7 cms/utils/check.py
  75. +1 −1 cms/utils/compat/dj.py
  76. +1 −1 cms/utils/compat/string_io.py
  77. +2 −2 cms/utils/compat/type_checks.py
  78. +4 −1 cms/utils/compat/urls.py
  79. +2 −1 cms/utils/helpers.py
  80. +3 −4 cms/utils/page.py
  81. +14 −11 cms/utils/plugins.py
  82. +18 −12 cms/views.py
  83. +0 −1 menus/base.py
  84. +0 −2 menus/templatetags/i18n_compat.py
  85. +1 −0 test_requirements/requirements_base.txt
View
@@ -3,10 +3,10 @@
import cms.admin.useradmin
import cms.admin.permissionadmin
import cms.admin.settingsadmin
-import cms.admin.static_placeholder
+import cms.admin.static_placeholder # nopyflakes
# Piggyback off admin.autodiscover() to discover cms plugins
from cms import plugin_pool
from cms.apphook_pool import apphook_pool
plugin_pool.plugin_pool.discover_plugins()
-apphook_pool.discover_apps()
+apphook_pool.discover_apps()
View
@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
from functools import wraps
import sys
-from cms.admin.placeholderadmin import PlaceholderAdminMixin
-from cms.plugin_pool import plugin_pool
-from django.contrib.admin.helpers import AdminForm
import django
+from django.contrib.admin.helpers import AdminForm
from django.conf import settings
from django.contrib import admin, messages
from django.contrib.admin.models import LogEntry, CHANGE
@@ -24,6 +22,8 @@
from django.utils.decorators import method_decorator
from django.views.decorators.http import require_POST
+from cms.admin.placeholderadmin import PlaceholderAdminMixin
+from cms.plugin_pool import plugin_pool
from cms.utils.conf import get_cms_setting
from cms.utils.compat.dj import force_unicode
from cms.utils.compat.urls import unquote
@@ -37,10 +37,9 @@
from cms.models import Page, Title, CMSPlugin, PagePermission, EmptyTitle, GlobalPagePermission, \
titlemodels, StaticPlaceholder
from cms.models.managers import PagePermissionsPermissionManager
-from cms.utils import helpers, moderator, permissions, get_language_from_request, admin as admin_utils, copy_plugins
+from cms.utils import helpers, permissions, get_language_from_request, admin as admin_utils, copy_plugins
from cms.utils.i18n import get_language_list, get_language_tuple, get_language_object, force_language
from cms.utils.admin import jsonify_request
-
from cms.utils.permissions import has_global_page_permission, has_generic_permission
from cms.utils.plugins import current_site
from cms.utils.compat import DJANGO_1_4
@@ -9,7 +9,6 @@
from cms.utils.permissions import get_user_permission_level
from cms.compat import get_user_model
from django.contrib import admin
-from django.contrib.auth.models import User
from django.utils.translation import ugettext as _
PERMISSION_ADMIN_INLINES = []
@@ -159,7 +158,7 @@ def _has_change_permissions_permission(self, request):
permission on some page.
"""
try:
- user_level = get_user_permission_level(request.user)
+ get_user_permission_level(request.user)
except NoPermissionsException:
return False
return True
View
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-from cms.models import Page, Title, CMSPlugin, Placeholder
-from cms.utils import get_language_from_request
from django.http import Http404
from django.shortcuts import get_object_or_404
+from cms.models import Page, Title, CMSPlugin, Placeholder
+
def revert_plugins(request, version_id, obj):
from reversion.models import Version
@@ -15,7 +15,6 @@ def revert_plugins(request, version_id, obj):
titles = []
others = []
page = obj
- lang = get_language_from_request(request)
for rev in revs:
obj = rev.object
if obj.__class__ == Placeholder:
View
@@ -7,16 +7,12 @@
calling these methods!
"""
import datetime
-from cms.utils import copy_plugins
-from cms.utils.compat.type_checks import string_types
-from cms.utils.conf import get_cms_setting
-from django.core.exceptions import PermissionDenied, ValidationError, FieldError
-from cms.utils.i18n import get_language_list
-from cms.compat import get_user_model
from django.contrib.sites.models import Site
+from django.core.exceptions import FieldError
+from django.core.exceptions import PermissionDenied
+from django.core.exceptions import ValidationError
from django.template.defaultfilters import slugify
-from menus.menu_pool import menu_pool
from cms.admin.forms import save_permissions
from cms.app_base import CMSApp
@@ -30,20 +26,12 @@
from cms.models.titlemodels import Title
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
+from cms.utils import copy_plugins
from cms.utils.compat.type_checks import string_types
from cms.utils.conf import get_cms_setting
from cms.utils.i18n import get_language_list
from cms.utils.permissions import _thread_locals
-from django.conf import settings
-from django.contrib.sites.models import Site
-from django.core.exceptions import PermissionDenied, ValidationError
-from django.db.models import Max
-from django.template.defaultfilters import slugify
from menus.menu_pool import menu_pool
-import datetime
-
-
-
#===============================================================================
@@ -58,6 +46,7 @@
# Helpers/Internals
#===============================================================================
+
def _generate_valid_slug(source, parent, language):
"""
Generate a valid slug for a page from source for the given language.
View
@@ -23,7 +23,6 @@ def clear_app_resolvers():
APP_RESOLVERS = []
-
def applications_page_check(request, current_page=None, path=None):
"""Tries to find if given path was resolved over application.
Applications have higher priority than other cms pages.
@@ -159,14 +158,14 @@ def get_patterns_for_title(path, title):
Returns a list of url objects.
"""
app = apphook_pool.get_apphook(title.page.application_urls)
- patterns = []
+ url_patterns = []
for pattern_list in get_app_urls(app.urls):
if path and not path.endswith('/'):
path += '/'
page_id = title.page.id
- patterns += recurse_patterns(path, pattern_list, page_id)
- patterns = _flatten_patterns(patterns)
- return patterns
+ url_patterns += recurse_patterns(path, pattern_list, page_id)
+ url_patterns = _flatten_patterns(url_patterns)
+ return url_patterns
def get_app_patterns():
View
@@ -1,22 +1,25 @@
# -*- coding: utf-8 -*-
-import urllib
-from cms.compat import user_model_label
+from django.conf import settings
+from django.core.urlresolvers import reverse
+from django.utils.translation import ugettext_lazy as _
+from django.contrib import admin
+from django.contrib.auth.models import User
+from django.contrib.sites.models import Site
+
from cms.api import get_page_draft
-from cms.constants import TEMPLATE_INHERITANCE_MAGIC, RIGHT
+from cms.compat import user_model_label
+from cms.constants import TEMPLATE_INHERITANCE_MAGIC
from cms.exceptions import LanguageError
from cms.models import Title
from cms.toolbar.items import TemplateItem
from cms.toolbar_base import CMSToolbar
-from cms.utils.i18n import get_language_objects, force_language, get_language_object
-from django.contrib.sites.models import Site
-from cms.utils import get_cms_setting
from cms.toolbar_pool import toolbar_pool
-from cms.utils.permissions import get_user_sites_queryset, has_page_change_permission
-from django.conf import settings
-from django.core.urlresolvers import reverse
-from django.utils.translation import ugettext_lazy as _
-from django.contrib import admin
-from django.contrib.auth.models import User
+from cms.utils.i18n import get_language_objects
+from cms.utils.i18n import force_language
+from cms.utils.i18n import get_language_object
+from cms.utils import get_cms_setting
+from cms.utils.permissions import get_user_sites_queryset
+from cms.utils.permissions import has_page_change_permission
from menus.utils import DefaultLanguageChanger
View
@@ -4,33 +4,40 @@
from cms.compat import is_user_swapped, user_model_label
-# Some custom user models may require a custom UserAdmin class and associated forms,
-# so check if they exist and import them
-from django.contrib.auth.forms import UserCreationForm, UserChangeForm
-from django.contrib.auth.admin import UserAdmin
# overide with custom classes if they exist
if is_user_swapped:
- # UserAdmin class
+ # UserAdmin class
user_app_name = user_model_label.split('.')[0]
app = models.get_app(user_app_name)
try:
- custom_admin = importlib.import_module(app.__name__[:-6] + "admin")
+ custom_admin = importlib.import_module(app.__name__[:-6] + "admin")
- if hasattr(custom_admin, 'UserAdmin'):
- UserAdmin = custom_admin.UserAdmin
+ if hasattr(custom_admin, 'UserAdmin'):
+ UserAdmin = custom_admin.UserAdmin
+ else:
+ from django.contrib.auth.admin import UserAdmin
except ImportError:
- pass
+ from django.contrib.auth.admin import UserAdmin # nopyflakes
# user form classes
try:
- custom_forms = importlib.import_module(app.__name__[:-6] + "forms")
+ custom_forms = importlib.import_module(app.__name__[:-6] + "forms")
- if hasattr(custom_forms, 'UserCreationForm'):
- UserCreationForm = custom_forms.UserCreationForm
+ if hasattr(custom_forms, 'UserCreationForm'):
+ UserCreationForm = custom_forms.UserCreationForm
+ else:
+ from django.contrib.auth.forms import UserCreationForm
- if hasattr(custom_forms, 'UserChangeForm'):
- UserChangeForm = custom_forms.UserChangeForm
+ if hasattr(custom_forms, 'UserChangeForm'):
+ UserChangeForm = custom_forms.UserChangeForm
+ else:
+ from django.contrib.auth.forms import UserChangeForm
except ImportError:
- pass
+ from django.contrib.auth.forms import UserCreationForm # nopyflakes
+ from django.contrib.auth.forms import UserChangeForm # nopyflakes
+else:
+ from django.contrib.auth.admin import UserAdmin # nopyflakes
+ from django.contrib.auth.forms import UserCreationForm # nopyflakes
+ from django.contrib.auth.forms import UserChangeForm # nopyflakes
@@ -1,3 +1,5 @@
-from .models import PageExtension, TitleExtension
-from .extension_pool import extension_pool
-from .admin import PageExtensionAdmin, TitleExtensionAdmin
+from .models import PageExtension # nopyflakes
+from .models import TitleExtension # nopyflakes
+from .extension_pool import extension_pool # nopyflakes
+from .admin import PageExtensionAdmin # nopyflakes
+from .admin import TitleExtensionAdmin # nopyflakes
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
+from django.core.management.base import LabelCommand
+
from cms.management.commands.subcommands.base import SubcommandsCommand
from cms.models import Page
from cms.models.pluginmodel import CMSPlugin
-from django.core.management.base import LabelCommand
from cms.utils.compat.input import raw_input
@@ -47,8 +48,11 @@ def handle_label(self, label, **options):
Type 'yes' to continue, or 'no' to cancel: """ % (number_of_plugins, label))
else:
confirm = 'yes'
- queryset.delete()
- self.stdout.write(u'%d %r plugins uninstalled\n' % (number_of_plugins, label))
+ if confirm == 'yes':
+ queryset.delete()
+ self.stdout.write(u'%d %r plugins uninstalled\n' % (number_of_plugins, label))
+ else:
+ self.stdout.write(u'Aborted')
else:
self.stdout.write(u'no %r plugins found\n' % label)
View
@@ -1,9 +1,16 @@
# -*- coding: utf-8 -*-
from collections import defaultdict
+
+from django.contrib.sites.models import Site
+from django.utils.translation import get_language
+
from cms.apphook_pool import apphook_pool
-from cms.compat import get_user_model, user_related_query_name, user_related_name
-from cms.models.permissionmodels import (ACCESS_DESCENDANTS,
- ACCESS_PAGE_AND_DESCENDANTS, ACCESS_CHILDREN, ACCESS_PAGE_AND_CHILDREN, ACCESS_PAGE)
+from cms.compat import user_related_name
+from cms.models.permissionmodels import ACCESS_DESCENDANTS
+from cms.models.permissionmodels import ACCESS_PAGE_AND_DESCENDANTS
+from cms.models.permissionmodels import ACCESS_CHILDREN
+from cms.models.permissionmodels import ACCESS_PAGE_AND_CHILDREN
+from cms.models.permissionmodels import ACCESS_PAGE
from cms.models.permissionmodels import PagePermission, GlobalPagePermission
from cms.models.titlemodels import Title
from cms.utils import get_language_from_request
@@ -15,10 +22,6 @@
from menus.base import Menu, NavigationNode, Modifier
from menus.menu_pool import menu_pool
-from django.contrib.sites.models import Site
-from django.db.models.query_utils import Q
-from django.utils.translation import get_language
-
def get_visible_pages(request, pages, site=None):
"""
View
@@ -1,21 +1,16 @@
# -*- coding: utf-8 -*-
from django.conf import settings as d_settings
-from django.core.exceptions import ImproperlyConfigured
-from django.core.urlresolvers import get_resolver, get_script_prefix, \
- NoReverseMatch
-from django.utils.encoding import iri_to_uri
-from .settingmodels import *
-from .pagemodel import *
-from .permissionmodels import *
-from .placeholdermodel import *
-from .pluginmodel import *
-from .titlemodels import *
-from .placeholderpluginmodel import *
-from .static_placeholder import *
+from .settingmodels import * # nopyflakes
+from .pagemodel import * # nopyflakes
+from .permissionmodels import * # nopyflakes
+from .placeholdermodel import * # nopyflakes
+from .pluginmodel import * # nopyflakes
+from .titlemodels import * # nopyflakes
+from .placeholderpluginmodel import * # nopyflakes
+from .static_placeholder import * # nopyflakes
-import django.core.urlresolvers
# must be last
-from cms import signals as s_import
+from cms import signals as s_import # nopyflakes
def validate_settings():
View
@@ -1,7 +1,16 @@
# -*- coding: utf-8 -*-
+from os.path import join
+
from django.utils.timezone import now
+from django.contrib.sites.models import Site
+from django.core.urlresolvers import reverse
+from django.core.cache import cache
+from django.conf import settings
+from django.db import models
+from django.shortcuts import get_object_or_404
+from django.utils.translation import get_language, ugettext_lazy as _
+from mptt.models import MPTTModel
-from os.path import join
from cms import constants
from cms.constants import PUBLISHER_STATE_DEFAULT, PUBLISHER_STATE_PENDING, PUBLISHER_STATE_DIRTY, TEMPLATE_INHERITANCE_MAGIC
from cms.exceptions import PublicIsUnmodifiable, LanguageError, PublicVersionNeeded
@@ -17,16 +26,7 @@
from cms.utils.conf import get_cms_setting
from cms.utils.copy_plugins import copy_plugins_to
from cms.utils.helpers import reversion_register
-from django.contrib.sites.models import Site
-from django.core.urlresolvers import reverse
-from django.core.cache import cache
-from django.conf import settings
-from django.db import models
-from django.db.models import Q
-from django.shortcuts import get_object_or_404
-from django.utils.translation import get_language, ugettext_lazy as _
from menus.menu_pool import menu_pool
-from mptt.models import MPTTModel
@python_2_unicode_compatible
class Page(with_metaclass(PageMetaClass, MPTTModel)):
Oops, something went wrong.

0 comments on commit 0d7a8bc

Please sign in to comment.