Mathis Faivre:
Hi,
I would like to take this one. I plan to split it in two:
1. A small fix in Deb822._merge_fields so a folded Binary merges with a
single-line one, using Colin's test case. No API change.
2. Separately, the larger rework Colin describes: an explicit
simple/folded/multiline type for merge_fields, and folding Binary when dumping,
as dpkg-genchanges does.
Do you want (2) in python-debian, and if so, what API do you prefer: a
field-type argument to merge_fields, or a per-class table of field types? I
would start with (1) now and only do (2) if you agree on the shape.
Thanks,
Mathis
Hi,
Thanks for looking into this.
For 2, my take is that the correct answer would be "both". For file
types known by python-debian, the library should provide a default
(which the "per-class table" solves). But with low-level Deb822 files,
the library do not know the file type and therefore cannot provide a
default. Even with file types that python-debian knows, some of them
support custom fields that python-debian would not know.
For the dumping logic, I am open to adding it. However, in my view it
cannot be in the Deb822 class as a default on a field called "Binary".
Deb822 is a generic file format and this logic for "Binary" is specific
to specialised format. I am fine with it being in the relevant
subclasses though.
I could see an argument for Deb822 getting support for being told field
level metadata information. That is, on a Deb822 instance, you could do
something like:
```
deb822.field_meta["Binary"].field_type = FieldType.FOLDED
deb822.merge_fields("Binary", {"Binary": "...")
deb822.dump(...)
```
In this alternative, subclasses would then just provide a default for
`field_meta`. The `merge_fields` & `dump` methods can then leave this
feature to decide how to merge/dump.
I would not be sad if this solution could be expanded to cover some of
the `_multivalued_fields` & `_relationship_fields` fields we have
floating around in various subclasses as a means to generalise the
features they provide. But then that is a considerably bigger scope.
Which ever path taken, the `Deb822ParagraphElement` would need similar
support for its `dump` method. It does not have a `merge_fields` method.
Best regards,
Niels