def files_settings(self, *names): settings = frontend.Values() for name in names: settings.update( self.option_parser.get_config_file_settings( self.config_files[name]), self.option_parser) return settings.__dict__
def setup_publishers(self): """ Manage configurations for individual publishers. Each publisher (combination of parser, reader, and writer) may have its own configuration defaults, which must be kept separate from those of the other publishers. Setting defaults are combined with the config file settings and command-line options by `self.get_settings()`. """ for name, publisher in self.publishers.items(): option_parser = OptionParser(components=publisher.components, usage=usage, description=description) publisher.option_parser = option_parser publisher.setting_defaults = option_parser.get_default_values() frontend.make_paths_absolute(publisher.setting_defaults.__dict__, option_parser.relative_path_settings) config_parser = frontend.ConfigParser() config_parser.read_standard_files(option_parser) self.config_settings = config_parser.get_section('options') frontend.make_paths_absolute( self.config_settings, self.publishers[''].option_parser.relative_path_settings) self.settings_spec = self.publishers[''].option_parser.parse_args( values=frontend.Values()) # no defaults; just the cmdline opts self.initial_settings = self.get_settings('')
def get_settings(self, publisher_name, directory=None): """ Return a settings object, from multiple sources. Copy the setting defaults, overlay the startup config file settings, then the local config file settings, then the command-line options. Assumes the current directory has been set. """ publisher = self.publishers[publisher_name] settings = frontend.Values(publisher.setting_defaults.__dict__) settings.update(publisher.config_settings, publisher.option_parser) if directory: local_config = publisher.option_parser.get_config_file_settings( os.path.join(directory, 'docutils.conf')) frontend.make_paths_absolute( local_config, publisher.option_parser.relative_path_settings, directory) settings.update(local_config, publisher.option_parser) settings.update(self.settings_spec.__dict__, publisher.option_parser) return settings