Exemplo n.º 1
0
def CreateWizardConfig(manager, from_existing):
    import config
    defaults = wizard_defaults.copy()
    defaults.update(config.defaults)
    options = config.CreateConfig(defaults)
    cfg = config.OptionsContainer(options)
    InitWizardConfig(manager, cfg, from_existing)
    return cfg
Exemplo n.º 2
0
    def PrepareConfig(self):
        # Load our Outlook specific configuration.  This is done before
        # SpamBayes is imported, and thus we are able to change the INI
        # file used for the engine.  It is also done before the primary
        # options are loaded - this means we can change the directory
        # from which these options are loaded.
        import config
        self.options = config.CreateConfig()
        # Note that self.options really *is* self.config - but self.config
        # allows a "." notation to access the values.  Changing one is reflected
        # immediately in the other.
        self.config = config.OptionsContainer(self.options)

        filename = os.path.join(self.application_directory, "default_configuration.ini")
        self._MergeConfigFile(filename)

        filename = os.path.join(self.windows_data_directory, "default_configuration.ini")
        self._MergeConfigFile(filename)
Exemplo n.º 3
0
def main():
    outlook_config = config.CreateConfig()
    spambayes_config = OptionsClass()
    spambayes_config.load_defaults(defaults)

    # Create HTML pages that outline the available options.
    for fn, o, sects in [("outlook-options.html", outlook_config,
                          ("General", "Filter", "Training", "Notification")),
                         ("spambayes-options.html", spambayes_config,
                          ("Tokenizer", "General", "Classifier", "Storage"))]:
        f = open(fn, "w")
        f.write(table_header)

        for sect in sects:
            f.write('<tr style="height:1em">&nbsp;</tr>\n')
            opts = o.options_in_section(sect)
            opts.sort()
            for opt_name in opts:
                opt = o.get_option(sect, opt_name)

                # Skip experimental and deprecated.
                if opt_name.startswith("x-"):
                    continue

                # Replace regex's with readable descriptions.
                if opt.allowed_values in nice_regex_names:
                    replacement = nice_regex_names[opt.allowed_values]
                    if replacement is None:
                        continue
                    opt.allowed_values = (replacement, )

                f.write(opt.as_documentation_string(sect))
                f.write('\n')
        f.write("</table>\n")
        f.close()

    # Create pre-filled configuration files with comments.
    for fn, o in (("outlook-defaults.ini", outlook_config),
                  ("spambayes-defaults.ini", spambayes_config)):
        f = open(fn, "w")
        f.write(o.display(add_comments=True))
        f.close()
Exemplo n.º 4
0
 def save_config(self):
     cf.CreateConfig(objs.get_default().get_config()).run()
Exemplo n.º 5
0
 def generate_config(self):
     import config as cf
     cf.CreateConfig().run()