Skip to content

Commit

Permalink
Merge pull request #541 from benjaoming/precommit
Browse files Browse the repository at this point in the history
Adding precommit hooks and removing unused imports, fixing pep8 etc
  • Loading branch information
benjaoming committed May 5, 2016
2 parents 1877b7b + 5a41d11 commit 3a8aacc
Show file tree
Hide file tree
Showing 167 changed files with 641 additions and 746 deletions.
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ notifications:
after_success:
- coverage combine
- coveralls

1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

39 changes: 23 additions & 16 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -57,7 +61,6 @@
sys.path = [path] + sys.path
sys.path = [os.path.join(path, 'wiki')] + sys.path

import wiki

print(wiki.__file__)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
15 changes: 6 additions & 9 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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'
Expand All @@ -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)



6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -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
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion testproject/README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
3 changes: 1 addition & 2 deletions testproject/manage.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions testproject/testproject/settings/codehilite.py
Original file line number Diff line number Diff line change
@@ -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 *

Expand Down
4 changes: 2 additions & 2 deletions testproject/testproject/settings/customauthuser.py
Original file line number Diff line number Diff line change
@@ -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 *

Expand Down
7 changes: 4 additions & 3 deletions testproject/testproject/settings/haystack.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions testproject/testproject/settings/sendfile.py
Original file line number Diff line number Diff line change
@@ -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 *

Expand Down
12 changes: 6 additions & 6 deletions testproject/testproject/urls.py
Original file line number Diff line number Diff line change
@@ -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()

Expand All @@ -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())
Expand Down
13 changes: 7 additions & 6 deletions testproject/testproject/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 3 additions & 5 deletions wiki/admin.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions wiki/apps.py
Original file line number Diff line number Diff line change
@@ -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 _

Expand Down
11 changes: 5 additions & 6 deletions wiki/conf/settings.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -217,7 +217,6 @@
# STORAGE #
###########

from django.core.files.storage import default_storage
STORAGE_BACKEND = getattr(
django_settings,
'WIKI_STORAGE_BACKEND',
Expand All @@ -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)
)
9 changes: 4 additions & 5 deletions wiki/core/compat.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions wiki/core/diff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import absolute_import, unicode_literals

import difflib


Expand Down

0 comments on commit 3a8aacc

Please sign in to comment.