aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/storage/vcs/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'libbe/storage/vcs/base.py')
-rw-r--r--libbe/storage/vcs/base.py38
1 files changed, 19 insertions, 19 deletions
diff --git a/libbe/storage/vcs/base.py b/libbe/storage/vcs/base.py
index 687575f..dfd007f 100644
--- a/libbe/storage/vcs/base.py
+++ b/libbe/storage/vcs/base.py
@@ -255,7 +255,7 @@ class CachedPathID (object):
def disconnect(self):
if self._changed == True:
f = codecs.open(self._cache_path, 'w', self.encoding)
- for uuid,path in self._cache.items():
+ for uuid,path in list(self._cache.items()):
f.write('%s\t%s\n' % (uuid, path))
f.close()
self._cache = {}
@@ -558,12 +558,12 @@ class VCS (libbe.storage.base.VersionedStorage):
for num in num_part.split('.'):
try:
self._parsed_version.append(int(num))
- except ValueError, e:
+ except ValueError as e:
# bzr version number might contain non-numerical tags
splitter = re.compile(r'[\D]') # Match non-digits
splits = splitter.split(num)
# if len(tag) > 1 some splits will be empty; remove
- splits = filter(lambda s: s != '', splits)
+ splits = [s for s in splits if s != '']
tag_starti = len(splits[0])
num_starti = num.find(splits[1], tag_starti)
tag = num[tag_starti:num_starti]
@@ -573,7 +573,7 @@ class VCS (libbe.storage.base.VersionedStorage):
for current,other in zip(self._parsed_version, args):
if type(current) != type (other):
# one of them is a pre-release string
- if type(current) != types.IntType:
+ if type(current) != int:
return -1
else:
return 1
@@ -586,12 +586,12 @@ class VCS (libbe.storage.base.VersionedStorage):
if verlen == arglen:
return 0
elif verlen > arglen:
- if type(self._parsed_version[arglen]) != types.IntType:
+ if type(self._parsed_version[arglen]) != int:
return -1 # self is a prerelease
else:
return 1
else:
- if type(args[verlen]) != types.IntType:
+ if type(args[verlen]) != int:
return 1 # args is a prerelease
else:
return -1
@@ -732,7 +732,7 @@ class VCS (libbe.storage.base.VersionedStorage):
if revision == None:
try:
path = self.path(id, revision, relpath=False)
- except InvalidID, e:
+ except InvalidID as e:
return False
return os.path.exists(path)
path = self.path(id, revision, relpath=True)
@@ -763,7 +763,7 @@ class VCS (libbe.storage.base.VersionedStorage):
if os.path.exists(path):
shutil.rmtree(path)
path = self._cached_path_id.path(id, relpath=True)
- for id,p in self._cached_path_id._cache.items():
+ for id,p in list(self._cached_path_id._cache.items()):
if p.startswith(path):
self._cached_path_id.remove_id(id)
@@ -818,7 +818,7 @@ class VCS (libbe.storage.base.VersionedStorage):
try:
relpath = self.path(id, revision, relpath=True)
contents = self._vcs_get_file_contents(relpath, revision)
- except InvalidID, e:
+ except InvalidID as e:
if default == libbe.util.InvalidObject:
raise e
return default
@@ -833,7 +833,7 @@ class VCS (libbe.storage.base.VersionedStorage):
def _set(self, id, value):
try:
path = self._cached_path_id.path(id)
- except InvalidID, e:
+ except InvalidID as e:
raise
if not os.path.exists(path):
raise InvalidID(id)
@@ -923,7 +923,7 @@ class VCS (libbe.storage.base.VersionedStorage):
"""
try:
ret = search_parent_directories(path, filename)
- except AssertionError, e:
+ except AssertionError as e:
return None
return ret
@@ -1054,8 +1054,8 @@ class VCS (libbe.storage.base.VersionedStorage):
path, decode=True).rstrip()
relpath = self._u_rel_path(path)
contents = self._vcs_get_file_contents(relpath, revision=revision)
- if type(contents) != types.UnicodeType:
- contents = unicode(contents, self.encoding)
+ if type(contents) != str:
+ contents = str(contents, self.encoding)
return contents.strip()
def _setup_storage_version(self):
@@ -1104,7 +1104,7 @@ if libbe.TESTING == True:
def test_installed(self):
"""See if the VCS is installed.
"""
- self.failUnless(self.s.installed() == True,
+ self.assertTrue(self.s.installed() == True,
'%(name)s VCS not found' % vars(self.Class))
@@ -1114,7 +1114,7 @@ if libbe.TESTING == True:
"""
if self.s.installed():
self.s.disconnect()
- self.failUnless(self.s._detect(self.dirname) == True,
+ self.assertTrue(self.s._detect(self.dirname) == True,
'Did not detected %(name)s VCS after initialising'
% vars(self.Class))
self.s.connect()
@@ -1125,7 +1125,7 @@ if libbe.TESTING == True:
if self.s.installed() and self.Class.name != 'None':
self.s.disconnect()
self.s.destroy()
- self.failUnless(self.s._detect(self.dirname) == False,
+ self.assertTrue(self.s._detect(self.dirname) == False,
'Detected %(name)s VCS before initialising'
% vars(self.Class))
self.s.init()
@@ -1136,7 +1136,7 @@ if libbe.TESTING == True:
rp = os.path.realpath(self.s.repo)
dp = os.path.realpath(self.dirname)
vcs_name = self.Class.name
- self.failUnless(
+ self.assertTrue(
dp == rp or rp == None,
"%(vcs_name)s VCS root in wrong dir (%(dp)s %(rp)s)" % vars())
@@ -1151,7 +1151,7 @@ if libbe.TESTING == True:
return
name,email = libbe.ui.util.user.parse_user_id(user_id)
if email != None:
- self.failUnless('@' in email, email)
+ self.assertTrue('@' in email, email)
def make_vcs_testcase_subclasses(vcs_class, namespace):
c = vcs_class()
@@ -1167,7 +1167,7 @@ if libbe.TESTING == True:
# Make VCSTestCase subclasses for vcs_class in the namespace.
vcs_testcase_classes = [
c for c in (
- ob for ob in globals().values() if isinstance(ob, type))
+ ob for ob in list(globals().values()) if isinstance(ob, type))
if issubclass(c, VCSTestCase) \
and c.Class == VCS]