Example #1
0
    def test_multiline_preserves_indentation(self):
        schema = ImplicitTypeSchema(self._testfile('base.conf'))
        config = schema.load(self._testfile('local.conf'))
        convert = config['section_1']._convert
        orig = """\
multiline value 1
    multiline value 2"""
        new = convert(orig)
        self.meq(new, orig)
Example #2
0
    def test_multiline_preserves_indentation(self):
        schema = ImplicitTypeSchema(self._testfile('base.conf'))
        config = schema.load(self._testfile('local.conf'))
        convert = config['section_1']._convert
        orig = """\
multiline value 1
    multiline value 2"""
        new = convert(orig)
        self.meq(new, orig)
Example #3
0
 def test_multiline_strips_leading_and_trailing_whitespace(self):
     schema = ImplicitTypeSchema(self._testfile('base.conf'))
     config = schema.load(self._testfile('local.conf'))
     convert = config['section_1']._convert
     orig = """
 multiline value 1
 multiline value 2
 """
     new = convert(orig)
     self.meq(new, orig.strip())
Example #4
0
 def test_multiline_strips_leading_and_trailing_whitespace(self):
     schema = ImplicitTypeSchema(self._testfile('base.conf'))
     config = schema.load(self._testfile('local.conf'))
     convert = config['section_1']._convert
     orig = """
 multiline value 1
 multiline value 2
 """
     new = convert(orig)
     self.meq(new, orig.strip())
Example #5
0
    def load(cls, conf_path, schema_path=None):
        """Initialize the Configuration.

        :conf_path: The path to the lazr.config conf file.
        :schema_path: The path to the lazr.config schema that defines
            the configuration.
        """
        if schema_path is None:
            schema_path = cls._schema_path
        schema = ImplicitTypeSchema(schema_path)
        return cls(schema.load(conf_path))
Example #6
0
    def _getConfig(self):
        """Get the schema and config for this environment.

        The config is will be loaded only when there is not a config.
        Repeated calls to this method will not cause the config to reload.
        """
        if self._config is not None:
            return

        schema_file = os.path.join(PACKAGE_DIR, 'schema-lazr.conf')
        config_dir = self.config_dir
        config_file = os.path.join(
            config_dir, '%s-lazr.conf' % self.process_name)
        if not os.path.isfile(config_file):
            config_file = os.path.join(config_dir, 'launchpad-lazr.conf')
        schema = ImplicitTypeSchema(schema_file)
        self._config = schema.load(config_file)
        try:
            self._config.validate()
        except ConfigErrors as error:
            message = '\n'.join([str(e) for e in error.errors])
            raise ConfigErrors(message)
        self._setZConfig()
Example #7
0
    def _getConfig(self):
        """Get the schema and config for this environment.

        The config is will be loaded only when there is not a config.
        Repeated calls to this method will not cause the config to reload.
        """
        if self._config is not None:
            return

        schema_file = os.path.join(PACKAGE_DIR, 'schema-lazr.conf')
        config_dir = self.config_dir
        config_file = os.path.join(config_dir,
                                   '%s-lazr.conf' % self.process_name)
        if not os.path.isfile(config_file):
            config_file = os.path.join(config_dir, 'launchpad-lazr.conf')
        schema = ImplicitTypeSchema(schema_file)
        self._config = schema.load(config_file)
        try:
            self._config.validate()
        except ConfigErrors as error:
            message = '\n'.join([str(e) for e in error.errors])
            raise ConfigErrors(message)
        self._setZConfig()
Example #8
0
    def test_multiline_key(self):
        schema = ImplicitTypeSchema(self._testfile('base.conf'))
        config = schema.load(self._testfile('local.conf'))
        self.meq(config['section_33'].key2, """\
multiline value 1
multiline value 2""")
Example #9
0
    def test_multiline_key(self):
        schema = ImplicitTypeSchema(self._testfile('base.conf'))
        config = schema.load(self._testfile('local.conf'))
        self.meq(config['section_33'].key2, """\
multiline value 1
multiline value 2""")