-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YAML format discussion #15
Comments
One can preserve key order if Python dicts are ordered and import yaml
print(yaml.dump({"c": 3, "z": 2, "a": 1}, default_flow_style=False, sort_keys=False))
import yaml
print(yaml.dump({"c": 3, "z": 2, "a": 1}, default_flow_style=False, sort_keys=True))
|
What alternatives do you have in mind? I think we decided on yaml because it's pretty common in the python space and more readable than xml (and xml parsing in python is a bit unconvenient). From my experience |
Using yaml in the config doesn't necessarily mean we have to use PyYAML. There's also ruamel.yaml. https://pypi.org/project/ruamel.yaml/ https://yaml.readthedocs.io/en/latest/pyyaml.html#differences-with-pyyaml |
This snippet show how to control list representation in pyyaml import yaml
class FlowStyleList(list):
pass
def flow_representer(dumper, data):
return dumper.represent_sequence("tag:yaml.org,2002:seq", data, flow_style=True)
yaml.add_representer(FlowStyleList, flow_representer)
print(yaml.dump({
"a": FlowStyleList(["a", "b", "c"]),
"b": ["a", "b", "c"],
})) Results in following yaml: a: [a, b, c]
b:
- a
- b
- c |
I suppose it's YAML for now, feel free to reopen and restart the discussion |
At the hackathon we were discussing if YAML is the format we want to go with.
@uschmidt83 had issues installing the python
PyYAML
. Also, the autogenerated YAML file looks weird.There might be better options and if you are interested in discussing this, do it here :)
The text was updated successfully, but these errors were encountered: