Fix other PEP8 issues in assorted files

fix_request_path_info
Diederik van der Boor 2015-12-28 17:39:04 +01:00
parent f90e87afcc
commit 137139f2bb
7 changed files with 61 additions and 39 deletions

View File

@ -11,7 +11,8 @@
# All configuration values have a default; values that are commented out # All configuration values have a default; values that are commented out
# serve to show the default. # serve to show the default.
import sys, os import sys
import os
# If extensions (or modules to document with autodoc) are in another directory, # 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 # add these directories to sys.path here. If the directory is relative to the
@ -176,21 +177,21 @@ htmlhelp_basename = 'django-polymorphicdoc'
# -- Options for LaTeX output -------------------------------------------------- # -- Options for LaTeX output --------------------------------------------------
latex_elements = { latex_elements = {
# The paper size ('letterpaper' or 'a4paper'). # The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper', #'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt'). # The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt', #'pointsize': '10pt',
# Additional stuff for the LaTeX preamble. # Additional stuff for the LaTeX preamble.
#'preamble': '', #'preamble': '',
} }
# Grouping the document tree into LaTeX files. List of tuples # Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]). # (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [ latex_documents = [
('index', 'django-polymorphic.tex', u'django-polymorphic Documentation', ('index', 'django-polymorphic.tex', u'django-polymorphic Documentation',
u'Bert Constantin, Chris Glass, Diederik van der Boor', 'manual'), u'Bert Constantin, Chris Glass, Diederik van der Boor', 'manual'),
] ]
# The name of an image file (relative to this directory) to place at the top of # The name of an image file (relative to this directory) to place at the top of
@ -233,9 +234,9 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
('index', 'django-polymorphic', u'django-polymorphic Documentation', ('index', 'django-polymorphic', u'django-polymorphic Documentation',
u'Bert Constantin, Chris Glass, Diederik van der Boor', 'django-polymorphic', 'One line description of project.', u'Bert Constantin, Chris Glass, Diederik van der Boor', 'django-polymorphic', 'One line description of project.',
'Miscellaneous'), 'Miscellaneous'),
] ]
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.

View File

