summaryrefslogtreecommitdiff
path: root/patchtracker/Patch.py
diff options
context:
space:
mode:
authorSean Finney <seanius@debian.org>2010-05-13 12:17:57 +0200
committerSean Finney <seanius@debian.org>2010-05-13 12:17:57 +0200
commit9649bd16ef6cadc96c2c6e96f3449aa62646df66 (patch)
treea79f67398b8b36bdc4a46a5cf1a3aae9398b2ece /patchtracker/Patch.py
parente2a079386b6f95deeadcea4cd3e2a04fafbf467a (diff)
downloadpatch-tracker-9649bd16ef6cadc96c2c6e96f3449aa62646df66.tar.gz
Implement series patch download and view in django
Diffstat (limited to 'patchtracker/Patch.py')
-rw-r--r--patchtracker/Patch.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/patchtracker/Patch.py b/patchtracker/Patch.py
index 6533910..09f4911 100644
--- a/patchtracker/Patch.py
+++ b/patchtracker/Patch.py
@@ -2,6 +2,9 @@ import sys
import os
import errno
from glob import glob
+import pygments
+import pygments.lexers
+import pygments.formatters
import tarfile
class Diffstat:
@@ -39,6 +42,14 @@ class Patch:
def diffstat(self):
return Diffstat(self)
+ def highlight(self):
+ for enc in ['utf-8', 'latin-1']:
+ try:
+ return pygments.highlight(str(self).decode(enc), pygments.lexers.DiffLexer(),
+ pygments.formatters.HtmlFormatter(style='colorful', noclasses=True, encoding=enc, nobackground=True))
+ except UnicodeDecodeError:
+ pass
+
class GenericPatchSeries (list):
def blank(self):
self.names = []