Commit 102f80a3 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Implement dump command.

parent 53fc6369
......@@ -39,6 +39,7 @@ import distutils.errors
import errno
import glob
import itertools
import json
import logging
import os
import pkg_resources
......@@ -916,6 +917,19 @@ class Buildout(DictMixin):
self._logger.warning(
"Unexpected entry, %r, in develop-eggs directory.", f)
def _dump(self):
d = {}
for section, data in sorted(self._annotated.items()):
for k, v in sorted(data.items()):
if section == 'buildout' and k == 'directory':
continue
elif v[1] == 'DEFAULT_VALUE':
continue
elif k == '_profile_base_location_':
continue
d.setdefault(section, {}).update({k: v[0]})
return json.dumps(d, sort_keys=True, indent=2)
def _compute_part_signatures(self, parts):
# Compute recipe signature and add to options
for part in parts:
......@@ -1260,6 +1274,9 @@ class Buildout(DictMixin):
def annotate(self, args=None):
_print_annotate(self._annotated)
def dump(self, args=None):
print_(self._dump())
def print_options(self):
for section in sorted(self._data):
if section == 'buildout' or section == self['buildout']['versions']:
......@@ -2098,6 +2115,11 @@ Commands:
sorted alphabetically, along with the origin of the value (file name or
COMPUTED_VALUE, DEFAULT_VALUE, COMMAND_LINE_VALUE).
dump
Display sections without buildout:directory and default values in
JSON format.
"""
def _help():
......@@ -2198,7 +2220,7 @@ def main(args=None):
command = args.pop(0)
if command not in (
'install', 'bootstrap', 'runsetup', 'setup', 'init',
'annotate',
'annotate', 'dump',
):
_error('invalid command:', command)
else:
......
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