Exemple #1
0
    def test_tidy_the_stuff_1(self):
        f_name = os.path.join(gen_utils.data_dir(), 'bad_tidy_config.txt')
        opts_dict = tidy_opt_utils.read_dict(f_name)

        (d, tidy_reports) = tidy_the_stuff('', opts_dict)

        self.assert_(len(tidy_reports) != 0)
Exemple #2
0
	def test_tidy_the_stuff_1(self):		
		f_name = os.path.join(gen_utils.data_dir(), 'bad_tidy_config.txt')		
		opts_dict = 	tidy_opt_utils.read_dict(f_name)
		
		(d, tidy_reports) = tidy_the_stuff('', opts_dict)
		
		self.assert_(len(tidy_reports) != 0)
    def test_notebook_1(self):
        sample_f_name = os.path.join(gen_utils.data_dir(),
                                     consts.sample_tidy_config_f_name)

        sample_dict = tidy_opt_utils.read_dict(sample_f_name)

        self._test_notebook(tidy_opt_utils.dict_to_names_dicts(sample_dict),
                            False)
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
Exemple #5
0
	def _test_tab(self, sensitive):		
		f_name = os.path.join(gen_utils.data_dir(), consts.opt_names_to_f_names['html_xhtml_xml_opts'])
		opts_dict = tidy_opt_utils.read_dict(f_name)
		
		o = tab(opts_dict, sensitive)

		o.connect('destroy', gtk.main_quit)	

		main_wnd = gtk.Window(gtk.WINDOW_TOPLEVEL)
		main_wnd.set_title('Output');
		main_wnd.add(o)

		main_wnd.show_all()
		gtk.main()
Exemple #6
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')
Exemple #7
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')
Exemple #8
0
	def _on_view_file_opts(self, w):
		f_name = self._file_entry.get_text()
		
		try:
			f_dict = tidy_opt_utils.read_dict(f_name)
		except Exception, inst:
			parent = self
			flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT
			type_ = gtk.MESSAGE_WARNING
			buttons = gtk.BUTTONS_OK
			log_utils.warn('can\'t view opts file')
			log_utils.warn(inst)
			msg = 'Couldn\'t read or parse file'
			
			d = gtk.MessageDialog(parent, flags, type_, buttons, msg)
			
			d.run()
			
			d.destroy()
			
			return
Exemple #9
0
	def test_notebook_1(self):
	 	sample_f_name = os.path.join(gen_utils.data_dir(), consts.sample_tidy_config_f_name)
	 	
	 	sample_dict = tidy_opt_utils.read_dict(sample_f_name)
	 	
		self._test_notebook(tidy_opt_utils.dict_to_names_dicts(sample_dict), False)
Exemple #10
0
	data_dir = gen_utils.data_dir()	

	d = _default_config_dict()

	f_name = os.path.join(data_dir, consts.config_f_name)

	try:
		f = open(f_name, 'r')
		d = opt_stream_utils.opt_stream_to_dict(f)					
		f.close()
	except Exception, inst:		
		log_utils.warn(str(inst))
		log_utils.warn('couldn\'t read config dict from %s' % f_name)
		
	custom_dict = tidy_opt_utils.read_dict(consts.custom_opt_file_name, True)
	d[consts.custom_opts_names_dicts_category] = tidy_opt_utils.dict_to_names_dicts(custom_dict)
	
	log_utils.debug('read config dict')
	
	return d
	


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])