Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6f55c17

Browse files
committed
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 parent1b9d3b9 commit6f55c17

21 files changed

+122
-1616
lines changed

‎doc/source/conf.py

Lines changed: 0 additions & 1 deletion
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-
printsys.path
2524

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

‎git/cmd.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
importos
88
importsys
9+
importlogging
910
fromutilimport (
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
ifself.GIT_PYTHON_TRACEand (self.GIT_PYTHON_TRACE!='full'oras_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
ifwith_keep_cwdorself._working_dirisNone:
@@ -389,11 +392,11 @@ def execute(self, command,
389392
ifself.GIT_PYTHON_TRACE=='full':
390393
cmdstr=" ".join(command)
391394
ifstderr_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
elifstdout_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
ifwith_exceptionsandstatus!=0:

‎git/config.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@
99
importre
1010
importConfigParserascp
1111
importinspect
12+
importlogging
1213

1314
fromgit.odictimportOrderedDict
1415
fromgit.utilimportLockFile
1516

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

1819

20+
log=logging.getLogger('git.config')
21+
22+
1923
classMetaParserBuilder(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-
exceptIOErrorase:
190-
print("Exception during destruction of GitConfigParser: %s"%str(e))
193+
exceptIOError:
194+
log.error("Exception during destruction of GitConfigParser",exc_info=True)
191195
finally:
192196
self._lock._release_lock()
193197

‎git/objects/commit.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
altzone
3232
)
3333
importos
34-
importsys
34+
importlogging
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
exceptUnicodeDecodeError:
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
exceptUnicodeDecodeError:
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
exceptUnicodeDecodeError:
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
returnself
497499

‎git/objects/submodule/base.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@
2727
importgit
2828

2929
importos
30-
importsys
30+
importlogging
3131

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

3434

35+
log=logging.getLogger('git.objects.submodule.base')
36+
37+
3538
classUpdateProgress(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
exceptIndexError:
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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
fromgit.excimportInvalidGitRepositoryError
66
importgit
77

8-
importsys
8+
importlogging
99

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

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

1315
classRootUpdateProgress(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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp