Hello,
In Python's configparser the default section is supposed to supply missing options for the rest sections. In py-configparser this doesn't work. I suggest fixing %get-option as follows:
(defun %get-option (config section-name option-name if-does-not-exist) (let* ((section (%get-section config section-name)) (norm-option (norm-option-name config option-name)) (option (or (assoc norm-option (section-options section) :test #'string=) (assoc norm-option (section-options (config-defaults config)) :test #'string=)))) (if (null option) (if (eq if-does-not-exist :error) (error 'no-option-error) ;; no such option error (values (car (push (list (%validate-option-name norm-option)) (section-options section))) section)) (values option section))))
Best regards, Stanislav Kondratyev.
I've noticed that my fix suggested above brings in one more trouble. Specifically, set-option destructively modifies the cons returned by %get-option, so overriding default options results in unwanted change of default options themselves. For this reason it's even impossible to correctly read a config file.
The function set-option can be patched; however, it's unclear if there are similar issues with destructive modifications in the rest of the code. So implementing the inheritance requires either checking the whole code for safety or copying the default values to each section.
2013/8/27 Станислав Кондратьев kondratjevsk@gmail.com:
Hello,
In Python's configparser the default section is supposed to supply missing options for the rest sections. In py-configparser this doesn't work. I suggest fixing %get-option as follows:
(defun %get-option (config section-name option-name if-does-not-exist) (let* ((section (%get-section config section-name)) (norm-option (norm-option-name config option-name)) (option (or (assoc norm-option (section-options section) :test #'string=) (assoc norm-option (section-options (config-defaults config)) :test #'string=)))) (if (null option) (if (eq if-does-not-exist :error) (error 'no-option-error) ;; no such option error (values (car (push (list (%validate-option-name norm-option)) (section-options section))) section)) (values option section))))
Best regards, Stanislav Kondratyev.
py-configparser-devel@common-lisp.net