Custom Query (121 matches)
Results (109 - 111 of 121)
| Ticket | Resolution | Summary | Owner | Reporter |
|---|---|---|---|---|
| #22 | fixed | Aliases break if there are temporary objects | xi | tim.hochberg@… |
| Description |
If an object being passed to represet_data has a shorter lifespan than the representer, the results are unpredictable, but generally bad. In my case, I'm trying to represent a custom omap class. I register a representer like so: def omap_representer(dumper, data):
items = [[x, y] for (x, y) in data.iteritems()]
return dumper.represent_sequence(u'!omap', items)
yaml.add_representer(omap, omap_representer)
If I then dump something that contains multiple omaps, such as [one_omap,another_omap], the representer get's confused because it sees distinct objects that have the same id. Here's an actual example: >>> a # Note that these are omaps not dictionaries, despite appearances.
[{1: 2, 2: 4}, {1: 99, 2: 88}]
>>> print yaml.dump(a)
- !omap
- &id001 [1, 2]
- &id002 [2, 4]
- !omap
- *id001
- *id002
Two approaches come to mind to fix this.
-tim |
|||
| #23 | fixed | Dictionary output not sorted. | xi | tim.hochberg@… |
| Description |
It is convenient to have YAML's output be consistent across runs. Some representers in PyYaml? do this already, but the dictionaries do not. I implemented a quick fix by replacing represent_dict with: def represent_dict(self, data):
items = data.items()
items.sort()
return self.represent_mapping(u'tag:yaml.org,2002:map', items)
It might also be convenient to have custom sort orders as PyYaml? legacy does, but that's a bigger change. |
|||
| #3 | fixed | allow_unicode missing in emitter? | xi | tim@… |
| Description |
Trying to emit plain chars in utf8 (£ symbol for instance - \xc2\xa3) isn't working.. I think I've tracked it down to missing allow_unicode passing through to emitter and possibly the emit events resetting allow_unicode (I won't say I've fixed it as I've forced allow_unicode to True in various places to get it to emit plain's in utf-8 rather than double quoted escaped unicode). I'll post more tomorrow if I can get my fix cleaner. Looking good btw!! |
|||
