Commit e7d42b35 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Indent big section of code before actual changes.

parent 30a8f29c
...@@ -652,159 +652,161 @@ class Buildout(DictMixin): ...@@ -652,159 +652,161 @@ class Buildout(DictMixin):
installed_parts = installed_part_options['buildout']['parts'] installed_parts = installed_part_options['buildout']['parts']
installed_parts = installed_parts and installed_parts.split() or [] installed_parts = installed_parts and installed_parts.split() or []
if install_args: try:
install_parts = install_args if install_args:
uninstall_missing = False install_parts = install_args
else: uninstall_missing = False
install_parts = conf_parts else:
uninstall_missing = True install_parts = conf_parts
uninstall_missing = True
# load and initialize recipes
[self[part]['recipe'] for part in install_parts] # load and initialize recipes
if not install_args: [self[part]['recipe'] for part in install_parts]
install_parts = self._parts if not install_args:
install_parts = self._parts
if self._log_level < logging.DEBUG:
sections = list(self) if self._log_level < logging.DEBUG:
sections.sort() sections = list(self)
print_() sections.sort()
print_('Configuration data:') print_()
for section in sorted(self._data): print_('Configuration data:')
_save_options(section, self[section], sys.stdout) for section in sorted(self._data):
print_() _save_options(section, self[section], sys.stdout)
print_()
# compute new part recipe signatures
self._compute_part_signatures(install_parts) # compute new part recipe signatures
self._compute_part_signatures(install_parts)
# uninstall parts that are no-longer used or who's configs
# have changed # uninstall parts that are no-longer used or who's configs
for part in reversed(installed_parts): # have changed
if part in install_parts: for part in reversed(installed_parts):
old_options = installed_part_options[part].copy() if part in install_parts:
installed_files = old_options.pop('__buildout_installed__') old_options = installed_part_options[part].copy()
new_options = self.get(part) installed_files = old_options.pop('__buildout_installed__')
if old_options == new_options: new_options = self.get(part)
# The options are the same, but are all of the if old_options == new_options:
# installed files still there? If not, we should # The options are the same, but are all of the
# reinstall. # installed files still there? If not, we should
if not installed_files: # reinstall.
continue if not installed_files:
for f in installed_files.split('\n'): continue
if not os.path.exists(self._buildout_path(f)): for f in installed_files.split('\n'):
break if not os.path.exists(self._buildout_path(f)):
else: break
continue else:
continue
# output debugging info
if self._logger.getEffectiveLevel() < logging.DEBUG: # output debugging info
for k in old_options: if self._logger.getEffectiveLevel() < logging.DEBUG:
if k not in new_options: for k in old_options:
self._logger.debug("Part %s, dropped option %s.", if k not in new_options:
part, k) self._logger.debug(
elif old_options[k] != new_options[k]: "Part %s, dropped option %s.", part, k)
self._logger.debug( elif old_options[k] != new_options[k]:
"Part %s, option %s changed:\n%r != %r", self._logger.debug(
part, k, new_options[k], old_options[k], "Part %s, option %s changed:\n%r != %r",
) part, k, new_options[k], old_options[k])
for k in new_options: for k in new_options:
if k not in old_options: if k not in old_options:
self._logger.debug("Part %s, new option %s.", self._logger.debug(
part, k) "Part %s, new option %s.", part, k)
elif not uninstall_missing: elif not uninstall_missing:
continue continue
self._uninstall_part(part, installed_part_options) self._uninstall_part(part, installed_part_options)
installed_parts = [p for p in installed_parts if p != part] installed_parts = [p for p in installed_parts if p != part]
if installed_exists: if installed_exists:
self._update_installed(parts=' '.join(installed_parts)) self._update_installed(parts=' '.join(installed_parts))
# Check for unused buildout options: # Check for unused buildout options:
_check_for_unused_options_in_section(self, 'buildout') _check_for_unused_options_in_section(self, 'buildout')
# install new parts # install new parts
for part in install_parts: for part in install_parts:
signature = self[part].pop('__buildout_signature__') signature = self[part].pop('__buildout_signature__')
saved_options = self[part].copy() saved_options = self[part].copy()
recipe = self[part].recipe recipe = self[part].recipe
if part in installed_parts: # update if part in installed_parts: # update
need_to_save_installed = False need_to_save_installed = False
__doing__ = 'Updating %s.', part __doing__ = 'Updating %s.', part
self._logger.info(*__doing__) self._logger.info(*__doing__)
old_options = installed_part_options[part] old_options = installed_part_options[part]
old_installed_files = old_options['__buildout_installed__'] old_installed_files = old_options['__buildout_installed__']
try: try:
update = recipe.update update = recipe.update
except AttributeError: except AttributeError:
update = recipe.install update = recipe.install
self._logger.warning( self._logger.warning(
"The recipe for %s doesn't define an update " "The recipe for %s doesn't define an update "
"method. Using its install method.", "method. Using its install method.",
part) part)
try: try:
installed_files = self[part]._call(update) installed_files = self[part]._call(update)
except: except:
installed_parts.remove(part) installed_parts.remove(part)
self._uninstall(old_installed_files) self._uninstall(old_installed_files)
if installed_exists: if installed_exists:
self._update_installed( self._update_installed(
parts=' '.join(installed_parts)) parts=' '.join(installed_parts))
raise raise
old_installed_files = old_installed_files.split('\n') old_installed_files = old_installed_files.split('\n')
if installed_files is None: if installed_files is None:
installed_files = old_installed_files installed_files = old_installed_files
else: else:
if isinstance(installed_files, str): if isinstance(installed_files, str):
installed_files = [installed_files]
else:
installed_files = list(installed_files)
need_to_save_installed = [
p for p in installed_files
if p not in old_installed_files]
if need_to_save_installed:
installed_files = (old_installed_files
+ need_to_save_installed)
else: # install
need_to_save_installed = True
__doing__ = 'Installing %s.', part
self._logger.info(*__doing__)
installed_files = self[part]._call(recipe.install)
if installed_files is None:
self._logger.warning(
"The %s install returned None. A path or "
"iterable os paths should be returned.",
part)
installed_files = ()
elif isinstance(installed_files, str):
installed_files = [installed_files] installed_files = [installed_files]
else: else:
installed_files = list(installed_files) installed_files = list(installed_files)
need_to_save_installed = [ installed_part_options[part] = saved_options
p for p in installed_files saved_options['__buildout_installed__'
if p not in old_installed_files] ] = '\n'.join(installed_files)
saved_options['__buildout_signature__'] = signature
if need_to_save_installed:
installed_files = (old_installed_files
+ need_to_save_installed)
else: # install
need_to_save_installed = True
__doing__ = 'Installing %s.', part
self._logger.info(*__doing__)
installed_files = self[part]._call(recipe.install)
if installed_files is None:
self._logger.warning(
"The %s install returned None. A path or "
"iterable os paths should be returned.",
part)
installed_files = ()
elif isinstance(installed_files, str):
installed_files = [installed_files]
else:
installed_files = list(installed_files)
installed_part_options[part] = saved_options
saved_options['__buildout_installed__'
] = '\n'.join(installed_files)
saved_options['__buildout_signature__'] = signature
installed_parts = [p for p in installed_parts if p != part] installed_parts = [p for p in installed_parts if p != part]
installed_parts.append(part) installed_parts.append(part)
_check_for_unused_options_in_section(self, part) _check_for_unused_options_in_section(self, part)
if need_to_save_installed: if need_to_save_installed:
installed_part_options['buildout']['parts'] = ( installed_part_options['buildout']['parts'] = (
' '.join(installed_parts)) ' '.join(installed_parts))
self._save_installed_options(installed_part_options) self._save_installed_options(installed_part_options)
installed_exists = True installed_exists = True
else: else:
assert installed_exists assert installed_exists
self._update_installed(parts=' '.join(installed_parts)) self._update_installed(parts=' '.join(installed_parts))
finally:
pass
if installed_develop_eggs: if installed_develop_eggs:
if not installed_exists: if not installed_exists:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment