def _buildFolderBox(self, section, option, available_folders): folderTable = self.html.configTable.clone() del folderTable.configTextRow1 del folderTable.configTextRow2 del folderTable.configCbRow1 del folderTable.configRow2 del folderTable.blankRow del folderTable.folderRow firstRow = True for folder in available_folders: folder = cgi.escape(folder) folderRow = self.html.configTable.folderRow.clone() if firstRow: folderRow.helpCell = options.doc(section, option) firstRow = False else: del folderRow.helpCell folderRow.folderBox.name = option folderRow.folderBox.value = folder folderRow.folderName = folder if options.multiple_values_allowed(section, option): if folder in options[section, option]: folderRow.folderBox.checked = "checked" folderRow.folderBox.name += folder else: if folder == options[section, option]: folderRow.folderBox.checked = "checked" folderRow.folderBox.type = "radio" folderTable += folderRow return self._buildBox(options.display_name(section, option), None, folderTable)
def _buildConfigPageBody(self, html, parm_map): configTable = None section = None for sect, opt in parm_map: if opt is None: if configTable is not None and section is not None: section.boxContent = configTable html.configFormContent += section section = self.html.headedBox.clone() configTable = self.html.configTable.clone() configTextRow1 = configTable.configTextRow1.clone() configTextRow2 = configTable.configTextRow2.clone() configCbRow1 = configTable.configCbRow1.clone() configRow2 = configTable.configRow2.clone() blankRow = configTable.blankRow.clone() del configTable.configTextRow1 del configTable.configTextRow2 del configTable.configCbRow1 del configTable.configRow2 del configTable.blankRow del configTable.folderRow section.heading = sect del section.iconCell continue html_key = sect + "_" + opt if sect == "Headers" and opt in ("notate_to", "notate_subject"): valid_input = ( options["Headers", "header_ham_string"], options["Headers", "header_spam_string"], options["Headers", "header_unsure_string"], ) else: valid_input = options.valid_input(sect, opt) if isinstance(valid_input, types.StringTypes): newConfigRow1 = configTextRow1.clone() newConfigRow1.label = options.display_name(sect, opt) newConfigRow1.input.name = html_key newConfigRow1.input.value = options.unconvert(sect, opt) else: newConfigRow1 = configCbRow1.clone() newConfigRow1.label = options.display_name(sect, opt) blankOption = newConfigRow1.input.clone() firstOpt = True i = 0 for val in valid_input: newOption = blankOption.clone() if options.multiple_values_allowed(sect, opt): if val in options[sect, opt]: newOption.input_box.checked = "checked" newOption.input_box.type = "checkbox" newOption.input_box.name = html_key + "-" + str(i) i += 1 else: if val == options[sect, opt]: newOption.input_box.checked = "checked" newOption.input_box.type = "radio" newOption.input_box.name = html_key if options.is_boolean(sect, opt): if val is True: val = "Yes" elif val is False: val = "No" newOption.val_label = str(val) newOption.input_box.value = str(val) if firstOpt: newConfigRow1.input = newOption firstOpt = False else: newConfigRow1.input += newOption newConfigRow1.helpCell = ( "<strong>" + options.display_name(sect, opt) + ":</strong> " + cgi.escape(options.doc(sect, opt)) ) newConfigRow2 = configRow2.clone() currentValue = options[sect, opt] if type(currentValue) in types.StringTypes: currentValue = currentValue.replace(",", ", ") newConfigRow2 = configTextRow2.clone() else: currentValue = options.unconvert(sect, opt) newConfigRow2 = configRow2.clone() if options.is_boolean(sect, opt): if currentValue == "False": currentValue = _("No") elif currentValue == "True": currentValue = _("Yes") newConfigRow2.currentValue = currentValue configTable += newConfigRow1 + newConfigRow2 + blankRow if section is not None: section.boxContent = configTable html.configFormContent += section return html
from email.Iterators import typed_subpart_iterator from textwrap import wrap from spambayes import oe_mailbox from spambayes import PyMeldLite from spambayes import Dibbler from spambayes import tokenizer from spambayes import Version from spambayes import storage from spambayes import FileCorpus from spambayes.Options import options, optionsPathname, defaults, OptionsClass, _ IMAGES = ("helmet", "status", "config", "help", "message", "train", "classify", "query") experimental_ini_map = (("Experimental Options", None),) for opt in options.options(True): sect, opt = opt[1:].split("]", 1) if opt[:2].lower() == "x-" and not options.doc(sect, opt).lower().startswith(_("(deprecated)")): experimental_ini_map += ((sect, opt),) class UserInterfaceServer(Dibbler.HTTPServer): """Implements the web server component via a Dibbler plugin.""" def __init__(self, uiPort): Dibbler.HTTPServer.__init__(self, uiPort) print _("User interface url is http://localhost:%d/") % (uiPort) def requestAuthenticationMode(self): return options["html_ui", "http_authentication"] def getRealm(self): return _("SpamBayes Web Interface")