Skip to content

Commit

Permalink
Ported to python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
btimby committed Jun 4, 2013
1 parent bfdd5c7 commit 3021654
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: python
python:
- "2.6"
- "2.7"
- "3.2"
before_install:
- sudo apt-get install -qq librsync1
install:
Expand All @@ -14,4 +15,4 @@ before_script:
script:
- make test
after_success:
- coveralls
- coveralls
10 changes: 3 additions & 7 deletions librsync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@

from functools import wraps

try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO

if os.name == 'posix':
path = ctypes.util.find_library('rsync')
Expand Down Expand Up @@ -169,7 +165,7 @@ def signature(f, s=None, block_size=RS_DEFAULT_BLOCK_LEN):
optional `block_size` parameter.
"""
if s is None:
s = tempfile.SpooledTemporaryFile(max_size=MAX_SPOOL)
s = tempfile.SpooledTemporaryFile(max_size=MAX_SPOOL, mode='wb')
job = _librsync.rs_sig_begin(block_size, RS_DEFAULT_STRONG_LEN)
try:
_execute(job, f, s)
Expand All @@ -187,7 +183,7 @@ def delta(f, s, d=None):
objects.
"""
if d is None:
d = tempfile.SpooledTemporaryFile(max_size=MAX_SPOOL)
d = tempfile.SpooledTemporaryFile(max_size=MAX_SPOOL, mode='wb')
sig = ctypes.c_void_p()
job = _librsync.rs_loadsig_begin(ctypes.byref(sig))
try:
Expand Down Expand Up @@ -215,7 +211,7 @@ def patch(f, d, o=None):
required to be seekable.
"""
if o is None:
o = tempfile.SpooledTemporaryFile(max_size=MAX_SPOOL)
o = tempfile.SpooledTemporaryFile(max_size=MAX_SPOOL, mode='wb')

@patch_callback
def read_cb(pos, length, buff):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
coverage
coveralls
coveralls
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
version = '0.1'
release = '4'
versrel = version + '-' + release
readme = os.path.join(os.path.dirname(__file__), 'README.rst')
long_description = file(readme).read()
long_description = open(os.path.join(os.path.dirname(__file__), 'README.rst'), 'r').read()

setup(
name = name,
Expand Down
5 changes: 4 additions & 1 deletion tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

import librsync

from StringIO import StringIO
try:
from StringIO import StringIO
except ImportError:
from io import BytesIO as StringIO


class TraceLevelTestCase(unittest.TestCase):
Expand Down

0 comments on commit 3021654

Please sign in to comment.