diff options
author | Lukas Brabec <lbrabec@redhat.com> | 2015-03-18 13:11:59 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2015-03-19 08:57:25 +0100 |
commit | 0d599fdf1f275adbb7b8b90292064628a4e020c2 (patch) | |
tree | 7531607ce25190e1e898cb24fd228d7b8364a8a7 | |
parent | 98fb113994b30117dc2fb302e681d8196066559e (diff) | |
download | yamlish-0d599fdf1f275adbb7b8b90292064628a4e020c2.tar.gz |
faster source handling in load()
-rw-r--r-- | yamlish.py | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -203,23 +203,23 @@ def load(source, ignore_wrong_characters=False): out = yaml.load(source, Loader=_YamlishLoader) log.debug("out (string) = %s", out) elif hasattr(source, "__iter__"): - inobj = u"" + inobj = [] for line in source: try: if not py3k or isinstance(line, bytes): line = line.decode('utf8') logging.debug('inobj, line ... %s, %s', type(inobj), type(line)) - inobj += line + u'\n' + inobj.append(line) except UnicodeDecodeError: log.debug('in ignore_wrong_characters = %s', ignore_wrong_characters) if ignore_wrong_characters: - inobj += line.decode('utf8', 'ignore') + '\n' + inobj.append(line.decode('utf8', 'ignore')) else: raise log.debug('restarting load with inobj as string') - out = load(inobj, ignore_wrong_characters) + out = load('\n'.join(inobj), ignore_wrong_characters) log.debug("out (iter) = %s", out) log.debug("out (iter) = type %s", type(out)) return out |