From: Günter M. <mi...@us...> - 2022-02-03 14:45:04
|
First draft on the OptionParser/ConfigParser separation: Clear separation of duties for OptionParser and ConfigParser. The ConfigParser: * Reads and parses the sequence of configuration files passed to its `read()` method. * Stores the extracted setting values as stings. * Collects settings from "active sections" in an "ACTIVE" section. The OptionParser: * Validates the settings and converts the values to the expected data type. * Eventually updates the settings from command line arguments. TODO: Validate configuration file settings in the ConfigParser? +1 Collecting "appending_settings" becomes easier. -1 Requires inheriting configparser.RawConfigParser to allow storing values other than strings. (Alternative: collect in a ``dict`` instance instead of ACTIVE section.) -1 Requires knowledge of all validation functions and converters in the ConfigParser. The attached files provide a working implementation and minimal test script for this approach. Attachments: - [cf_parser.py](https://sourceforge.net/p/docutils/bugs/_discuss/thread/c76f9a2618/6a1c/attachment/cf_parser.py) (7.0 kB; text/x-python) - [config_list.txt](https://sourceforge.net/p/docutils/bugs/_discuss/thread/c76f9a2618/6a1c/attachment/config_list.txt) (342 Bytes; text/plain) - [config_list_2.txt](https://sourceforge.net/p/docutils/bugs/_discuss/thread/c76f9a2618/6a1c/attachment/config_list_2.txt) (359 Bytes; text/plain) - [test.conf](https://sourceforge.net/p/docutils/bugs/_discuss/thread/c76f9a2618/6a1c/attachment/test.conf) (2.2 kB; application/octet-stream) - [test2.conf](https://sourceforge.net/p/docutils/bugs/_discuss/thread/c76f9a2618/6a1c/attachment/test2.conf) (281 Bytes; application/octet-stream) - [test3.conf](https://sourceforge.net/p/docutils/bugs/_discuss/thread/c76f9a2618/6a1c/attachment/test3.conf) (190 Bytes; application/octet-stream) - [test_cf_parser.py](https://sourceforge.net/p/docutils/bugs/_discuss/thread/c76f9a2618/6a1c/attachment/test_cf_parser.py) (8.8 kB; text/x-python) --- ** [bugs:#441] Move from "optparse" to "argparse".** **Status:** open **Created:** Thu Jan 06, 2022 03:02 PM UTC by Günter Milde **Last Updated:** Mon Jan 31, 2022 11:28 PM UTC **Owner:** Günter Milde The optparse documentation says: > Deprecated since version 3.2: The optparse module is deprecated and will not be developed further; development will continue with the argparse module. We are currently suppressing related deprecation warnings in the test suite. After raising the Python dependency to >=3.7, now may be the right time to make the move. --- Sent from sourceforge.net because doc...@li... is subscribed to https://sourceforge.net/p/docutils/bugs/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |