Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 522c50c

Browse files
committed
Updated to import by Python 3
1 parent 0b820e6 commit 522c50c

File tree

8 files changed

+102
-103
lines changed

8 files changed

+102
-103
lines changed

git/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ def _init_externals():
4949

5050
#} END imports
5151

52-
__all__ = [ name for name, obj in locals().items()
52+
__all__ = [ name for name, obj in list(locals().items())
5353
if not (name.startswith('_') or inspect.ismodule(obj)) ]
5454

git/cmd.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

77
import os, sys
8-
from util import (
8+
from .util import (
99
LazyMixin,
1010
stream_copy
1111
)
12-
from exc import GitCommandError
12+
from .exc import GitCommandError
1313

1414
from subprocess import (
1515
call,
@@ -192,7 +192,7 @@ def readlines(self, size=-1):
192192
def __iter__(self):
193193
return self
194194

195-
def next(self):
195+
def __next__(self):
196196
line = self.readline()
197197
if not line:
198198
raise StopIteration
@@ -321,7 +321,7 @@ def execute(self, command,
321321
If you add additional keyword arguments to the signature of this method,
322322
you must update the execute_kwargs tuple housed in this module."""
323323
if self.GIT_PYTHON_TRACE and not self.GIT_PYTHON_TRACE == 'full':
324-
print ' '.join(command)
324+
print(' '.join(command))
325325

326326
# Allow the user to have the command executed in their working dir.
327327
if with_keep_cwd or self._working_dir is None:
@@ -370,11 +370,11 @@ def execute(self, command,
370370
if self.GIT_PYTHON_TRACE == 'full':
371371
cmdstr = " ".join(command)
372372
if stderr_value:
373-
print "%s -> %d; stdout: '%s'; stderr: '%s'" % (cmdstr, status, stdout_value, stderr_value)
373+
print("%s -> %d; stdout: '%s'; stderr: '%s'" % (cmdstr, status, stdout_value, stderr_value))
374374
elif stdout_value:
375-
print "%s -> %d; stdout: '%s'" % (cmdstr, status, stdout_value)
375+
print("%s -> %d; stdout: '%s'" % (cmdstr, status, stdout_value))
376376
else:
377-
print "%s -> %d" % (cmdstr, status)
377+
print("%s -> %d" % (cmdstr, status))
378378
# END handle debug printing
379379

380380
if with_exceptions and status != 0:
@@ -389,7 +389,7 @@ def execute(self, command,
389389
def transform_kwargs(self, **kwargs):
390390
"""Transforms Python style kwargs into git command line options."""
391391
args = list()
392-
for k, v in kwargs.items():
392+
for k, v in list(kwargs.items()):
393393
if len(k) == 1:
394394
if v is True:
395395
args.append("-%s" % k)

git/config.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
import re
1010
import os
11-
import ConfigParser as cp
11+
import configparser as cp
1212
import inspect
13-
import cStringIO
13+
import io
1414

1515
from git.odict import OrderedDict
1616
from git.util import LockFile
@@ -97,7 +97,7 @@ def config(self):
9797
return self._config
9898

9999

100-
class GitConfigParser(cp.RawConfigParser, object):
100+
class GitConfigParser(cp.RawConfigParser, object, metaclass=MetaParserBuilder):
101101
"""Implements specifics required to read git style configuration files.
102102
103103
This variation behaves much like the git.config command such that the configuration
@@ -112,7 +112,6 @@ class GitConfigParser(cp.RawConfigParser, object):
112112
:note:
113113
The config is case-sensitive even when queried, hence section and option names
114114
must match perfectly."""
115-
__metaclass__ = MetaParserBuilder
116115

117116

118117
#{ Configuration
@@ -163,7 +162,7 @@ def __init__(self, file_or_files, read_only=True):
163162
raise ValueError("Write-ConfigParsers can operate on a single file only, multiple files have been passed")
164163
# END single file check
165164

166-
if not isinstance(file_or_files, basestring):
165+
if not isinstance(file_or_files, str):
167166
file_or_files = file_or_files.name
168167
# END get filename from handle/stream
169168
# initialize lock base - we want to write
@@ -183,8 +182,8 @@ def __del__(self):
183182
try:
184183
try:
185184
self.write()
186-
except IOError,e:
187-
print "Exception during destruction of GitConfigParser: %s" % str(e)
185+
except IOError as e:
186+
print("Exception during destruction of GitConfigParser: %s" % str(e))
188187
finally:
189188
self._lock._release_lock()
190189

@@ -283,7 +282,7 @@ def read(self):
283282
try:
284283
fp = open(file_object)
285284
close_fp = True
286-
except IOError,e:
285+
except IOError as e:
287286
continue
288287
# END fp handling
289288

@@ -301,15 +300,15 @@ def _write(self, fp):
301300
git compatible format"""
302301
def write_section(name, section_dict):
303302
fp.write("[%s]\n" % name)
304-
for (key, value) in section_dict.items():
303+
for (key, value) in list(section_dict.items()):
305304
if key != "__name__":
306305
fp.write("\t%s = %s\n" % (key, str(value).replace('\n', '\n\t')))
307306
# END if key is not __name__
308307
# END section writing
309308

310309
if self._defaults:
311310
write_section(cp.DEFAULTSECT, self._defaults)
312-
map(lambda t: write_section(t[0],t[1]), self._sections.items())
311+
list(map(lambda t: write_section(t[0],t[1]), list(self._sections.items())))
313312

314313

315314
@needs_values
@@ -324,7 +323,7 @@ def write(self):
324323
close_fp = False
325324

326325
# we have a physical file on disk, so get a lock
327-
if isinstance(fp, (basestring, file)):
326+
if isinstance(fp, (str, file)):
328327
self._lock._obtain_lock()
329328
# END get lock for physical files
330329

@@ -382,7 +381,7 @@ def get_value(self, section, option, default = None):
382381
return default
383382
raise
384383

385-
types = ( long, float )
384+
types = ( int, float )
386385
for numtype in types:
387386
try:
388387
val = numtype( valuestr )
@@ -403,7 +402,7 @@ def get_value(self, section, option, default = None):
403402
if vl == 'true':
404403
return True
405404

406-
if not isinstance( valuestr, basestring ):
405+
if not isinstance( valuestr, str ):
407406
raise TypeError( "Invalid value type: only int, long, float and str are allowed", valuestr )
408407

409408
return valuestr

git/db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Module with our own gitdb implementation - it uses the git command"""
2-
from exc import (
2+
from .exc import (
33
GitCommandError,
44
BadObject
55
)

git/diff.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

77
import re
8-
from objects.blob import Blob
9-
from objects.util import mode_str_to_int
10-
from exc import GitCommandError
8+
from .objects.blob import Blob
9+
from .objects.util import mode_str_to_int
10+
from .exc import GitCommandError
1111

1212
from gitdb.util import hex_to_bin
1313

0 commit comments

Comments
 (0)