diff options
-rw-r--r-- | gdatastore/datastore.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gdatastore/datastore.py b/gdatastore/datastore.py index 2378abc..3b77828 100644 --- a/gdatastore/datastore.py +++ b/gdatastore/datastore.py @@ -19,6 +19,7 @@ Gdatastore D-Bus service API import hashlib import logging import os +import pprint import shutil from subprocess import Popen, PIPE import tempfile @@ -593,7 +594,7 @@ class InternalApi(object): [_format_ref(tree_id, parent_id)]).strip() def _format_commit_message(self, metadata): - return repr(metadata) + return pprint.pformat(to_native(metadata)) def _gen_uuid(self): return str(uuid.uuid4()) @@ -660,5 +661,17 @@ def calculate_checksum(path): checksum.update(chunk) +def to_native(value): + if isinstance(value, list): + return [to_native(e) for e in value] + elif isinstance(value, dict): + return dict([(to_native(k), to_native(v)) for k, v in value.items()]) + elif isinstance(value, unicode): + return unicode(value) + elif isinstance(value, str): + return str(value) + return value + + def _format_ref(tree_id, version_id): return 'refs/gdatastore/%s/%s' % (tree_id, version_id) |