From d9f2aa1f9d1066a168700c4e356db4f26772468a Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Mon, 27 Feb 2012 18:54:37 +0100 Subject: Temporary commit to make files available --- yamlish.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'yamlish.py') diff --git a/yamlish.py b/yamlish.py index d7be098..098e03d 100644 --- a/yamlish.py +++ b/yamlish.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from __future__ import absolute_import, print_function, unicode_literals """ Easy YAML serialisation compatible with TAP (http://testanything.org/) format. Copyright (C) 2012 Red Hat, Inc. @@ -150,15 +151,15 @@ def load(source): many others). """ out = None - logging.debug("instr:\n%s", source) + logging.debug("inobj:\n%s", source) if isinstance(source, (str, unicode)): out = yaml.load(source, Loader=_YamlishLoader) logging.debug("out (string) = %s", out) elif hasattr(source, "__iter__"): - instr = "" + inobj = "" for line in source: - instr += line + '\n' - out = load(instr) + inobj += line + '\n' + out = load(inobj) logging.debug("out (iter) = %s", out) return out @@ -172,13 +173,15 @@ def dump(source, destination): with open(destination, "w") as outf: dump(source, outf) elif isinstance(destination, file): - yaml.dump(source, destination, canonical=False, - allow_unicode=False, - default_flow_style=False, default_style=False) + yaml.dump(source, destination, encoding="utf-8", + default_flow_style=False, canonical=False, + Dumper=yaml.SafeDumper) def dumps(source): """ Return YAMLish string from given source. """ - return yaml.dump(source, canonical=False, allow_unicode=False, - default_flow_style=False, default_style=False) + return yaml.dump(source, encoding="utf-8", + explicit_start=True, explicit_end=True, + default_flow_style=False, default_style=False, + canonical=False, Dumper=yaml.SafeDumper) -- cgit