[issue30779] IDLE: configdialog -- factor out Changes class

Terry J. Reedy report at bugs.python.org
Thu Jul 6 01:23:39 EDT 2017


Terry J. Reedy added the comment:

To get moving and unblock other issues, I decided to start with the simplest not-bad change that will work.

The factored out code belongs in config.py. This will separate integration with ConfigDialog into 2 steps.
1. Add code and tests to config and test_config, leaving configdialog untouched.
2. Modify configdialog and tests to import and use the new classes, removing the refactored classes.

We should start with ConfigChanges as a subclass of dict, with added methods as unchanged as possible.  No Page class, but the page idea appears, and will later be applied elsewhere.  No apply method, as the code only accesses changes but does not modify them.  No save_new_config, as that code bypasses changes completely. No set_user_value, as that only access idleConf.  I guessed at what delete_section should look like as I don't know where the original code is.

Attached is my untested ConfigChanges.

With step 1 done, I believe step 2 would consist of:

A. add ConfigChanges to the config import.

B. make 'changes' a global (like idleConf), after imports, with
changes = ConfigChanges()
[This could go in config, but CD is its only user.]
Remove self.reset_changed_items in CD.__init__.

C. replace names throughout file
/self.changed_items/changes/
/self.reset_changed_items/changes.clear/
/self.add_changed_items/changes.add_item/ 
/self.save_all_changed_configs/changes.save_all/

C. Removed renamed methods.  (Could do before B.)
D. Replace code moved to .delete_section with a call thereto.

E. Change test_configdialog
If you wrote tests for methods not included in ConfigChanges, they could be added here anyway.

PR2 could be prepared before PR1 is merged, but must not be applied before PR1 is merged and backported, and has to be consistent with final applied version of PR1.

----------
Added file: http://bugs.python.org/file46991/changes_class_v4.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30779>
_______________________________________


More information about the Python-bugs-list mailing list