diff --git a/kallithea/lib/annotate.py b/kallithea/lib/annotate.py
--- a/kallithea/lib/annotate.py
+++ b/kallithea/lib/annotate.py
@@ -25,8 +25,6 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
-import StringIO
-
from pygments import highlight
from pygments.formatters import HtmlFormatter
@@ -111,12 +109,12 @@ class AnnotateHtmlFormatter(HtmlFormatte
return ''.join((changeset.id, '\n'))
def _wrap_tablelinenos(self, inner):
- dummyoutfile = StringIO.StringIO()
+ inner_lines = []
lncount = 0
for t, line in inner:
if t:
lncount += 1
- dummyoutfile.write(line)
+ inner_lines.append(line)
fl = self.linenostart
mw = len(str(lncount + fl - 1))
@@ -176,7 +174,7 @@ class AnnotateHtmlFormatter(HtmlFormatte
'
| ' +
'')
- yield 0, dummyoutfile.getvalue()
+ yield 0, ''.join(inner_lines)
yield 0, ' |
'
'''
@@ -204,5 +202,5 @@ class AnnotateHtmlFormatter(HtmlFormatte
''.join(headers_row) +
''.join(body_row_start)
)
- yield 0, dummyoutfile.getvalue()
+ yield 0, ''.join(inner_lines)
yield 0, ''
diff --git a/kallithea/lib/helpers.py b/kallithea/lib/helpers.py
--- a/kallithea/lib/helpers.py
+++ b/kallithea/lib/helpers.py
@@ -22,7 +22,6 @@ import json
import logging
import random
import re
-import StringIO
import textwrap
import urlparse
@@ -246,12 +245,12 @@ class CodeHtmlFormatter(HtmlFormatter):
yield i, t
def _wrap_tablelinenos(self, inner):
- dummyoutfile = StringIO.StringIO()
+ inner_lines = []
lncount = 0
for t, line in inner:
if t:
lncount += 1
- dummyoutfile.write(line)
+ inner_lines.append(line)
fl = self.linenostart
mw = len(str(lncount + fl - 1))
@@ -304,7 +303,7 @@ class CodeHtmlFormatter(HtmlFormatter):
' | '
'')
- yield 0, dummyoutfile.getvalue()
+ yield 0, ''.join(inner_lines)
yield 0, ' |
'
diff --git a/kallithea/lib/vcs/utils/annotate.py b/kallithea/lib/vcs/utils/annotate.py
--- a/kallithea/lib/vcs/utils/annotate.py
+++ b/kallithea/lib/vcs/utils/annotate.py
@@ -1,5 +1,3 @@
-import StringIO
-
from pygments import highlight
from pygments.formatters import HtmlFormatter
@@ -83,12 +81,12 @@ class AnnotateHtmlFormatter(HtmlFormatte
return ''.join((changeset.id, '\n'))
def _wrap_tablelinenos(self, inner):
- dummyoutfile = StringIO.StringIO()
+ inner_lines = []
lncount = 0
for t, line in inner:
if t:
lncount += 1
- dummyoutfile.write(line)
+ inner_lines.append(line)
fl = self.linenostart
mw = len(str(lncount + fl - 1))
@@ -147,7 +145,7 @@ class AnnotateHtmlFormatter(HtmlFormatte
' | ' +
'')
- yield 0, dummyoutfile.getvalue()
+ yield 0, ''.join(inner_lines)
yield 0, ' |
'
'''
@@ -175,5 +173,5 @@ class AnnotateHtmlFormatter(HtmlFormatte
''.join(headers_row) +
''.join(body_row_start)
)
- yield 0, dummyoutfile.getvalue()
+ yield 0, ''.join(inner_lines)
yield 0, ''
diff --git a/kallithea/model/scm.py b/kallithea/model/scm.py
--- a/kallithea/model/scm.py
+++ b/kallithea/model/scm.py
@@ -25,7 +25,6 @@ Original author and date, and relevant c
:license: GPLv3, see LICENSE.md for more details.
"""
-import cStringIO
import logging
import os
import posixpath
@@ -485,12 +484,8 @@ class ScmModel(object):
# in any other case this will throw exceptions and deny commit
if isinstance(content, (basestring,)):
content = safe_str(content)
- elif isinstance(content, (file, cStringIO.OutputType,)):
+ else:
content = content.read()
- else:
- raise Exception('Content is of unrecognized type %s' % (
- type(content)
- ))
processed_nodes.append((f_path, content))
message = safe_unicode(message)
diff --git a/kallithea/tests/vcs/test_archives.py b/kallithea/tests/vcs/test_archives.py
--- a/kallithea/tests/vcs/test_archives.py
+++ b/kallithea/tests/vcs/test_archives.py
@@ -37,9 +37,8 @@ class ArchivesTestCaseMixin(_BackendTest
for x in xrange(5):
node_path = '%d/file_%d.txt' % (x, x)
- decompressed = StringIO.StringIO()
- decompressed.write(out.read('repo/' + node_path))
- assert decompressed.getvalue() == self.tip.get_node(node_path).content
+ decompressed = out.read('repo/' + node_path)
+ assert decompressed == self.tip.get_node(node_path).content
def test_archive_tgz(self):
path = tempfile.mkstemp(dir=TESTS_TMP_PATH, prefix='test_archive_tgz-')[1]