2
0
Эх сурвалжийг харах

Add SEEK_END to misc.py, since it was added in 2.5.

Change-Id: I9caa891e53423b444063b2801da4043489647703
Dave Borowitz 15 жил өмнө
parent
commit
cc8bfb0656

+ 5 - 0
dulwich/misc.py

@@ -30,6 +30,11 @@ try:
 except ImportError:
     from cgi import parse_qs
 
+try:
+    from os import SEEK_END
+except ImportError:
+    SEEK_END = 2
+
 import struct
 
 

+ 2 - 1
dulwich/pack.py

@@ -67,6 +67,7 @@ from dulwich.lru_cache import (
     )
 from dulwich.misc import (
     make_sha,
+    SEEK_END,
     )
 from dulwich.objects import (
     ShaFile,
@@ -553,7 +554,7 @@ class PackStreamReader(object):
     def _buf_len(self):
         buf = self._rbuf
         start = buf.tell()
-        buf.seek(0, os.SEEK_END)
+        buf.seek(0, SEEK_END)
         end = buf.tell()
         buf.seek(start)
         return end - start

+ 6 - 3
dulwich/protocol.py

@@ -27,6 +27,9 @@ from dulwich.errors import (
     HangupException,
     GitProtocolError,
     )
+from dulwich.misc import (
+    SEEK_END,
+    )
 
 TCP_GIT_PORT = 9418
 
@@ -193,7 +196,7 @@ class ReceivableProtocol(Protocol):
         #  - omit the size <= 0 branch
         #  - seek back to start rather than 0 in case some buffer has been
         #    consumed.
-        #  - use os.SEEK_END instead of the magic number.
+        #  - use SEEK_END instead of the magic number.
         # Copyright (c) 2001-2010 Python Software Foundation; All Rights Reserved
         # Licensed under the Python Software Foundation License.
         # TODO: see if buffer is more efficient than cStringIO.
@@ -204,7 +207,7 @@ class ReceivableProtocol(Protocol):
         # rbufsize is large compared to the typical return value of recv().
         buf = self._rbuf
         start = buf.tell()
-        buf.seek(0, os.SEEK_END)
+        buf.seek(0, SEEK_END)
         # buffer may have been partially consumed by recv()
         buf_len = buf.tell() - start
         if buf_len >= size:
@@ -252,7 +255,7 @@ class ReceivableProtocol(Protocol):
 
         buf = self._rbuf
         start = buf.tell()
-        buf.seek(0, os.SEEK_END)
+        buf.seek(0, SEEK_END)
         buf_len = buf.tell()
         buf.seek(start)