Skip to content
This repository was archived by the owner on Apr 14, 2024. It is now read-only.

Commit 18152fe

Browse files
committed
Bumped version to 0.5.1, added changelog to documentation
1 parent ebf1ead commit 18152fe

File tree

6 files changed

+59
-11
lines changed

6 files changed

+59
-11
lines changed

doc/source/changes.rst

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#########
2+
Changelog
3+
#########
4+
*****
5+
0.5.1
6+
*****
7+
* Restored most basic python 2.4 compatibility, such that gitdb can be imported within python 2.4, pack access cannot work though. This at least allows Super-Projects to provide their own workarounds, or use everything but pack support.
8+
9+
*****
10+
0.5.0
11+
*****
12+
Initial Release

doc/source/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
# The short X.Y version.
4848
version = '0.5'
4949
# The full version, including alpha/beta/rc tags.
50-
release = '0.5.0'
50+
release = '0.5.1'
5151

5252
# The language for content autogenerated by Sphinx. Refer to documentation
5353
# for a list of supported languages.

doc/source/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Contents:
1414
intro
1515
tutorial
1616
api
17+
changes
1718

1819
Indices and tables
1920
==================

setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def get_data_files(self):
5656
# END apply setuptools patch too
5757

5858
setup(name = "gitdb",
59-
version = "0.5.0",
59+
version = "0.5.1",
6060
description = "Git Object Database",
6161
author = "Sebastian Thiel",
6262
author_email = "byronimo@gmail.com",
@@ -67,7 +67,7 @@ def get_data_files(self):
6767
package_dir = {'gitdb':''},
6868
ext_modules=[Extension('gitdb._fun', ['_fun.c'])],
6969
license = "BSD License",
70-
requires=('async (>=0.6.0)',),
71-
install_requires='async >= 0.6.0',
70+
requires=('async (>=0.6.1)',),
71+
install_requires='async >= 0.6.1',
7272
long_description = """GitDB is a pure-Python git object database"""
7373
)

stream.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def compressed_bytes_read(self):
170170
def seek(self, offset, whence=getattr(os, 'SEEK_SET', 0)):
171171
"""Allows to reset the stream to restart reading
172172
:raise ValueError: If offset and whence are not 0"""
173-
if offset != 0 or whence != os.SEEK_SET:
173+
if offset != 0 or whence != getattr(os, 'SEEK_SET', 0):
174174
raise ValueError("Can only seek to position 0")
175175
# END handle offset
176176

@@ -411,7 +411,7 @@ def seek(self, offset, whence=getattr(os, 'SEEK_SET', 0)):
411411
"""Allows to reset the stream to restart reading
412412
413413
:raise ValueError: If offset and whence are not 0"""
414-
if offset != 0 or whence != os.SEEK_SET:
414+
if offset != 0 or whence != getattr(os, 'SEEK_SET', 0):
415415
raise ValueError("Can only seek to position 0")
416416
# END handle offset
417417
self._br = 0
@@ -520,7 +520,7 @@ def close(self):
520520
def seek(self, offset, whence=getattr(os, 'SEEK_SET', 0)):
521521
"""Seeking currently only supports to rewind written data
522522
Multiple writes are not supported"""
523-
if offset != 0 or whence != os.SEEK_SET:
523+
if offset != 0 or whence != getattr(os, 'SEEK_SET', 0):
524524
raise ValueError("Can only seek to position 0")
525525
# END handle offset
526526
self.buf.seek(0)

util.py

+39-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
import mmap
44
import sys
55
import errno
6-
import cStringIO
6+
7+
from cStringIO import StringIO
8+
9+
# in py 2.4, StringIO is only StringI, without write support.
10+
# Hence we must use the python implementation for this
11+
if sys.version_info[1] < 5:
12+
from StringIO import StringIO
13+
# END handle python 2.4
714

815
try:
916
import async.mod.zlib as zlib
@@ -73,6 +80,29 @@ def unpack_from(fmt, data, offset=0):
7380

7481
#} END Aliases
7582

83+
#{ compatibility stuff ...
84+
85+
class _RandomAccessStringIO(object):
86+
"""Wrapper to provide required functionality in case memory maps cannot or may
87+
not be used. This is only really required in python 2.4"""
88+
__slots__ = '_sio'
89+
90+
def __init__(self, buf=''):
91+
self._sio = StringIO(buf)
92+
93+
def __getattr__(self, attr):
94+
return getattr(self._sio, attr)
95+
96+
def __len__(self):
97+
return len(self.getvalue())
98+
99+
def __getitem__(self, i):
100+
return self.getvalue()[i]
101+
102+
def __getslice__(self, start, end):
103+
return self.getvalue()[start:end]
104+
105+
#} END compatibility stuff ...
76106

77107
#{ Routines
78108

@@ -94,7 +124,7 @@ def allocate_memory(size):
94124
# this of course may fail if the amount of memory is not available in
95125
# one chunk - would only be the case in python 2.4, being more likely on
96126
# 32 bit systems.
97-
return cStringIO.StringIO("\0"*size)
127+
return _RandomAccessStringIO("\0"*size)
98128
# END handle memory allocation
99129

100130

@@ -109,15 +139,20 @@ def file_contents_ro(fd, stream=False, allow_mmap=True):
109139
try:
110140
if allow_mmap:
111141
# supports stream and random access
112-
return mmap.mmap(fd, 0, access=mmap.ACCESS_READ)
142+
try:
143+
return mmap.mmap(fd, 0, access=mmap.ACCESS_READ)
144+
except EnvironmentError:
145+
# python 2.4 issue, 0 wants to be the actual size
146+
return mmap.mmap(fd, os.fstat(fd).st_size, access=mmap.ACCESS_READ)
147+
# END handle python 2.4
113148
except OSError:
114149
pass
115150
# END exception handling
116151

117152
# read manully
118153
contents = os.read(fd, os.fstat(fd).st_size)
119154
if stream:
120-
return cStringIO.StringIO(contents)
155+
return _RandomAccessStringIO(contents)
121156
return contents
122157

123158
def file_contents_ro_filepath(filepath, stream=False, allow_mmap=True, flags=0):

0 commit comments

Comments
 (0)