@ -9,7 +9,8 @@ import django
from django.core.management.base import NoArgsCommand from django.core.management.base import NoArgsCommand
from django.db import connection from django.db import connection
from pprint import pprint from pprint import pprint
import time, sys import time
import sys
from pexp.models import * from pexp.models import *
@ -22,7 +23,11 @@ def reset_queries():
def show_queries(): def show_queries():
print; print 'QUERIES:', len(connection.queries); pprint(connection.queries); print; connection.queries = [] print
print 'QUERIES:', len(connection.queries)
pprint(connection.queries)
print
connection.queries = []
def print_timing(func, message='', iterations=1): def print_timing(func, message='', iterations=1):
@ -35,7 +40,8 @@ def print_timing(func, message='', iterations=1):
t2 = time.time() t2 = time.time()
results.append((t2 - t1) * 1000.0) results.append((t2 - t1) * 1000.0)
res_sum = 0 res_sum = 0
for r in results: res_sum += r for r in results:
res_sum += r
median = res_sum / len(results) median = res_sum / len(results)
print '%s%-19s: %.4f ms, %i queries (%i times)' % ( print '%s%-19s: %.4f ms, %i queries (%i times)' % (
message, func.func_name, message, func.func_name,
@ -57,7 +63,7 @@ class Command(NoArgsCommand):
b = ModelB.objects.create(field1='B1', field2='B2') b = ModelB.objects.create(field1='B1', field2='B2')
c = ModelC.objects.create(field1='C1', field2='C2', field3='C3') c = ModelC.objects.create(field1='C1', field2='C2', field3='C3')
reset_queries() reset_queries()
print ModelC.base_objects.all(); print ModelC.base_objects.all()
show_queries() show_queries()
if False: if False:
@ -66,7 +72,8 @@ class Command(NoArgsCommand):
a = ModelA.objects.create(field1=str(i % 100)) a = ModelA.objects.create(field1=str(i % 100))
b = ModelB.objects.create(field1=str(i % 100), field2=str(i % 200)) b = ModelB.objects.create(field1=str(i % 100), field2=str(i % 200))
c = ModelC.objects.create(field1=str(i % 100), field2=str(i % 200), field3=str(i % 300)) c = ModelC.objects.create(field1=str(i % 100), field2=str(i % 200), field3=str(i % 300))
if i % 100 == 0: print i if i % 100 == 0:
print i
f = print_timing(poly_sql_query, iterations=1000) f = print_timing(poly_sql_query, iterations=1000)
f() f()
@ -81,7 +88,8 @@ class Command(NoArgsCommand):
b = nModelB.objects.create(field1='B1', field2='B2') b = nModelB.objects.create(field1='B1', field2='B2')
c = nModelC.objects.create(field1='C1', field2='C2', field3='C3') c = nModelC.objects.create(field1='C1', field2='C2', field3='C3')
qs = ModelA.objects.raw("SELECT * from pexp_modela") qs = ModelA.objects.raw("SELECT * from pexp_modela")
for o in list(qs): print o for o in list(qs):
print o
from django.db import connection, transaction from django.db import connection, transaction
from random import Random from random import Random

View File

@ -15,7 +15,11 @@ def reset_queries():
def show_queries(): def show_queries():
print; print 'QUERIES:', len(connection.queries); pprint(connection.queries); print; connection.queries = [] print
print 'QUERIES:', len(connection.queries)
pprint(connection.queries)
print
connection.queries = []
class Command(NoArgsCommand): class Command(NoArgsCommand):

View File

@ -21,7 +21,11 @@ def reset_queries():
def show_queries(): def show_queries():
print; print 'QUERIES:', len(connection.queries); pprint(connection.queries); print; reset_queries() print
print 'QUERIES:', len(connection.queries)
pprint(connection.queries)
print
reset_queries()
import time import time
@ -39,7 +43,8 @@ def print_timing(func, message='', iterations=1):
t2 = time.time() t2 = time.time()
results.append((t2 - t1) * 1000.0) results.append((t2 - t1) * 1000.0)
res_sum = 0 res_sum = 0
for r in results: res_sum += r for r in results:
res_sum += r
median = res_sum / len(results) median = res_sum / len(results)
print '%s%-19s: %.0f ms, %i queries' % ( print '%s%-19s: %.0f ms, %i queries' % (
message, func.func_name, message, func.func_name,

View File

@ -15,7 +15,11 @@ def reset_queries():
def show_queries(): def show_queries():
print; print 'QUERIES:', len(connection.queries); pprint(connection.queries); print; connection.queries = [] print
print 'QUERIES:', len(connection.queries)
pprint(connection.queries)
print
connection.queries = []
class Command(NoArgsCommand): class Command(NoArgsCommand):

View File

@ -19,15 +19,15 @@ sys.stderr.write('Using Django version {0} from {1}\n'.format(
if not settings.configured: if not settings.configured:
settings.configure( settings.configure(
DEBUG = True, DEBUG=True,
TEMPLATE_DEBUG = True, TEMPLATE_DEBUG=True,
DATABASES = { DATABASES={
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:' 'NAME': ':memory:'
} }
}, },
TEMPLATE_LOADERS = ( TEMPLATE_LOADERS=(
'django.template.loaders.app_directories.Loader', 'django.template.loaders.app_directories.Loader',
), ),
TEMPLATE_CONTEXT_PROCESSORS=( TEMPLATE_CONTEXT_PROCESSORS=(
@ -37,7 +37,7 @@ if not settings.configured:
'django.core.context_processors.request', 'django.core.context_processors.request',
] ]
), ),
TEST_RUNNER = 'django.test.runner.DiscoverRunner' if django.VERSION >= (1,7) else 'django.test.simple.DjangoTestSuiteRunner', TEST_RUNNER = 'django.test.runner.DiscoverRunner' if django.VERSION >= (1, 7) else 'django.test.simple.DjangoTestSuiteRunner',
INSTALLED_APPS = ( INSTALLED_APPS = (
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',

View File

@ -21,22 +21,22 @@ def find_version(*parts):
setup( setup(
name = 'django_polymorphic', name='django_polymorphic',
version = find_version('polymorphic', '__init__.py'), version=find_version('polymorphic', '__init__.py'),
license = 'BSD', license='BSD',
description = 'Seamless Polymorphic Inheritance for Django Models', description='Seamless Polymorphic Inheritance for Django Models',
long_description = read('README.rst'), long_description=read('README.rst'),
url = 'https://github.com/chrisglass/django_polymorphic', url='https://github.com/chrisglass/django_polymorphic',
author = 'Bert Constantin', author='Bert Constantin',
author_email = 'bert.constantin@gmx.de', author_email='bert.constantin@gmx.de',
maintainer = 'Christopher Glass', maintainer='Christopher Glass',
maintainer_email = 'tribaal@gmail.com', maintainer_email='tribaal@gmail.com',
packages = find_packages(), packages=find_packages(),
package_data = { package_data={
'polymorphic': [ 'polymorphic': [
'templates/admin/polymorphic/*.html', 'templates/admin/polymorphic/*.html',
], ],