def effective_opts_dict(d): """ Given a configuration dictionary, returns the effective HTML-Tidy options dictionary (default, from file, or custom). """ k = d[consts.tidy_opts_config_category] if k == consts.default_tidy_opts_config: return tidy_opt_utils.names_dicts_to_dict( tidy_opt_utils.default_names_dicts() ) elif k == consts.from_file_tidy_opts_config: return tidy_opt_utils.read_dict( d[consts.opt_file_name_category] ) elif k == consts.custom_tidy_opts_config: return tidy_opt_utils.names_dicts_to_dict( d[consts.custom_opts_names_dicts_category] ) else: assert False
def test_tidy_the_stuff_0(self): opts_dict = tidy_opt_utils.names_dicts_to_dict( tidy_opt_utils.default_names_dicts()) (d, tidy_reports) = tidy_the_stuff('', opts_dict) self.assert_(len(tidy_reports) != 0)
def test_custom_dlg(self): custom_dict = tidy_opt_utils.read_dict(consts.custom_opt_file_name, True) tabs = tidy_opt_utils.dict_to_names_dicts(custom_dict) o = dlg(None, tabs, True) rep = o.run() if rep == gtk.RESPONSE_OK: log_utils.debug('updating custom opts') names_dicts = o.names_dicts() custom_dict = tidy_opt_utils.names_dicts_to_dict(names_dicts) tidy_opt_utils.write_dict(custom_dict, consts.custom_opt_file_name) log_utils.debug('updated custom opts')
def write_config_dict(d): """ Writes the configuration dictionary to a predefined file (defined in consts.py). """ log_utils.debug('writing config dict') custom_dict = tidy_opt_utils.names_dicts_to_dict(d[consts.custom_opts_names_dicts_category]) tidy_opt_utils.write_dict(custom_dict, consts.custom_opt_file_name) tmp_d = {} for k in [k for k in d.keys() if k != consts.custom_opts_names_dicts_category]: tmp_d[k] = d[k] f_name = os.path.join(gen_utils.data_dir(), consts.config_f_name) f = open(f_name, 'w') opt_stream_utils.dict_to_opt_stream(tmp_d, f) f.close() log_utils.debug('wrote config dict')
def test_tidy_the_stuff_0(self): opts_dict = tidy_opt_utils.names_dicts_to_dict(tidy_opt_utils.default_names_dicts()) (d, tidy_reports) = tidy_the_stuff('', opts_dict) self.assert_(len(tidy_reports) != 0)