summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-03-21 07:47:45 +0000
committerLars Wirzenius <liw@liw.fi>2014-03-21 07:47:45 +0000
commit34180dcbe29ff85351079575ddd78ed4527811af (patch)
treedc4769c02e4b0c9e667322cb1ca9b9ed1648a619
parent0628d55f2582af6ffb34ec12a20832e9fad73515 (diff)
downloadobnam-34180dcbe29ff85351079575ddd78ed4527811af.tar.gz
Convert dump-repo plugin to output JSON
This will let us drop the depenency on PyYAML.
-rw-r--r--obnamlib/plugins/dump_repo_plugin.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/obnamlib/plugins/dump_repo_plugin.py b/obnamlib/plugins/dump_repo_plugin.py
index 7379ba39..3c09a28d 100644
--- a/obnamlib/plugins/dump_repo_plugin.py
+++ b/obnamlib/plugins/dump_repo_plugin.py
@@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import yaml
+import json
import obnamlib
@@ -31,10 +31,9 @@ class DumpRepositoryPlugin(obnamlib.ObnamPlugin):
def cmd_dump_repo(self, args):
repo = self.app.get_repository_object()
- yaml.safe_dump_all(
- self.dump_repository(repo),
- stream=self.app.output,
- default_flow_style=False)
+ for obj in self.dump_repository(repo):
+ json.dump(obj, self.app.output, indent=4)
+ self.app.output.write('\n')
repo.close()
def dump_repository(self, repo):