Changes to config file handling

Hi all --
I think I've fixed all the problems Marc-André pointed out with config files last week, specifically:
* options in config files can now be spelled either "foo-bar" (like on the command line, minus the leading "--") or "foo_bar" (like in the code)
* negative alias options are now respected, eg. "quiet=1" is the same as "verbose=0"
Plus I fixed a bug nobody had reported:
* boolean options now work: previously, "force=0" resulted in an attribute 'force' being set to the string "0", which of course is true. As an extra bonus, you can now use a variety of sensible representations of true and false: yes, y, t, true, 1, on for true, and no, n, f, false, 0, off for false.
And added a feature that was supposed to be in there from the beginning, but I just plain forgot about:
* a "[global]" section where you can set global options; currently, only 'verbose' and 'dry-run' are supported here (and of course 'quiet', since it's the opposite of 'verbose')
As soon as I've checked everything in, I'll put out a new code snapshot. Please give it a try and let me know if config files now work as you'd expect them to work.
Greg

Plus I fixed a bug nobody had reported:
- boolean options now work: previously, "force=0" resulted in an attribute 'force' being set to the string "0", which of course is true. As an extra bonus, you can now use a variety of sensible representations of true and false: yes, y, t, true, 1, on for true, and no, n, f, false, 0, off for false.
Does not work with command line options. Example: C:\sf\lpfw>setup.py build_ext -f running build_ext Traceback (innermost last): File "C:\sf\lpfw\setup.py", line 41, in ? ext_modules = [_ctypes, ExtensionClass, xxtype], File "c:\work\orion\src\Fpanel\Python\distutils\core.py", line 138, in setup dist.run_commands() File "c:\work\orion\src\Fpanel\Python\distutils\dist.py", line 828, in run_commands self.run_command(cmd) File "c:\work\orion\src\Fpanel\Python\distutils\dist.py", line 846, in run_command cmd_obj = self.get_command_obj(command) File "c:\work\orion\src\Fpanel\Python\distutils\dist.py", line 726, in get_command_obj self._set_command_options(cmd_obj, options) File "c:\work\orion\src\Fpanel\Python\distutils\dist.py", line 761, in _set_command_options setattr(command_obj, option, strtobool(value)) File "c:\work\orion\src\Fpanel\Python\distutils\util.py", line 284, in strtobool val = string.lower(val) TypeError: read-only character buffer, int
string.lower(val) is called with the integer 1 (not the string "1").
Thomas

On 26 September 2000, Thomas Heller said:
Does not work with command line options. Example: C:\sf\lpfw>setup.py build_ext -f running build_ext
[...]
val = string.lower(val)
TypeError: read-only character buffer, int
ARRGGHHH!!!!
Thank you Thomas; I only wish I had tested this myself. Duh. It's too late for Distutils 0.9.3 or, more importantly, Python 2.0b2 -- they both include the broken code. Damn, damn, damn!
I'm uploading Distutils 0.9.4 to python.org as I type. Fixed three lines of code, and that was it. !@$#%#^@#@&!@#%@^!#$%!@%@!#% Did actually test it this time.
Good thing I don't have one of those annoying mail programs that warn you when your language is potentially offensive...
Greg
participants (2)
-
Greg Ward
-
Thomas Heller