Permalink
Browse files

Adding precommit hooks and removing unused imports, fixing pep8 etc

  • Loading branch information...
benjaoming committed May 5, 2016
1 parent 1877b7b commit 5a41d112e5129ecadcdd44af1a1bb9928c820bbb
Showing with 641 additions and 746 deletions.
  1. +16 −0 .pre-commit-config.yaml
  2. +0 −1 .travis.yml
  3. +0 −1 CONTRIBUTING.md
  4. +23 −16 docs/conf.py
  5. +6 −9 runtests.py
  6. +6 −0 setup.cfg
  7. +4 −5 setup.py
  8. +1 −1 testproject/README.md
  9. +1 −2 testproject/manage.py
  10. +2 −2 testproject/testproject/settings/codehilite.py
  11. +2 −2 testproject/testproject/settings/customauthuser.py
  12. +4 −3 testproject/testproject/settings/haystack.py
  13. +2 −2 testproject/testproject/settings/sendfile.py
  14. +6 −6 testproject/testproject/urls.py
  15. +7 −6 testproject/testproject/wsgi.py
  16. +3 −5 wiki/admin.py
  17. +2 −2 wiki/apps.py
  18. +5 −6 wiki/conf/settings.py
  19. +4 −5 wiki/core/compat.py
  20. +2 −2 wiki/core/diff.py
  21. +5 −6 wiki/core/http.py
  22. +1 −1 wiki/core/markdown/mdx/previewlinks.py
  23. +3 −2 wiki/core/permissions.py
  24. +4 −3 wiki/core/plugins/base.py
  25. +3 −4 wiki/core/plugins/loader.py
  26. +3 −3 wiki/core/plugins/registry.py
  27. +1 −2 wiki/core/utils.py
  28. +9 −12 wiki/decorators.py
  29. +2 −2 wiki/editors/base.py
  30. +5 −5 wiki/editors/markitup.py
  31. +21 −22 wiki/forms.py
  32. +5 −8 wiki/managers.py
  33. +2 −4 wiki/migrations/0001_initial.py
  34. +4 −7 wiki/models/article.py
  35. +5 −5 wiki/models/pluginbase.py
  36. +12 −15 wiki/models/urlpath.py
  37. +2 −2 wiki/plugins/attachments/admin.py
  38. +8 −9 wiki/plugins/attachments/forms.py
  39. +5 −7 wiki/plugins/attachments/markdown_extensions.py
  40. +2 −3 wiki/plugins/attachments/migrations/0001_initial.py
  41. +7 −11 wiki/plugins/attachments/models.py
  42. +3 −3 wiki/plugins/attachments/settings.py
  43. +3 −3 wiki/plugins/attachments/south_migrations/0001_initial.py
  44. +0 −1 wiki/plugins/attachments/templates/wiki/plugins/attachments/delete.html
  45. +1 −2 wiki/plugins/attachments/templates/wiki/plugins/attachments/history.html
  46. +14 −15 wiki/plugins/attachments/templates/wiki/plugins/attachments/index.html
  47. +1 −1 wiki/plugins/attachments/templates/wiki/plugins/attachments/replace.html
  48. +1 −2 wiki/plugins/attachments/tests/test_commands.py
  49. +2 −3 wiki/plugins/attachments/urls.py
  50. +4 −4 wiki/plugins/attachments/views.py
  51. +4 −7 wiki/plugins/attachments/wiki_plugin.py
  52. +2 −2 wiki/plugins/haystack/search_indexes.py
  53. +0 −1 wiki/plugins/haystack/templates/wiki/plugins/haystack/search.html
  54. +7 −7 wiki/plugins/haystack/views.py
  55. +2 −4 wiki/plugins/help/wiki_plugin.py
  56. +4 −3 wiki/plugins/images/admin.py
  57. +3 −4 wiki/plugins/images/forms.py
  58. +4 −5 wiki/plugins/images/markdown_extensions.py
  59. +1 −1 wiki/plugins/images/migrations/0001_initial.py
  60. +5 −7 wiki/plugins/images/models.py
  61. +2 −2 wiki/plugins/images/settings.py
  62. +3 −3 wiki/plugins/images/south_migrations/0001_initial.py
  63. +3 −3 wiki/plugins/images/static/wiki/colorbox/example1/colorbox.css
  64. +10 −10 wiki/plugins/images/static/wiki/colorbox/example1/index.html
  65. +1 −1 wiki/plugins/images/static/wiki/colorbox/jquery.colorbox-min.js
  66. +2 −3 wiki/plugins/images/templates/wiki/plugins/images/index.html
  67. +1 −2 wiki/plugins/images/templates/wiki/plugins/images/purge.html
  68. +1 −1 wiki/plugins/images/templates/wiki/plugins/images/render.html
  69. +1 −2 wiki/plugins/images/templates/wiki/plugins/images/revision_add.html
  70. +3 −3 wiki/plugins/images/templates/wiki/plugins/images/sidebar.html
  71. +3 −5 wiki/plugins/images/templatetags/wiki_images_tags.py
  72. +4 −6 wiki/plugins/images/views.py
  73. +4 −5 wiki/plugins/images/wiki_plugin.py
  74. +2 −4 wiki/plugins/links/mdx/djangowikilinks.py
  75. +7 −5 wiki/plugins/links/mdx/urlize.py
  76. +1 −1 wiki/plugins/links/models.py
  77. +2 −2 wiki/plugins/links/settings.py
  78. +4 −5 wiki/plugins/links/views.py
  79. +5 −7 wiki/plugins/links/wiki_plugin.py
  80. +8 −8 wiki/plugins/macros/mdx/macro.py
  81. +8 −11 wiki/plugins/macros/mdx/toc.py
  82. +4 −4 wiki/plugins/macros/mdx/wikilinks.py
  83. +2 −3 wiki/plugins/macros/settings.py
  84. +2 −2 wiki/plugins/macros/templatetags/wiki_macro_tags.py
  85. +2 −5 wiki/plugins/macros/wiki_plugin.py
  86. +10 −15 wiki/plugins/mediawikiimport/management/commands/mediawiki_import.py
  87. +9 −12 wiki/plugins/notifications/forms.py
  88. +2 −3 wiki/plugins/notifications/management/commands/wiki_notifications_create_defaults.py
  89. +1 −1 wiki/plugins/notifications/migrations/0001_initial.py
  90. +6 −8 wiki/plugins/notifications/models.py
  91. +2 −2 wiki/plugins/notifications/settings.py
  92. +2 −2 wiki/plugins/notifications/south_migrations/0001_initial.py
  93. +0 −1 wiki/plugins/notifications/static/wiki/plugins/notifications/js/ui.js
  94. +0 −1 wiki/plugins/notifications/templates/wiki/plugins/notifications/settings.html
  95. +2 −2 wiki/plugins/notifications/util.py
  96. +3 −4 wiki/plugins/notifications/views.py
  97. +3 −4 wiki/plugins/notifications/wiki_plugin.py
  98. +3 −3 wiki/south_migrations/0001_initial.py
  99. +1 −1 wiki/static/wiki/bootstrap/css/bootstrap.min.css
  100. +1 −1 wiki/static/wiki/bootstrap/css/wiki-bootstrap.min.css
  101. +1 −1 wiki/static/wiki/bootstrap/js/bootstrap.min.js
  102. +0 −1 wiki/static/wiki/bootstrap/less/wiki/typeahead.less
  103. +1 −1 wiki/static/wiki/bootstrap/less/wiki/wiki-bootstrap.less
  104. +3 −3 wiki/static/wiki/bootstrap/less/wiki/wiki.less
  105. +1 −1 wiki/static/wiki/css/all.css
  106. +0 −1 wiki/static/wiki/css/print.css
  107. +0 −1 wiki/static/wiki/font-awesome/less/variables.less
  108. +0 −1 wiki/static/wiki/js/core.js
  109. +1 −1 wiki/static/wiki/js/diff.js
  110. +6 −6 wiki/static/wiki/js/diffview.js
  111. +0 −1 wiki/static/wiki/js/editor.js
  112. +1 −1 wiki/static/wiki/js/jqueryui/jquery-ui-1.10.0.custom.min.css
  113. +1 −1 wiki/static/wiki/js/jqueryui/jquery-ui-1.10.0.custom.min.js
  114. +1 −1 wiki/static/wiki/js/typeahead.min.js
  115. +0 −2 wiki/static/wiki/markitup/admin.init.js
  116. +0 −2 wiki/static/wiki/markitup/frontend.init.js
  117. +37 −37 wiki/static/wiki/markitup/jquery.markitup.js
  118. +2 −2 wiki/static/wiki/markitup/sets/admin/readme.txt
  119. +2 −2 wiki/static/wiki/markitup/sets/admin/set.js
  120. +7 −7 wiki/static/wiki/markitup/sets/admin/style.css
  121. +2 −2 wiki/static/wiki/markitup/sets/default/set.js
  122. +2 −2 wiki/static/wiki/markitup/sets/default/style.css
  123. +2 −2 wiki/static/wiki/markitup/sets/frontend/readme.txt
  124. +2 −2 wiki/static/wiki/markitup/sets/frontend/set.js
  125. +7 −7 wiki/static/wiki/markitup/sets/frontend/style.css
  126. +5 −5 wiki/static/wiki/markitup/skins/markitup/style.css
  127. +1 −1 wiki/static/wiki/markitup/skins/simple/readme.txt
  128. +3 −3 wiki/static/wiki/markitup/skins/simple/style.css
  129. +1 −1 wiki/static/wiki/markitup/templates/preview.css
  130. +4 −5 wiki/templates/wiki/create.html
  131. +0 −1 wiki/templates/wiki/create_root.html
  132. +11 −12 wiki/templates/wiki/delete.html
  133. +7 −8 wiki/templates/wiki/deleted.html
  134. +1 −2 wiki/templates/wiki/dir.html
  135. +0 −1 wiki/templates/wiki/edit.html
  136. +6 −6 wiki/templates/wiki/error.html
  137. +12 −13 wiki/templates/wiki/history.html
  138. +1 −1 wiki/templates/wiki/includes/breadcrumbs.html
  139. +3 −5 wiki/templates/wiki/includes/editor_sidebar.html
  140. +0 −1 wiki/templates/wiki/includes/editormedia.html
  141. +1 −1 wiki/templates/wiki/includes/formerrors.html
  142. +0 −1 wiki/templates/wiki/includes/formfield.html
  143. +2 −3 wiki/templates/wiki/includes/render.html
  144. +0 −1 wiki/templates/wiki/includes/revision_info.html
  145. +2 −3 wiki/templates/wiki/permission_denied.html
  146. +3 −3 wiki/templates/wiki/preview_inline.html
  147. +3 −3 wiki/templates/wiki/root_missing.html
  148. +0 −1 wiki/templates/wiki/search.html
  149. +1 −1 wiki/templates/wiki/settings.html
  150. +0 −1 wiki/templates/wiki/source.html
  151. +0 −1 wiki/templates/wiki/view.html
  152. +8 −9 wiki/templatetags/wiki_tags.py
  153. +4 −4 wiki/tests/base.py
  154. +4 −6 wiki/tests/test_basic.py
  155. +3 −3 wiki/tests/test_commands.py
  156. +3 −5 wiki/tests/test_managers.py
  157. +8 −12 wiki/tests/test_models.py
  158. +7 −12 wiki/tests/test_template_filters.py
  159. +11 −16 wiki/tests/test_template_tags.py
  160. +11 −15 wiki/tests/test_urls.py
  161. +7 −7 wiki/tests/test_views.py
  162. +6 −6 wiki/tests/testdata/urls.py
  163. +5 −6 wiki/urls.py
  164. +6 −6 wiki/views/accounts.py
  165. +11 −13 wiki/views/article.py
  166. +2 −2 wiki/views/deleted_list.py
  167. +3 −5 wiki/views/mixins.py
