Skip to content

Commit 6f55c17

Browse files
committedJan 4, 2015
Replaced ordered dict with standard version; used logging module
All performance tests still print to stderr, but do so in a py3 compatible way
1 parent 1b9d3b9 commit 6f55c17

21 files changed

+122
-1616
lines changed
 

‎doc/source/conf.py

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
# absolute, like shown here.
2222
#sys.path.append(os.path.abspath('.'))
2323
sys.path.insert(0, os.path.abspath('../..'))
24-
print sys.path
2524

2625
# General configuration
2726
# ---------------------

‎git/cmd.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import os
88
import sys
9+
import logging
910
from util import (
1011
LazyMixin,
1112
stream_copy
@@ -22,6 +23,8 @@
2223
'with_exceptions', 'as_process',
2324
'output_stream')
2425

26+
log = logging.getLogger('git.cmd')
27+
2528
__all__ = ('Git', )
2629

2730

@@ -334,7 +337,7 @@ def execute(self, command,
334337
If you add additional keyword arguments to the signature of this method,
335338
you must update the execute_kwargs tuple housed in this module."""
336339
if self.GIT_PYTHON_TRACE and (self.GIT_PYTHON_TRACE != 'full' or as_process):
337-
print(' '.join(command))
340+
log.info(' '.join(command))
338341

339342
# Allow the user to have the command executed in their working dir.
340343
if with_keep_cwd or self._working_dir is None:
@@ -389,11 +392,11 @@ def execute(self, command,
389392
if self.GIT_PYTHON_TRACE == 'full':
390393
cmdstr = " ".join(command)
391394
if stderr_value:
392-
print("%s -> %d; stdout: '%s'; stderr: '%s'" % (cmdstr, status, stdout_value, stderr_value))
395+
log.info("%s -> %d; stdout: '%s'; stderr: '%s'", cmdstr, status, stdout_value, stderr_value)
393396
elif stdout_value:
394-
print("%s -> %d; stdout: '%s'" % (cmdstr, status, stdout_value))
397+
log.info("%s -> %d; stdout: '%s'", cmdstr, status, stdout_value)
395398
else:
396-
print("%s -> %d" % (cmdstr, status))
399+
log.info("%s -> %d", cmdstr, status)
397400
# END handle debug printing
398401

399402
if with_exceptions and status != 0:

‎git/config.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@
99
import re
1010
import ConfigParser as cp
1111
import inspect
12+
import logging
1213

1314
from git.odict import OrderedDict
1415
from git.util import LockFile
1516

1617
__all__ = ('GitConfigParser', 'SectionConstraint')
1718

1819

20+
log = logging.getLogger('git.config')
21+
22+
1923
class MetaParserBuilder(type):
2024

2125
"""Utlity class wrapping base-class methods into decorators that assure read-only properties"""
@@ -186,8 +190,8 @@ def __del__(self):
186190
try:
187191
try:
188192
self.write()
189-
except IOError as e:
190-
print("Exception during destruction of GitConfigParser: %s" % str(e))
193+
except IOError:
194+
log.error("Exception during destruction of GitConfigParser", exc_info=True)
191195
finally:
192196
self._lock._release_lock()
193197

‎git/objects/commit.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
altzone
3232
)
3333
import os
34-
import sys
34+
import logging
35+
36+
log = logging.getLogger('git.objects.commit')
3537

3638
__all__ = ('Commit', )
3739

@@ -473,16 +475,16 @@ def _deserialize(self, stream):
473475
try:
474476
self.author.name = self.author.name.decode(self.encoding)
475477
except UnicodeDecodeError:
476-
print >> sys.stderr, "Failed to decode author name '%s' using encoding %s" % (
477-
self.author.name, self.encoding)
478+
log.error("Failed to decode author name '%s' using encoding %s", self.author.name, self.encoding,
479+
exc_info=True)
478480
# END handle author's encoding
479481

480482
# decode committer name
481483
try:
482484
self.committer.name = self.committer.name.decode(self.encoding)
483485
except UnicodeDecodeError:
484-
print >> sys.stderr, "Failed to decode committer name '%s' using encoding %s" % (
485-
self.committer.name, self.encoding)
486+
log.error("Failed to decode committer name '%s' using encoding %s", self.committer.name, self.encoding,
487+
exc_info=True)
486488
# END handle author's encoding
487489

488490
# a stream from our data simply gives us the plain message
@@ -491,7 +493,7 @@ def _deserialize(self, stream):
491493
try:
492494
self.message = self.message.decode(self.encoding)
493495
except UnicodeDecodeError:
494-
print >> sys.stderr, "Failed to decode message '%s' using encoding %s" % (self.message, self.encoding)
496+
log.error("Failed to decode message '%s' using encoding %s", self.message, self.encoding, exc_info=True)
495497
# END exception handling
496498
return self
497499

‎git/objects/submodule/base.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@
2727
import git
2828

2929
import os
30-
import sys
30+
import logging
3131

3232
__all__ = ["Submodule", "UpdateProgress"]
3333

3434

35+
log = logging.getLogger('git.objects.submodule.base')
36+
37+
3538
class UpdateProgress(RemoteProgress):
3639

3740
"""Class providing detailed progress information to the caller who should
@@ -408,7 +411,7 @@ def update(self, recursive=False, init=True, to_latest_revision=False, progress=
408411
mrepo.head.set_reference(local_branch, logmsg="submodule: attaching head to %s" % local_branch)
409412
mrepo.head.ref.set_tracking_branch(remote_branch)
410413
except IndexError:
411-
print >> sys.stderr, "Warning: Failed to checkout tracking branch %s" % self.branch_path
414+
log.warn("Failed to checkout tracking branch %s", self.branch_path)
412415
# END handle tracking branch
413416

414417
# NOTE: Have to write the repo config file as well, otherwise
@@ -437,11 +440,10 @@ def update(self, recursive=False, init=True, to_latest_revision=False, progress=
437440
binsha = rcommit.binsha
438441
hexsha = rcommit.hexsha
439442
else:
440-
print >> sys.stderr, "%s a tracking branch was not set for local branch '%s'" % (
441-
msg_base, mrepo.head.ref)
443+
log.error("%s a tracking branch was not set for local branch '%s'", msg_base, mrepo.head.ref)
442444
# END handle remote ref
443445
else:
444-
print >> sys.stderr, "%s there was no local tracking branch" % msg_base
446+
log.error("%s there was no local tracking branch", msg_base)
445447
# END handle detached head
446448
# END handle to_latest_revision option
447449

‎git/objects/submodule/root.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
from git.exc import InvalidGitRepositoryError
66
import git
77

8-
import sys
8+
import logging
99

1010
__all__ = ["RootModule", "RootUpdateProgress"]
1111

12+
log = logging.getLogger('git.objects.submodule.root')
13+
1214

1315
class RootUpdateProgress(UpdateProgress):
1416

@@ -247,8 +249,8 @@ def update(self, previous_commit=None, recursive=True, force_remove=False, init=
247249
# this way, it will be checked out in the next step
248250
# This will change the submodule relative to us, so
249251
# the user will be able to commit the change easily
250-
print >> sys.stderr, "WARNING: Current sha %s was not contained in the tracking\
251-
branch at the new remote, setting it the the remote's tracking branch" % sm.hexsha
252+
log.warn("Current sha %s was not contained in the tracking\
253+
branch at the new remote, setting it the the remote's tracking branch", sm.hexsha)
252254
sm.binsha = rref.commit.binsha
253255
# END reset binsha
254256

‎git/odict.py

+10-1,535
Large diffs are not rendered by default.

‎git/refs/tag.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ class TagReference(Reference):
1313
information in a tag object::
1414
1515
tagref = TagReference.list_items(repo)[0]
16-
print tagref.commit.message
16+
print(tagref.commit.message)
1717
if tagref.tag is not None:
18-
print tagref.tag.message"""
18+
print(tagref.tag.message)"""
1919

2020
__slots__ = tuple()
2121
_common_path_default = "refs/tags"

‎git/test/lib/asserts.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
patch
2828
)
2929

30+
3031
def assert_instance_of(expected, actual, msg=None):
3132
"""Verify that object is an instance of expected """
3233
assert isinstance(actual, expected), msg

‎git/test/lib/helper.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
6-
6+
from __future__ import print_function
77
import os
88
import sys
99
from git import Repo, Remote, GitCommandError, Git
@@ -111,7 +111,7 @@ def repo_creator(self):
111111
try:
112112
return func(self, rw_repo)
113113
except:
114-
print >> sys.stderr, "Keeping repo after failure: %s" % repo_dir
114+
print("Keeping repo after failure: %s" % repo_dir, file=sys.stderr)
115115
repo_dir = None
116116
raise
117117
finally:

‎git/test/performance/test_commit.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
6-
6+
from __future__ import print_function
77
from .lib import TestBigRepoRW
88
from git import Commit
99
from gitdb import IStream
@@ -46,8 +46,8 @@ def test_iteration(self):
4646
# END for each object
4747
# END for each commit
4848
elapsed_time = time() - st
49-
print >> sys.stderr, "Traversed %i Trees and a total of %i unchached objects in %s [s] ( %f objs/s )" % (
50-
nc, no, elapsed_time, no / elapsed_time)
49+
print("Traversed %i Trees and a total of %i unchached objects in %s [s] ( %f objs/s )"
50+
% (nc, no, elapsed_time, no / elapsed_time), file=sys.stderr)
5151

5252
def test_commit_traversal(self):
5353
# bound to cat-file parsing performance
@@ -58,7 +58,8 @@ def test_commit_traversal(self):
5858
self._query_commit_info(c)
5959
# END for each traversed commit
6060
elapsed_time = time() - st
61-
print >> sys.stderr, "Traversed %i Commits in %s [s] ( %f commits/s )" % (nc, elapsed_time, nc / elapsed_time)
61+
print("Traversed %i Commits in %s [s] ( %f commits/s )"
62+
% (nc, elapsed_time, nc / elapsed_time), file=sys.stderr)
6263

6364
def test_commit_iteration(self):
6465
# bound to stream parsing performance
@@ -69,7 +70,8 @@ def test_commit_iteration(self):
6970
self._query_commit_info(c)
7071
# END for each traversed commit
7172
elapsed_time = time() - st
72-
print >> sys.stderr, "Iterated %i Commits in %s [s] ( %f commits/s )" % (nc, elapsed_time, nc / elapsed_time)
73+
print("Iterated %i Commits in %s [s] ( %f commits/s )"
74+
% (nc, elapsed_time, nc / elapsed_time), file=sys.stderr)
7375

7476
def test_commit_serialization(self):
7577
assert_commit_serialization(self.gitrwrepo, self.gitrwrepo.head, True)
@@ -97,5 +99,5 @@ def test_commit_serialization(self):
9799
# END commit creation
98100
elapsed = time() - st
99101

100-
print >> sys.stderr, "Serialized %i commits to loose objects in %f s ( %f commits / s )" % (
101-
nc, elapsed, nc / elapsed)
102+
print("Serialized %i commits to loose objects in %f s ( %f commits / s )"
103+
% (nc, elapsed, nc / elapsed), file=sys.stderr)

‎git/test/performance/test_odb.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Performance tests for object store"""
2-
2+
from __future__ import print_function
33
from time import time
44
import sys
55

@@ -20,8 +20,8 @@ def test_random_access(self):
2020
nc = len(commits)
2121
elapsed = time() - st
2222

23-
print >> sys.stderr, "%s: Retrieved %i commits from ObjectStore in %g s ( %f commits / s )" % (
24-
type(repo.odb), nc, elapsed, nc / elapsed)
23+
print("%s: Retrieved %i commits from ObjectStore in %g s ( %f commits / s )"
24+
% (type(repo.odb), nc, elapsed, nc / elapsed), file=sys.stderr)
2525
results[0].append(elapsed)
2626

2727
# GET TREES
@@ -42,8 +42,8 @@ def test_random_access(self):
4242
# END for each commit
4343
elapsed = time() - st
4444

45-
print >> sys.stderr, "%s: Retrieved %i objects from %i commits in %g s ( %f objects / s )" % (
46-
type(repo.odb), nt, len(commits), elapsed, nt / elapsed)
45+
print("%s: Retrieved %i objects from %i commits in %g s ( %f objects / s )"
46+
% (type(repo.odb), nt, len(commits), elapsed, nt / elapsed), file=sys.stderr)
4747
results[1].append(elapsed)
4848

4949
# GET BLOBS
@@ -63,11 +63,11 @@ def test_random_access(self):
6363

6464
msg = "%s: Retrieved %i blob (%i KiB) and their data in %g s ( %f blobs / s, %f KiB / s )"\
6565
% (type(repo.odb), nb, data_bytes / 1000, elapsed, nb / elapsed, (data_bytes / 1000) / elapsed)
66+
print(msg, file=sys.stderr)
6667
results[2].append(elapsed)
67-
print >> sys.stderr, msg
6868
# END for each repo type
6969

7070
# final results
7171
for test_name, a, b in results:
72-
print >> sys.stderr, "%s: %f s vs %f s, pure is %f times slower" % (test_name, a, b, b / a)
72+
print("%s: %f s vs %f s, pure is %f times slower" % (test_name, a, b, b / a), file=sys.stderr)
7373
# END for each result

‎git/test/performance/test_streams.py

+19-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""Performance data streaming performance"""
2+
from __future__ import print_function
3+
24
from time import time
35
import os
46
import sys
@@ -19,6 +21,7 @@
1921
IStream
2022
)
2123

24+
2225
class TestObjDBPerformance(TestBigRepoR):
2326

2427
large_data_size_bytes = 1000 * 1000 * 10 # some MiB should do it
@@ -32,11 +35,11 @@ def test_large_data_streaming(self, rwrepo):
3235

3336
for randomize in range(2):
3437
desc = (randomize and 'random ') or ''
35-
print >> sys.stderr, "Creating %s data ..." % desc
38+
print("Creating %s data ..." % desc, file=sys.stderr)
3639
st = time()
3740
size, stream = make_memory_file(self.large_data_size_bytes, randomize)
3841
elapsed = time() - st
39-
print >> sys.stderr, "Done (in %f s)" % elapsed
42+
print("Done (in %f s)" % elapsed, file=sys.stderr)
4043

4144
# writing - due to the compression it will seem faster than it is
4245
st = time()
@@ -49,7 +52,7 @@ def test_large_data_streaming(self, rwrepo):
4952
size_kib = size / 1000
5053
msg = "Added %i KiB (filesize = %i KiB) of %s data to loose odb in %f s ( %f Write KiB / s)"
5154
msg %= (size_kib, fsize_kib, desc, elapsed_add, size_kib / elapsed_add)
52-
print >> sys.stderr, msg
55+
print(msg, file=sys.stderr)
5356

5457
# reading all at once
5558
st = time()
@@ -61,7 +64,7 @@ def test_large_data_streaming(self, rwrepo):
6164
assert shadata == stream.getvalue()
6265
msg = "Read %i KiB of %s data at once from loose odb in %f s ( %f Read KiB / s)"
6366
msg %= (size_kib, desc, elapsed_readall, size_kib / elapsed_readall)
64-
print >> sys.stderr, msg
67+
print(msg, file=sys.stderr)
6568

6669
# reading in chunks of 1 MiB
6770
cs = 512 * 1000
@@ -80,8 +83,8 @@ def test_large_data_streaming(self, rwrepo):
8083
assert ''.join(chunks) == stream.getvalue()
8184

8285
cs_kib = cs / 1000
83-
print >> sys.stderr, "Read %i KiB of %s data in %i KiB chunks from loose odb in %f s ( %f Read KiB / s)" % (
84-
size_kib, desc, cs_kib, elapsed_readchunks, size_kib / elapsed_readchunks)
86+
print("Read %i KiB of %s data in %i KiB chunks from loose odb in %f s ( %f Read KiB / s)"
87+
% (size_kib, desc, cs_kib, elapsed_readchunks, size_kib / elapsed_readchunks), file=sys.stderr)
8588

8689
# del db file so git has something to do
8790
os.remove(db_file)
@@ -106,22 +109,22 @@ def test_large_data_streaming(self, rwrepo):
106109
fsize_kib = os.path.getsize(db_file) / 1000
107110
msg = "Added %i KiB (filesize = %i KiB) of %s data to using git-hash-object in %f s ( %f Write KiB / s)"
108111
msg %= (size_kib, fsize_kib, desc, gelapsed_add, size_kib / gelapsed_add)
109-
print >> sys.stderr, msg
112+
print(msg, file=sys.stderr)
110113

111114
# compare ...
112-
print >> sys.stderr, "Git-Python is %f %% faster than git when adding big %s files" % (
113-
100.0 - (elapsed_add / gelapsed_add) * 100, desc)
115+
print("Git-Python is %f %% faster than git when adding big %s files"
116+
% (100.0 - (elapsed_add / gelapsed_add) * 100, desc), file=sys.stderr)
114117

115118
# read all
116119
st = time()
117120
s, t, size, data = rwrepo.git.get_object_data(gitsha)
118121
gelapsed_readall = time() - st
119-
print >> sys.stderr, "Read %i KiB of %s data at once using git-cat-file in %f s ( %f Read KiB / s)" % (
120-
size_kib, desc, gelapsed_readall, size_kib / gelapsed_readall)
122+
print("Read %i KiB of %s data at once using git-cat-file in %f s ( %f Read KiB / s)"
123+
% (size_kib, desc, gelapsed_readall, size_kib / gelapsed_readall), file=sys.stderr)
121124

122125
# compare
123-
print >> sys.stderr, "Git-Python is %f %% faster than git when reading big %sfiles" % (
124-
100.0 - (elapsed_readall / gelapsed_readall) * 100, desc)
126+
print("Git-Python is %f %% faster than git when reading big %sfiles"
127+
% (100.0 - (elapsed_readall / gelapsed_readall) * 100, desc), file=sys.stderr)
125128

126129
# read chunks
127130
st = time()
@@ -134,9 +137,9 @@ def test_large_data_streaming(self, rwrepo):
134137
gelapsed_readchunks = time() - st
135138
msg = "Read %i KiB of %s data in %i KiB chunks from git-cat-file in %f s ( %f Read KiB / s)"
136139
msg %= (size_kib, desc, cs_kib, gelapsed_readchunks, size_kib / gelapsed_readchunks)
137-
print >> sys.stderr, msg
140+
print(msg, file=sys.stderr)
138141

139142
# compare
140-
print >> sys.stderr, "Git-Python is %f %% faster than git when reading big %s files in chunks" % (
141-
100.0 - (elapsed_readchunks / gelapsed_readchunks) * 100, desc)
143+
print ("Git-Python is %f %% faster than git when reading big %s files in chunks"
144+
% (100.0 - (elapsed_readchunks / gelapsed_readchunks) * 100, desc), file=sys.stderr)
142145
# END for each randomization factor

‎git/test/performance/test_utils.py

+25-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Performance of utilities"""
2+
from __future__ import print_function
23
from time import time
34
import sys
45

@@ -43,8 +44,8 @@ def __init__(self):
4344
cli.attr
4445
# END for each access
4546
elapsed = time() - st
46-
print >> sys.stderr, "Accessed %s.attr %i times in %s s ( %f acc / s)" % (
47-
cls.__name__, ni, elapsed, ni / elapsed)
47+
print("Accessed %s.attr %i times in %s s ( %f acc / s)"
48+
% (cls.__name__, ni, elapsed, ni / elapsed), file=sys.stderr)
4849
# END for each class type
4950

5051
# check num of sequence-acceses
@@ -59,8 +60,8 @@ def __init__(self):
5960
# END for
6061
elapsed = time() - st
6162
na = ni * 3
62-
print >> sys.stderr, "Accessed %s[x] %i times in %s s ( %f acc / s)" % (
63-
cls.__name__, na, elapsed, na / elapsed)
63+
print("Accessed %s[x] %i times in %s s ( %f acc / s)"
64+
% (cls.__name__, na, elapsed, na / elapsed), file=sys.stderr)
6465
# END for each sequence
6566

6667
def test_instantiation(self):
@@ -85,8 +86,8 @@ def test_instantiation(self):
8586
# END handle empty cls
8687
# END for each item
8788
elapsed = time() - st
88-
print >> sys.stderr, "Created %i %ss of size %i in %f s ( %f inst / s)" % (
89-
ni, cls.__name__, mni, elapsed, ni / elapsed)
89+
print("Created %i %ss of size %i in %f s ( %f inst / s)"
90+
% (ni, cls.__name__, mni, elapsed, ni / elapsed), file=sys.stderr)
9091
# END for each type
9192
# END for each item count
9293

@@ -96,14 +97,16 @@ def test_instantiation(self):
9697
(1, 2, 3, 4)
9798
# END for each item
9899
elapsed = time() - st
99-
print >> sys.stderr, "Created %i tuples (1,2,3,4) in %f s ( %f tuples / s)" % (ni, elapsed, ni / elapsed)
100+
print("Created %i tuples (1,2,3,4) in %f s ( %f tuples / s)"
101+
% (ni, elapsed, ni / elapsed), file=sys.stderr)
100102

101103
st = time()
102104
for i in xrange(ni):
103105
tuple((1, 2, 3, 4))
104106
# END for each item
105107
elapsed = time() - st
106-
print >> sys.stderr, "Created %i tuples tuple((1,2,3,4)) in %f s ( %f tuples / s)" % (ni, elapsed, ni / elapsed)
108+
print("Created %i tuples tuple((1,2,3,4)) in %f s ( %f tuples / s)"
109+
% (ni, elapsed, ni / elapsed), file=sys.stderr)
107110

108111
def test_unpacking_vs_indexing(self):
109112
ni = 1000000
@@ -116,24 +119,24 @@ def test_unpacking_vs_indexing(self):
116119
one, two, three, four = sequence
117120
# END for eac iteration
118121
elapsed = time() - st
119-
print >> sys.stderr, "Unpacked %i %ss of size %i in %f s ( %f acc / s)" % (
120-
ni, type(sequence).__name__, len(sequence), elapsed, ni / elapsed)
122+
print("Unpacked %i %ss of size %i in %f s ( %f acc / s)"
123+
% (ni, type(sequence).__name__, len(sequence), elapsed, ni / elapsed), file=sys.stderr)
121124

122125
st = time()
123126
for i in xrange(ni):
124127
one, two, three, four = sequence[0], sequence[1], sequence[2], sequence[3]
125128
# END for eac iteration
126129
elapsed = time() - st
127-
print >> sys.stderr, "Unpacked %i %ss of size %i individually in %f s ( %f acc / s)" % (
128-
ni, type(sequence).__name__, len(sequence), elapsed, ni / elapsed)
130+
print("Unpacked %i %ss of size %i individually in %f s ( %f acc / s)"
131+
% (ni, type(sequence).__name__, len(sequence), elapsed, ni / elapsed), file=sys.stderr)
129132

130133
st = time()
131134
for i in xrange(ni):
132135
one, two = sequence[0], sequence[1]
133136
# END for eac iteration
134137
elapsed = time() - st
135-
print >> sys.stderr, "Unpacked %i %ss of size %i individually (2 of 4) in %f s ( %f acc / s)" % (
136-
ni, type(sequence).__name__, len(sequence), elapsed, ni / elapsed)
138+
print("Unpacked %i %ss of size %i individually (2 of 4) in %f s ( %f acc / s)"
139+
% (ni, type(sequence).__name__, len(sequence), elapsed, ni / elapsed), file=sys.stderr)
137140
# END for each sequence
138141

139142
def test_large_list_vs_iteration(self):
@@ -150,14 +153,16 @@ def slow_iter(ni):
150153
i
151154
# END for each item
152155
elapsed = time() - st
153-
print >> sys.stderr, "Iterated %i items from list in %f s ( %f acc / s)" % (ni, elapsed, ni / elapsed)
156+
print("Iterated %i items from list in %f s ( %f acc / s)"
157+
% (ni, elapsed, ni / elapsed), file=sys.stderr)
154158

155159
st = time()
156160
for i in slow_iter(ni):
157161
i
158162
# END for each item
159163
elapsed = time() - st
160-
print >> sys.stderr, "Iterated %i items from iterator in %f s ( %f acc / s)" % (ni, elapsed, ni / elapsed)
164+
print("Iterated %i items from iterator in %f s ( %f acc / s)"
165+
% (ni, elapsed, ni / elapsed), file=sys.stderr)
161166
# END for each number of iterations
162167

163168
def test_type_vs_inst_class(self):
@@ -173,12 +178,13 @@ class NewType(object):
173178
inst.__class__()
174179
# END for each item
175180
elapsed = time() - st
176-
print >> sys.stderr, "Created %i items using inst.__class__ in %f s ( %f items / s)" % (
177-
ni, elapsed, ni / elapsed)
181+
print("Created %i items using inst.__class__ in %f s ( %f items / s)"
182+
% (ni, elapsed, ni / elapsed), file=sys.stderr)
178183

179184
st = time()
180185
for i in xrange(ni):
181186
type(inst)()
182187
# END for each item
183188
elapsed = time() - st
184-
print >> sys.stderr, "Created %i items using type(inst)() in %f s ( %f items / s)" % (ni, elapsed, ni / elapsed)
189+
print("Created %i items using type(inst)() in %f s ( %f items / s)"
190+
% (ni, elapsed, ni / elapsed), file=sys.stderr)

‎git/test/test_actor.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from git.test.lib import assert_equal
88
from git import Actor
99

10+
1011
class TestActor(object):
1112

1213
def test_from_string_should_separate_name_and_email(self):

‎git/test/test_commit.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#
55
# This module is part of GitPython and is released under
66
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
7+
from __future__ import print_function
78

89
from git.test.lib import (
910
TestBase,
@@ -72,8 +73,8 @@ def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False)
7273
elapsed = time.time() - st
7374

7475
if print_performance_info:
75-
print >> sys.stderr, "Serialized %i and deserialized %i commits in %f s ( (%f, %f) commits / s" % (
76-
ns, nds, elapsed, ns / elapsed, nds / elapsed)
76+
print("Serialized %i and deserialized %i commits in %f s ( (%f, %f) commits / s"
77+
% (ns, nds, elapsed, ns / elapsed, nds / elapsed), file=sys.stderr)
7778
# END handle performance info
7879

7980

‎git/test/test_config.py

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def test_read_write(self):
6464

6565
file_obj.seek(0)
6666
r_config = GitConfigParser(file_obj, read_only=True)
67-
# print file_obj.getvalue()
6867
assert r_config.has_section(sname)
6968
assert r_config.has_option(sname, oname)
7069
assert r_config.get(sname, oname) == val

‎git/test/test_diff.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
DiffIndex
1919
)
2020

21+
2122
class TestDiff(TestBase):
2223

2324
def _assert_diff_format(self, diffs):

‎git/test/test_git.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def test_it_transforms_kwargs_into_git_command_arguments(self):
5050
assert_equal(["--max-count"], self.git.transform_kwargs(**{'max_count': True}))
5151
assert_equal(["--max-count=5"], self.git.transform_kwargs(**{'max_count': 5}))
5252

53-
assert_equal(["-s", "-t"], self.git.transform_kwargs(**{'s': True, 't': True}))
53+
# order is undefined
54+
res = self.git.transform_kwargs(**{'s': True, 't': True})
55+
assert ['-s', '-t'] == res or ['-t', '-s'] == res
5456

5557
def test_it_executes_git_to_shell_and_returns_result(self):
5658
assert_match('^git version [\d\.]{2}.*$', self.git.execute(["git", "version"]))

‎git/test/test_index.py

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
Diff,
2020
GitCommandError,
2121
CheckoutError,
22-
2322
)
2423
from gitdb.util import hex_to_bin
2524
import os

‎setup.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
from __future__ import print_function
23
try:
34
from setuptools import setup, find_packages
45
except ImportError:
@@ -49,7 +50,7 @@ def _stamp_version(filename):
4950
try:
5051
f = open(filename, 'r')
5152
except (IOError, OSError):
52-
print >> sys.stderr, "Couldn't find file %s to stamp version" % filename
53+
print("Couldn't find file %s to stamp version" % filename, file=sys.stderr)
5354
return
5455
# END handle error, usually happens during binary builds
5556
for line in f:
@@ -64,9 +65,12 @@ def _stamp_version(filename):
6465
f.writelines(out)
6566
f.close()
6667
else:
67-
print >> sys.stderr, "WARNING: Couldn't find version line in file %s" % filename
68+
print("WARNING: Couldn't find version line in file %s" % filename, file=sys.stderr)
6869

6970
install_requires = ['gitdb >= 0.6.1']
71+
if sys.version_info[:2] < (2, 7):
72+
install_requires.append('ordereddict')
73+
# end
7074

7175
setup(
7276
name="GitPython",

0 commit comments

Comments
 (0)
Please sign in to comment.