Rename "dir" variables

The variable name "dir" conflicts with the name of a Python built-in
function: http://docs.python.org/library/functions.html#dir

Change-Id: I850f3ec8df7563dc85e21f2876fe5e6550ca2d8f
This commit is contained in:
Mickaël Salaün 2012-09-30 00:37:55 +02:00
parent 3a6cd4200e
commit 2f6ab7f5b8
5 changed files with 28 additions and 28 deletions

View File

@ -37,11 +37,11 @@ def ssh_sock(create=True):
if _ssh_sock_path is None: if _ssh_sock_path is None:
if not create: if not create:
return None return None
dir = '/tmp' tmp_dir = '/tmp'
if not os.path.exists(dir): if not os.path.exists(tmp_dir):
dir = tempfile.gettempdir() tmp_dir = tempfile.gettempdir()
_ssh_sock_path = os.path.join( _ssh_sock_path = os.path.join(
tempfile.mkdtemp('', 'ssh-', dir), tempfile.mkdtemp('', 'ssh-', tmp_dir),
'master-%r@%h:%p') 'master-%r@%h:%p')
return _ssh_sock_path return _ssh_sock_path

View File

@ -209,8 +209,8 @@ def _CheckWrapperVersion(ver, repo_path):
cp %s %s cp %s %s
""" % (exp_str, _MyWrapperPath(), repo_path) """ % (exp_str, _MyWrapperPath(), repo_path)
def _CheckRepoDir(dir): def _CheckRepoDir(repo_dir):
if not dir: if not repo_dir:
print >>sys.stderr, 'no --repo-dir argument' print >>sys.stderr, 'no --repo-dir argument'
sys.exit(1) sys.exit(1)

View File

@ -209,9 +209,9 @@ class _CopyFile:
if os.path.exists(dest): if os.path.exists(dest):
os.remove(dest) os.remove(dest)
else: else:
dir = os.path.dirname(dest) dest_dir = os.path.dirname(dest)
if not os.path.isdir(dir): if not os.path.isdir(dest_dir):
os.makedirs(dir) os.makedirs(dest_dir)
shutil.copy(src, dest) shutil.copy(src, dest)
# make the file read-only # make the file read-only
mode = os.stat(dest)[stat.ST_MODE] mode = os.stat(dest)[stat.ST_MODE]

30
repo
View File

@ -538,19 +538,19 @@ def _Checkout(cwd, branch, rev, quiet):
def _FindRepo(): def _FindRepo():
"""Look for a repo installation, starting at the current directory. """Look for a repo installation, starting at the current directory.
""" """
dir = os.getcwd() curdir = os.getcwd()
repo = None repo = None
olddir = None olddir = None
while dir != '/' \ while curdir != '/' \
and dir != olddir \ and curdir != olddir \
and not repo: and not repo:
repo = os.path.join(dir, repodir, REPO_MAIN) repo = os.path.join(curdir, repodir, REPO_MAIN)
if not os.path.isfile(repo): if not os.path.isfile(repo):
repo = None repo = None
olddir = dir olddir = curdir
dir = os.path.dirname(dir) curdir = os.path.dirname(curdir)
return (repo, os.path.join(dir, repodir)) return (repo, os.path.join(curdir, repodir))
class _Options: class _Options:
@ -656,13 +656,13 @@ def _SetDefaultsTo(gitdir):
def main(orig_args): def main(orig_args):
main, dir = _FindRepo() repo_main, rel_repo_dir = _FindRepo()
cmd, opt, args = _ParseArguments(orig_args) cmd, opt, args = _ParseArguments(orig_args)
wrapper_path = os.path.abspath(__file__) wrapper_path = os.path.abspath(__file__)
my_main, my_git = _RunSelf(wrapper_path) my_main, my_git = _RunSelf(wrapper_path)
if not main: if not repo_main:
if opt.help: if opt.help:
_Usage() _Usage()
if cmd == 'help': if cmd == 'help':
@ -682,25 +682,25 @@ def main(orig_args):
os.rmdir(os.path.join(root, name)) os.rmdir(os.path.join(root, name))
os.rmdir(repodir) os.rmdir(repodir)
sys.exit(1) sys.exit(1)
main, dir = _FindRepo() repo_main, rel_repo_dir = _FindRepo()
else: else:
_NoCommands(cmd) _NoCommands(cmd)
if my_main: if my_main:
main = my_main repo_main = my_main
ver_str = '.'.join(map(lambda x: str(x), VERSION)) ver_str = '.'.join(map(lambda x: str(x), VERSION))
me = [main, me = [repo_main,
'--repo-dir=%s' % dir, '--repo-dir=%s' % rel_repo_dir,
'--wrapper-version=%s' % ver_str, '--wrapper-version=%s' % ver_str,
'--wrapper-path=%s' % wrapper_path, '--wrapper-path=%s' % wrapper_path,
'--'] '--']
me.extend(orig_args) me.extend(orig_args)
me.extend(extra_args) me.extend(extra_args)
try: try:
os.execv(main, me) os.execv(repo_main, me)
except OSError, e: except OSError, e:
print >>sys.stderr, "fatal: unable to start %s" % main print >>sys.stderr, "fatal: unable to start %s" % repo_main
print >>sys.stderr, "fatal: %s" % e print >>sys.stderr, "fatal: %s" % e
sys.exit(148) sys.exit(148)

View File

@ -339,13 +339,13 @@ uncommitted changes are present' % project.relpath
print >>sys.stderr, 'Deleting obsolete path %s' % project.worktree print >>sys.stderr, 'Deleting obsolete path %s' % project.worktree
shutil.rmtree(project.worktree) shutil.rmtree(project.worktree)
# Try deleting parent subdirs if they are empty # Try deleting parent subdirs if they are empty
dir = os.path.dirname(project.worktree) project_dir = os.path.dirname(project.worktree)
while dir != self.manifest.topdir: while project_dir != self.manifest.topdir:
try: try:
os.rmdir(dir) os.rmdir(project_dir)
except OSError: except OSError:
break break
dir = os.path.dirname(dir) project_dir = os.path.dirname(project_dir)
new_project_paths.sort() new_project_paths.sort()
fd = open(file_path, 'w') fd = open(file_path, 'w')