From 217ea7d2747e3098009afe0b389fc4b45f55ea5a Mon Sep 17 00:00:00 2001 From: Chirayu Desai Date: Fri, 1 Mar 2013 19:14:38 +0530 Subject: 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 --- git_refs.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'git_refs.py') diff --git a/git_refs.py b/git_refs.py index cfeffba9..4dd68769 100644 --- a/git_refs.py +++ b/git_refs.py @@ -66,7 +66,7 @@ class GitRefs(object): 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 @@ class GitRefs(object): 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 @@ class GitRefs(object): return try: for line in fd: + line = str(line) if line[0] == '#': continue if line[0] == '^': @@ -150,6 +151,10 @@ class GitRefs(object): finally: fd.close() + try: + ref_id = ref_id.decode() + except AttributeError: + pass if not ref_id: return ref_id = ref_id[:-1] -- cgit v1.2.3-54-g00ecf