diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2014-06-22 10:10:54 -0400 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-06-22 10:10:54 -0400 |
| commit | 3f78a9bbb7667a0d296d829795056e710a293e21 (patch) | |
| tree | c5c65e3c60d2c299bd1165aa96f8f980e83edfd8 | |
| parent | 4cab71f66c1642a01898aac2528efee678345a0a (diff) | |
| download | python-setuptools-bitbucket-3f78a9bbb7667a0d296d829795056e710a293e21.tar.gz | |
Use short-circuit for less nesting
| -rwxr-xr-x | setuptools/command/install_egg_info.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/setuptools/command/install_egg_info.py b/setuptools/command/install_egg_info.py index 67ba7453..6aba68be 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -83,19 +83,21 @@ class install_egg_info(Command): filename += '-nspkg.pth' self.outputs.append(filename) log.info("Installing %s", filename) - if not self.dry_run: - f = open(filename, 'wt') - for pkg in nsp: - # ensure pkg is not a unicode string under Python 2.7 - pkg = str(pkg) - pth = tuple(pkg.split('.')) - tmpl_lines = self._nspkg_tmpl - parent, sep, child = pkg.rpartition('.') - if parent: - tmpl_lines += self._nspkg_tmpl_multi - dat = ';'.join(tmpl_lines) % locals() + '\n' - f.write(dat) - f.close() + if self.dry_run: + return + + f = open(filename, 'wt') + for pkg in nsp: + # ensure pkg is not a unicode string under Python 2.7 + pkg = str(pkg) + pth = tuple(pkg.split('.')) + tmpl_lines = self._nspkg_tmpl + parent, sep, child = pkg.rpartition('.') + if parent: + tmpl_lines += self._nspkg_tmpl_multi + dat = ';'.join(tmpl_lines) % locals() + '\n' + f.write(dat) + f.close() def _get_all_ns_packages(self): """Return sorted list of all package namespaces""" |
