FreeTAKTeam / DigitalPy

A framework to support digital engineering in the python language
Eclipse Public License 2.0
9 stars 6 forks source link

Python 11 features we can use #17

Closed brothercorvo closed 1 year ago

brothercorvo commented 1 year ago

@nam

hickey commented 1 year ago

Actually there have been a number of modules that support parsing of toml files for a number of years. Sort of interesting/nice to see that there is one for the standard Python classes. This will be pretty straight forward to integrate into MainConfig. The biggest question becomes the order of precedence (i.e. does YAML override TOML or does TOML override YAML). Although maybe it should be structured so that once one form is found the other is ignored.

Although the downside is if using tomllib becomes a requirement, then it becomes nearly impossible to run on anything but Python 3.11. Most of the distributions out there are ranging between Python 3.9 and Python 3.10. This can pose installation problems for the greater community as a whole.

BTW I can certainly see dropping official support for Python 3.8. I can not think of any distribution out there that is still shipping with Python 3.8.

brothercorvo commented 1 year ago

Good point regarding compatibility! The primary use would be in DigitalPy components that have a lot of ini files, so probably we keep the yaml

On Fri., Nov. 25, 2022, 3:14 p.m. Gerard Hickey, @.***> wrote:

Actually there have been a number of modules that support parsing of toml files for a number of years. Sort of interesting/nice to see that there is one for the standard Python classes. This will be pretty straight forward to integrate into MainConfig. The biggest question becomes the order of precedence (i.e. does YAML override TOML or does TOML override YAML). Although maybe it should be structured so that once one form is found the other is ignored.

Although the downside is if using tomllib becomes a requirement, then it becomes nearly impossible to run on anything but Python 3.11. Most of the distributions out there are ranging between Python 3.9 and Python 3.10. This can pose installation problems for the greater community as a whole.

BTW I can certainly see dropping official support for Python 3.8. I can not think of any distribution out there that is still shipping with Python 3.8.

— Reply to this email directly, view it on GitHub https://github.com/FreeTAKTeam/DigitalPy/issues/17#issuecomment-1327800604, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOPIAPOVGQBVKSPZIFHGXRLWKEFZNANCNFSM6AAAAAASLRCDHI . You are receiving this because you authored the thread.Message ID: @.***>

hickey commented 1 year ago

We can support both formats. There are a couple of options here:

  1. YAML config is processed first and then the TOML config would be processed. (TOML overrides YAML)
  2. TOML config is processed first and then the YAML config would be processed. (YAML overrides TOML)
  3. Check for YAML, process and ignore TOML. If YAML not found, process TOML.
  4. Check for TOML, process and ignore YAML. If TOML not found, process YAML.

The one thing that the TOML format does not do for us is make it easy to write out a config file. So if we wanted to save the internal state of the configuration we would have to write our own routines that would produce the TOML configuration file. But then even with YAML we still have to prepare all the data before it could be written to a file.