Permalink
Browse files

Merge branch 'master' of git@github.com:durden/spygit

  • Loading branch information...
durden committed Aug 15, 2010
2 parents 1144769 + 0dafb35 commit 4c06e6775c5b6a01e1fa63a24fae8dca3fdb0de5
Showing with 35 additions and 29 deletions.
  1. +7 −2 manage.py
  2. +2 −1 settings.py
  3. +0 −1 spygitapp/admin.py
  4. +15 −16 spygitapp/pep8.py
  5. +5 −5 spygitapp/templatetags/syntax_color.py
  6. +1 −1 spygitapp/tests.py
  7. +4 −2 spygitapp/views.py
  8. +1 −1 urls.py
View
@@ -1,10 +1,15 @@
#!/usr/bin/env python
from django.core.management import execute_manager
try:
- import settings # Assumed to be in the same directory.
+ import settings # Assumed to be in the same directory.
except ImportError:
import sys
- sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+ sys.stderr.write("Error: Can't find the file 'settings.py' in the "
+ "directory containing %r. It appears you've customized things.\nYou'll"
+ " have to run django-admin.py, passing it your settings module.\n(If "
+ "the file settings.py does indeed exist, it's causing an ImportError "
+ "somehow."
+ ")\n" % __file__)
sys.exit(1)
if __name__ == "__main__":
View
@@ -82,7 +82,8 @@
ROOT_URLCONF = 'spygit.urls'
TEMPLATE_DIRS = (
- # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
+ # Put strings here, like "/home/html/django_templates" or
+ # "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(os.path.dirname(__file__), 'spygitapp/templates'),
View
@@ -6,4 +6,3 @@
admin.site.register(File)
admin.site.register(RunError)
admin.site.register(Line)
-
View
@@ -28,7 +28,7 @@ def parse_pep8(run, git_path, output):
os.path.walk(git_path, add_file_to_set, allfiles)
for filename in allfiles:
filename = filename.replace(git_path + '/', '', 1)
- runfile = File(filename = filename, run = run)
+ runfile = File(filename=filename, run=run)
runfile.save()
# Generate a set of error types, error files, and lines
@@ -43,30 +43,30 @@ def parse_pep8(run, git_path, output):
# Add new err types to the db
if (errnum, errtext) not in errortype_set:
errortype_set.add((errnum, errtext))
- if not Error.objects.filter(error_type = errnum):
- err = Error(error_type = errnum, short_descr = errtext)
+ if not Error.objects.filter(error_type=errnum):
+ err = Error(error_type=errnum, short_descr=errtext)
err.save()
# Create a set of line numbers for each file
- for ln in range(max(0,lineno - 3), lineno + 4):
- lineno_set.add((filename,ln))
+ for ln in range(max(0, lineno - 3), lineno + 4):
+ lineno_set.add((filename, ln))
# Add err instances to the db
- runfile = File.objects.get(run = run, filename = filename)
- errtype = Error.objects.get(error_type = errnum)
- runerr = RunError(error = errtype, file = runfile, line_number = lineno,
- error_descr = errtext)
+ runfile = File.objects.get(run=run, filename=filename)
+ errtype = Error.objects.get(error_type=errnum)
+ runerr = RunError(error=errtype, file=runfile, line_number=lineno,
+ error_descr=errtext)
runerr.save()
# Add lines to the db
for filename in errfiles_set:
- runfile = File.objects.get(run = run, filename = filename)
-
+ runfile = File.objects.get(run=run, filename=filename)
+
f = open(git_path + '/' + filename, 'r')
- lineno = 0
+ lineno = 1
for line in f:
if (filename, lineno) in lineno_set:
- linetext = Line(file = runfile, line_number = lineno, text = line)
+ linetext = Line(file=runfile, line_number=lineno, text=line)
linetext.save()
lineno = lineno + 1
f.close()
@@ -96,10 +96,9 @@ def run_pep8(git_url):
gpipe.close()
# Do not allow duplicates of the same project/rev
- old_run = Run.objects.filter(project_name = git_name, git_revision = rev)
+ old_run = Run.objects.filter(project_name=git_name, git_revision=rev)
if not old_run:
- run = Run(project_name = git_name, project_url = git_url,
- git_revision = rev)
+ run = Run(project_name=git_name, project_url=git_url, git_revision=rev)
run.save()
pep8_pipe = os.popen("pep8 %s" % git_path)
parse_pep8(run, git_path, pep8_pipe)
@@ -6,21 +6,22 @@
from django.utils.safestring import mark_safe
from pygments import highlight
from pygments.formatters import HtmlFormatter
-from pygments.lexers import get_lexer_by_name,guess_lexer,ClassNotFound
+from pygments.lexers import get_lexer_by_name, guess_lexer, ClassNotFound
register = template.Library()
+
def generate_pygments_css(path=None):
if path is None:
import os
- path = os.path.join(os.getcwd(),'pygments.css')
+ path = os.path.join(os.getcwd(), 'pygments.css')
- f = open(path,'w')
+ f = open(path, 'w')
f.write(HtmlFormatter().get_style_defs('.highlight'))
f.close()
-def get_lexer(value,arg):
+def get_lexer(value, arg):
if arg is None:
return guess_lexer(value)
@@ -56,4 +57,3 @@ def colorize_error(value, arg=1):
@stringfilter
def colorize_table(value, arg=1):
return __colorize(value, arg, linenos='table')
-
View
@@ -7,6 +7,7 @@
from django.test import TestCase
+
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
@@ -20,4 +21,3 @@ def test_basic_addition(self):
>>> 1 + 1 == 2
True
"""}
-
View
@@ -69,7 +69,8 @@ def file_detail(request, project_name, rev, filename):
# Match up the lines with which ones have errors
for line in all_lines:
try:
- error = RunError.objects.get(file=file, line_number=line.line_number)
+ error = RunError.objects.get(file=file,
+ line_number=line.line_number)
error = error.error
except ObjectDoesNotExist:
error = None
@@ -79,7 +80,8 @@ def file_detail(request, project_name, rev, filename):
# Pass this b/c if there are no errors there will be no lines, so can't
# show the filename
- return render_to_response('file.html', {'lines': lines, 'filename': filename})
+ return render_to_response('file.html',
+ {'lines': lines, 'filename': filename})
def pep_view(request, **view_args):
View
@@ -8,7 +8,7 @@
admin.autodiscover()
urlpatterns = patterns('django.views.generic.simple',
- # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
+ # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

0 comments on commit 4c06e67

Please sign in to comment.