yaml output: entry type is lost, if type is set

Issue #105 new
dbacc created an issue

Suppose there is a database entry with field type. Then, when writing the output with yaml. The value of entry_type will be overwritten by entry.field['type'], which is obviously not what you want.

I propose to use a second level of nesting, so that the entry_type value is completely isolated from all the field keys.

--- a/pybtex/database/output/bibyaml.py
+++ b/pybtex/database/output/bibyaml.py
@@ -60,10 +60,12 @@ class Writer(BaseWriter):

         def process_entries(bib_data):
             for key, entry in bib_data.items():
-                fields = OrderedDict([('type', entry.original_type)])
+                fields = OrderedDict()
                 fields.update(entry.fields)
                 fields.update(process_person_roles(entry))
-                yield key, fields
+                dict = {'entry_type' : entry.original_type,
+                        'fields' : fields}
+                yield key, dict

         data = {'entries': OrderedDict(process_entries(bib_data.entries))}
         if bib_data.preamble:

Comments (0)

  1. Log in to comment