View
@@ -0,0 +1,16 @@
+- repo: git://github.com/pre-commit/pre-commit-hooks
+ sha: 97b88d9610bcc03982ddac33caba98bb2b751f5f
+ hooks:
+ - id: trailing-whitespace
+ - id: flake8
+ args:
+ - --exclude=*/*migrations/*, testproject/testproject/settings/*
+ - id: check-added-large-files
+ - id: debug-statements
+ - id: end-of-file-fixer
+- repo: git://github.com/FalconSocial/pre-commit-python-sorter
+ sha: d044ff27300a6dc8b1a56cd22552e3a810dc6f49
+ hooks:
+ - id: python-import-sorter
+ args:
+ - --silent-overwrite
View
@@ -39,4 +39,3 @@ notifications:
after_success:
- coverage combine
- coveralls
-
View
@@ -47,4 +47,3 @@ Django needs a mature wiki system appealing to all kinds of needs, both big and
* **Be smart.** [This is](https://upload.wikimedia.org/wikipedia/commons/8/88/MediaWiki_database_schema_1-19_%28r102798%29.png) the map of tables in MediaWiki - we'll understand the choices of other wiki projects and make our own. After-all, this is a Django project.
* **Be simple.** The source code should *almost* explain itself.
* **Be structured.** Markdown is a simple syntax for readability. Features should be implemented either through easy coding patterns in the content field, but rather stored in a structured way (in the database) and managed through a friendly interface. This gives control back to the website developer, and makes knowledge more usable. Just ask: Why has Wikipedia never changed? Answer: Because it's knowledge is stored in a complicated way, thus it becomes very static.
-
View
@@ -1,6 +1,11 @@
# -*- coding: utf-8 -*-
-from __future__ import print_function, unicode_literals
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function, unicode_literals
+
+import os
+import sys
+
+import wiki
+
#
# django-wiki documentation build configuration file, created by
# sphinx-quickstart on Mon Jul 23 16:13:51 2012.
@@ -13,7 +18,6 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
-import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -43,7 +47,7 @@
# General information about the project.
project = 'django-wiki'
-copyright = '2013, Benjamin Bach'
+copyright = '2013, Benjamin Bach' # noqa
path = os.path.join(
@@ -57,7 +61,6 @@
sys.path = [path] + sys.path
sys.path = [os.path.join(path, 'wiki')] + sys.path
-import wiki
print(wiki.__file__)
@@ -190,21 +193,23 @@
# -- Options for LaTeX output --------------------------------------------------
latex_elements = {
-# The paper size ('letterpaper' or 'a4paper').
-# 'papersize': 'letterpaper',
+ # The paper size ('letterpaper' or 'a4paper').
+ # 'papersize': 'letterpaper',
-# The font size ('10pt', '11pt' or '12pt').
-# 'pointsize': '10pt',
+ # The font size ('10pt', '11pt' or '12pt').
+ # 'pointsize': '10pt',
-# Additional stuff for the LaTeX preamble.
-# 'preamble': '',
+ # Additional stuff for the LaTeX preamble.
+ # 'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
- ('index', 'django-wiki.tex', 'django-wiki Documentation',
- 'Benjamin Bach', 'manual'),
+ (
+ 'index', 'django-wiki.tex', 'django-wiki Documentation',
+ 'Benjamin Bach', 'manual'
+ ),
]
# The name of an image file (relative to this directory) to place at the top of
@@ -247,9 +252,11 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
- ('index', 'django-wiki', 'django-wiki Documentation',
- 'Benjamin Bach', 'django-wiki', 'One line description of project.',
- 'Miscellaneous'),
+ (
+ 'index', 'django-wiki', 'django-wiki Documentation',
+ 'Benjamin Bach', 'django-wiki', 'Wiki engine for Django - with real data models!',
+ 'Miscellaneous'
+ ),
]
# Documents to append as an appendix to all manuals.
View
@@ -1,10 +1,14 @@
#!/usr/bin/env python
-from __future__ import absolute_import
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
+
import sys
+
import django
+import pytest
from django.conf import settings
+# Run py.tests
+# Compatibility testing patches on the py-moneyed
settings_dict = dict(
DEBUG=True,
@@ -87,7 +91,6 @@
from south.management.commands import patch_for_test_db_setup
patch_for_test_db_setup()
-from django.core.management import execute_from_command_line
argv = [sys.argv[0], "test", "--traceback"]
# python setup.py test calls script with just 'test'
@@ -102,13 +105,7 @@
argv.extend(sys.argv[1:])
-## Run py.tests
-# Compatibility testing patches on the py-moneyed
-import pytest
failures = pytest.main()
if failures:
sys.exit(failures)
-
-
-
View
@@ -1,5 +1,11 @@
[bdist_wheel]
universal = 1
+[flake8]
+ignore = E226,E302,E303,E41,E501
+max-line-length = 160
+max-complexity = 10
+exclude = */*migrations
+
[metadata]
description-file = README.rst
View
@@ -1,14 +1,15 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from __future__ import absolute_import
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
import os
+from sys import version_info as PYTHON_VERSION
-from setuptools import setup, find_packages
+from setuptools import find_packages, setup
from wiki import __version__
+
# Utility function to read the README file.
# Used for the long_description. It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
@@ -63,8 +64,6 @@ def read(fname):
else:
requirements.append("sorl-thumbnail>=12,<13")
-# Requirements that depend on Python version: Markdown
-from sys import version_info as PYTHON_VERSION
if PYTHON_VERSION < (2, 7):
# For Python 2.6, use Markdown<2.5.0, see
# https://github.com/waylan/Python-Markdown/issues/349
View
@@ -1,7 +1,7 @@
Testing
===========
-This project can be run directly with the manage.py script, provided
+This project can be run directly with the manage.py script, provided
that you have checked out the root of the Git repository.
It comes with a prepopulated SQLite database.
View
@@ -1,6 +1,5 @@
#!/usr/bin/env python
-from __future__ import absolute_import
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
import os
import sys
@@ -1,5 +1,5 @@
-from __future__ import absolute_import
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
+
from testproject.settings import *
from testproject.settings.local import *
@@ -1,5 +1,5 @@
-from __future__ import absolute_import
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
+
from testproject.settings import *
from testproject.settings.local import *
@@ -1,8 +1,9 @@
-from __future__ import absolute_import
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
+
+import os
+
from testproject.settings import *
from testproject.settings.local import *
-import os
# Django Haystack
@@ -1,5 +1,5 @@
-from __future__ import absolute_import
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
+
from testproject.settings import *
from testproject.settings.local import *
@@ -1,11 +1,13 @@
-from __future__ import absolute_import
-from __future__ import unicode_literals
-from django.conf.urls import include, url
+from __future__ import absolute_import, unicode_literals
+
from django.conf import settings
-from django.contrib.staticfiles.urls import staticfiles_urlpatterns
+from django.conf.urls import include, url
from django.contrib import admin
+from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.http.response import HttpResponse
from django.views.static import serve as static_serve
+from django_nyt.urls import get_pattern as get_notify_pattern
+from wiki.urls import get_pattern as get_wiki_pattern
admin.autodiscover()
@@ -20,8 +22,6 @@
url(r'^media/(?P<path>.*)$', static_serve, {'document_root': settings.MEDIA_ROOT}),
]
-from wiki.urls import get_pattern as get_wiki_pattern
-from django_nyt.urls import get_pattern as get_notify_pattern
urlpatterns += [
url(r'^notify/', get_notify_pattern()),
url(r'', get_wiki_pattern())
@@ -13,22 +13,23 @@
framework.
"""
-from __future__ import absolute_import
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
+
import os
import sys
+# This application object is used by any WSGI server configured to use this
+# file. This includes Django's development server, if the WSGI_APPLICATION
+# setting points here.
+from django.core.wsgi import get_wsgi_application
+
PROJECT_PATH = os.path.abspath(os.path.split(__file__)[0])
PROJECT_PARENT = os.path.abspath(os.path.split(PROJECT_PATH)[0])
sys.path.append(PROJECT_PATH)
sys.path.append(PROJECT_PARENT)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.settings")
-# This application object is used by any WSGI server configured to use this
-# file. This includes Django's development server, if the WSGI_APPLICATION
-# setting points here.
-from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
# Apply WSGI middleware here.
View
@@ -1,13 +1,11 @@
-from __future__ import unicode_literals
-from __future__ import absolute_import
+from __future__ import absolute_import, unicode_literals
+
from django import forms
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
-
from mptt.admin import MPTTModelAdmin
-from . import models
-from . import editors
+from . import editors, models
# Django 1.9 deprecation of contenttypes.generic
try:
View
@@ -1,5 +1,5 @@
-from __future__ import absolute_import
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
+
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
View
@@ -1,10 +1,10 @@
-from __future__ import absolute_import
-from __future__ import unicode_literals
-# -*- coding: utf-8 -*-
+from __future__ import absolute_import, unicode_literals
+
+import django
from django.conf import settings as django_settings
+from django.core.files.storage import default_storage
from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext_lazy as _
-import django
# Should urls be case sensitive?
URL_CASE_SENSITIVE = getattr(django_settings, 'WIKI_URL_CASE_SENSITIVE', False)
@@ -217,7 +217,6 @@
# STORAGE #
###########
-from django.core.files.storage import default_storage
STORAGE_BACKEND = getattr(
django_settings,
'WIKI_STORAGE_BACKEND',
@@ -234,6 +233,6 @@
# Maximum age of revisions in days, 0=unlimited
MAX_REVISION_AGE = getattr(
- django_settings, 'WIKI_MAX_REVISION_AGE',
+ django_settings, 'WIKI_MAX_REVISION_AGE',
getattr(django_settings, 'MAX_REVISION_AGE', 365)
)
View
@@ -1,11 +1,10 @@
"""Abstraction layer to deal with Django related changes in order to keep
compatibility with several Django versions simultaneously."""
-from __future__ import absolute_import
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
+
from django import VERSION as DJANGO_VERSION
-from django.db import transaction
from django.conf import settings as django_settings
-
+from django.db import transaction
# Django 1.5+
if DJANGO_VERSION >= (1, 5):
@@ -55,4 +54,4 @@ def render_to_string(template_name, context=None, request=None):
return django_render_to_string(template_name,
context_instance=context_instance)
else:
- from django.template.loader import render_to_string
+ from django.template.loader import render_to_string # noqa @UnusedImport
View
@@ -1,5 +1,5 @@
-from __future__ import absolute_import
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
+
import difflib
Oops, something went wrong.

0 comments on commit 5a41d11

Please sign in to comment.