Custom Query (132 matches)


Show under each result:

Results (43 - 45 of 132)

Ticket Resolution Summary Owner Reporter
#41 fixed Patch: Use types module instead of hand crafted entities and type(). xi v.haisman@…

Reported by v.haisman@…, 7 years ago.


Hi, I have a patch that makes PyYAML use types module instead of hand crafted entities and type(). The motivation is that it silences some PyDev? error complains, like methods not having self parameter and such.

#167 worksforme Please help saving dict to yaml xi anonymous

Reported by anonymous, 4 years ago.

Hi, is there any way of saving dict to a file in yaml format? I'm using:
import yaml
y = """
         - subject1:
            desc: msg1
         - subject2:
            desc: msg2

settings['root'][0]['subject1']['desc'] = "new msg"
print settings

f = open("temp", "w")
but failing miserably, contents of the temp file:
{'root': [{'subject1': {'desc': 'new msg'}}, {'subject2': {'desc': 'msg2'}}]}

expected result:
         - subject1:
            desc: new msg
         - subject2:
            desc: msg2

Is there anything like Any help greatly appreciated!

#136 invalid Pure-python emitter fails emitting tag represented as a mapping xi julians@…

Reported by julians@…, 5 years ago.



the following snippet will fail with PyYAML 3.08:

#!/usr/bin/env python2.5

import yaml

Dumper = yaml.Dumper

class FooTag(yaml.YAMLObject):

    yaml_dumper = Dumper

    yaml_tag = u'!foo'

    def to_yaml(cls, dumper, foo):
        return dumper.represent_mapping(None, 
                                        {"foo": "bar"} )

print(yaml.dump(FooTag(), Dumper=Dumper))

The error message is:

Traceback (most recent call last):
  File "", line 20, in <module>
    print(yaml.dump(FooTag(), Dumper=Dumper))
  File "(bogus file name)", line 175, in dump
  File "(bogus file name)", line 165, in dump_all
  File "yaml/", line 34, in represent
  File "yaml/", line 54, in serialize
  File "yaml/", line 109, in serialize_node
  File "yaml/", line 110, in emit
  File "yaml/", line 224, in expect_document_root
  File "yaml/", line 238, in expect_node
  File "yaml/", line 483, in process_tag
yaml.emitter.EmitterError: tag is not specified

(For some reason the file name in lines two and three of the trace is wrong, I've removed it here.)

The above does work when using libyaml (try substituting CDumper). For what it's worth it will also work when to_yaml emits a scalar instead of a mapping.

I've found that the following patch fixes the issue for me, but I don't understand the code well enough to know all implications of doing so.

diff -ru PyYAML-3.08/lib/yaml/ PyYAML-3.08-patched/lib/yaml/
--- PyYAML-3.08/lib/yaml/	2008-12-31 05:24:15.000000000 +1030
+++ PyYAML-3.08-patched/lib/yaml/	2009-07-03 13:58:11.000000000 +0930
@@ -480,7 +480,7 @@

                 self.prepared_tag = None
         if tag is None:
-            raise EmitterError(&quot;tag is not specified&quot;)
+            return
         if self.prepared_tag is None:
             self.prepared_tag = self.prepare_tag(tag)
         if self.prepared_tag:
Note: See TracQuery for help on using queries.