Some fixes for supporting python3
* Fix imports.
* Use python3 syntax.
* Wrap map() calls with list().
* Use list() only wherever needed.
(Thanks Conley!)
* Fix dictionary iteration methods
(s/iteritems/items/).
* Make use of sorted() in appropriate places
* Use iterators directly in the loop.
* Don't use .keys() wherever it isn't needed.
* Use sys.maxsize instead of sys.maxint
TODO:
* Make repo work fully with python3. :)
Some of this was done by the '2to3' tool [1], by
applying the needed fixes in a way that doesn't
break compatibility with python2.
Links:
[1]: http://docs.python.org/2/library/2to3.html
Change-Id: Ibdf3bf9a530d716db905733cb9bfef83a48820f7
Signed-off-by: Chirayu Desai <cdesai@cyanogenmod.org>
diff --git a/git_refs.py b/git_refs.py
index cfeffba..4dd6876 100644
--- a/git_refs.py
+++ b/git_refs.py
@@ -66,7 +66,7 @@
def _NeedUpdate(self):
Trace(': scan refs %s', self._gitdir)
- for name, mtime in self._mtime.iteritems():
+ for name, mtime in self._mtime.items():
try:
if mtime != os.path.getmtime(os.path.join(self._gitdir, name)):
return True
@@ -89,7 +89,7 @@
attempts = 0
while scan and attempts < 5:
scan_next = {}
- for name, dest in scan.iteritems():
+ for name, dest in scan.items():
if dest in self._phyref:
self._phyref[name] = self._phyref[dest]
else:
@@ -108,6 +108,7 @@
return
try:
for line in fd:
+ line = str(line)
if line[0] == '#':
continue
if line[0] == '^':
@@ -150,6 +151,10 @@
finally:
fd.close()
+ try:
+ ref_id = ref_id.decode()
+ except AttributeError:
+ pass
if not ref_id:
return
ref_id = ref_id[:-1]