Run 2to3 utility

This commit is contained in:
Moritz Lell 2019-10-27 14:19:50 +01:00
commit 491040ea72
12 changed files with 26 additions and 26 deletions

View file

@ -11,7 +11,7 @@ def _nice(t):
def _try_stat(filename):
try:
return os.lstat(filename)
except OSError, e:
except OSError as e:
if e.errno == errno.ENOENT:
return None
else:
@ -90,7 +90,7 @@ def start_stdin_log_reader(status, details, pretty, color,
argv.append('--color' if color >= 2 else '--no-color')
argv.append('-')
os.execvp(argv[0], argv)
except Exception, e: # pylint: disable=broad-except
except Exception as e: # pylint: disable=broad-except
sys.stderr.write('redo-log: exec: %s\n' % e)
finally:
os._exit(99)
@ -138,7 +138,7 @@ class _BuildJob(object):
if is_target:
meta('unchanged', state.target_relpath(self.t))
return self._finalize(0)
except helpers.ImmediateReturn, e:
except helpers.ImmediateReturn as e:
return self._finalize(e.rv)
if env.v.NO_OOB or dirty == True: # pylint: disable=singleton-comparison
@ -398,7 +398,7 @@ class _BuildJob(object):
helpers.unlink(self.tmpname)
try:
newf = open(self.tmpname, 'w')
except IOError, e:
except IOError as e:
dnt = os.path.dirname(os.path.abspath(t))
if not os.path.exists(dnt):
# This could happen, so report a simple error message
@ -424,7 +424,7 @@ class _BuildJob(object):
try:
# Atomically replace the target file
os.rename(self.tmpname, t)
except OSError, e:
except OSError as e:
# This could happen for, eg. a permissions error on
# the target directory.
err('%s: rename %s: %s\n' % (t, self.tmpname, e))

View file

@ -52,7 +52,7 @@ def main():
finally:
try:
jobserver.force_return_tokens()
except Exception, e: # pylint: disable=broad-except
except Exception as e: # pylint: disable=broad-except
traceback.print_exc(100, sys.stderr)
err('unexpected error: %r\n' % e)
rv = 1

View file

@ -102,7 +102,7 @@ def catlog(t):
if not f:
try:
f = open(logname)
except IOError, e:
except IOError as e:
if e.errno == errno.ENOENT:
# ignore files without logs
pass
@ -231,7 +231,7 @@ def catlog(t):
status = None
if line_head:
# partial line never got terminated
print line_head
print(line_head)
if t != '-':
assert depth[-1] == t
depth.pop(-1)
@ -274,7 +274,7 @@ def main():
catlog(t)
except KeyboardInterrupt:
sys.exit(200)
except IOError, e:
except IOError as e:
if e.errno == errno.EPIPE:
pass
else:

View file

@ -36,7 +36,7 @@ def main():
is_checked=is_checked,
set_checked=set_checked,
log_override=log_override):
print state.relpath(os.path.join(env.v.BASE, f.name), cwd)
print(state.relpath(os.path.join(env.v.BASE, f.name), cwd))
if __name__ == '__main__':

View file

@ -48,7 +48,7 @@ def main():
if opt.version:
from . import version
print version.TAG
print(version.TAG)
sys.exit(0)
if opt.debug:
os.environ['REDO_DEBUG'] = str(opt.debug or 0)
@ -114,7 +114,7 @@ def main():
finally:
try:
jobserver.force_return_tokens()
except Exception, e: # pylint: disable=broad-except
except Exception as e: # pylint: disable=broad-except
traceback.print_exc(100, sys.stderr)
err('unexpected error: %r\n' % e)
retcode = 1

View file

@ -16,7 +16,7 @@ def main():
cwd = os.getcwd()
for f in state.files():
if f.is_source():
print state.relpath(os.path.join(env.v.BASE, f.name), cwd)
print(state.relpath(os.path.join(env.v.BASE, f.name), cwd))
if __name__ == '__main__':

View file

@ -16,7 +16,7 @@ def main():
cwd = os.getcwd()
for f in state.files():
if f.is_target():
print state.relpath(os.path.join(env.v.BASE, f.name), cwd)
print(state.relpath(os.path.join(env.v.BASE, f.name), cwd))
if __name__ == '__main__':

View file

@ -26,7 +26,7 @@ def main():
relpath = os.path.relpath(dopath, '.')
exists = os.path.exists(dopath)
assert '\n' not in relpath
print relpath
print(relpath)
if exists:
sys.exit(0)
sys.exit(1) # no appropriate dofile found

View file

@ -16,7 +16,7 @@ def unlink(f):
"""
try:
os.unlink(f)
except OSError, e:
except OSError as e:
if e.errno == errno.ENOENT:
pass # it doesn't exist, that's what you asked for

View file

@ -98,7 +98,7 @@ def _create_tokens(n):
global _mytokens, _cheats
assert n >= 0
assert _cheats >= 0
for _ in xrange(n):
for _ in range(n):
if _cheats > 0:
_cheats -= 1
else:
@ -118,7 +118,7 @@ def _release(n):
assert _mytokens >= n
_debug('%d,%d -> release(%d)\n' % (_mytokens, _cheats, n))
n_to_share = 0
for _ in xrange(n):
for _ in range(n):
_mytokens -= 1
if _cheats > 0:
_cheats -= 1
@ -176,7 +176,7 @@ def _try_read(fd, n):
signal.setitimer(signal.ITIMER_REAL, 0.01, 0.01) # emergency fallback
try:
b = os.read(fd, 1)
except OSError, e:
except OSError as e:
if e.errno in (errno.EAGAIN, errno.EINTR):
# interrupted or it was nonblocking
return None # try again
@ -297,7 +297,7 @@ def _wait(want_token, max_delay):
Returns:
None
"""
rfds = _waitfds.keys()
rfds = list(_waitfds.keys())
if want_token:
rfds.append(_tokenfds[0])
assert rfds

View file

@ -239,12 +239,12 @@ class Options:
"""
try:
(flags,extra) = self.optfunc(args, self._shortopts, self._longopts)
except getopt.GetoptError, e:
except getopt.GetoptError as e:
self.fatal(e)
opt = OptDict()
for k,v in self._defaults.iteritems():
for k,v in self._defaults.items():
k = self._aliases[k]
opt[k] = v
@ -268,6 +268,6 @@ class Options:
else:
v = _intify(v)
opt[k] = v
for (f1,f2) in self._aliases.iteritems():
for (f1,f2) in self._aliases.items():
opt[f1] = opt._opts.get(f2)
return (opt,flags,extra)

View file

@ -46,14 +46,14 @@ def db():
dbfile = '%s/db.sqlite3' % dbdir
try:
os.mkdir(dbdir)
except OSError, e:
except OSError as e:
if e.errno == errno.EEXIST:
pass # if it exists, that's okay
else:
raise
_lockfile = os.open(os.path.join(env.v.BASE, '.redo/locks'),
os.O_RDWR | os.O_CREAT, 0666)
os.O_RDWR | os.O_CREAT, 0o666)
close_on_exec(_lockfile, True)
if env.is_toplevel and detect_broken_locks():
env.mark_locks_broken()
@ -508,7 +508,7 @@ class Lock(object):
assert not self.owned
try:
fcntl.lockf(_lockfile, fcntl.LOCK_EX|fcntl.LOCK_NB, 1, self.fid)
except IOError, e:
except IOError as e:
if e.errno in (errno.EAGAIN, errno.EACCES):
pass # someone else has it locked
else: