Exemplo n.º 1
0
 def __init__(self, manifest_path, overrides_path, templatedir, targetdir, ):
     self._manifest_path = manifest_path
     self._overrides_path = overrides_path
     self._template_loader = TemplateLoader([templatedir])
     self._file_generator = FileGenerator(self._template_loader, targetdir)
     self._manifest_parser = ManifestParser()
     self._overrides_parser = ManifestOverridesParser()
Exemplo n.º 2
0
class GenConf(object):
    def __init__(self, manifest_path, overrides_path, templatedir, targetdir, ):
        self._manifest_path = manifest_path
        self._overrides_path = overrides_path
        self._template_loader = TemplateLoader([templatedir])
        self._file_generator = FileGenerator(self._template_loader, targetdir)
        self._manifest_parser = ManifestParser()
        self._overrides_parser = ManifestOverridesParser()
        
    
    def generate(self, error_listener=DefaultGenConfErrorListener(), event_listener=DefaultGenConfEventListener()):
        overrides = self._parse_overrides(error_listener, event_listener)
        
        with codecs.open(self._manifest_path, 'rb', 'utf-8') as f:
            try:
                manifest = self._manifest_parser.parse(f, overrides)
                event_listener.on_manifest_parsed(self._manifest_path, manifest)
                self._file_generator.generate_files(manifest, error_listener, event_listener)
            except ManifestParsingError, e:
                error_listener.on_manifest_parsing_error(self._manifest_path, e)
Exemplo n.º 3
0
class ManifestParsingTestCase(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.parser = ManifestParser()
        self.manifest = self.parser.parse(samples.simple_manifest_stream)

    def test_should_parse_simple_manifest(self):
        assert len(self.manifest.profiles) == 2

    def test_should_create_development_profile(self):
        development_profile = self.manifest.profile("development")
        assert development_profile.is_abstract == False
        assert len(development_profile.properties) == 3 + NUMBER_OF_AUTO_GENERATED_PROPERTIES
        assert len(development_profile._extends) == 1
        assert development_profile._extends[0] == self.manifest.profile("all")
        assert len(development_profile.output_files) == 3

    def test_should_create_all_profile(self):
        all_profile = self.manifest.profile("all")
        assert all_profile.is_abstract == True
        assert len(all_profile.properties) == 2 + NUMBER_OF_AUTO_GENERATED_PROPERTIES
        assert len(all_profile._extends) == 0
class ManifestParsingTestCase(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.parser = ManifestParser()
        self.manifest = self.parser.parse(samples.simple_manifest_stream)

    def test_should_parse_simple_manifest(self):
        assert len(self.manifest.profiles) == 2

    def test_should_create_development_profile(self):
        development_profile = self.manifest.profile("development")
        assert development_profile.is_abstract == False
        assert len(development_profile.properties
                   ) == 3 + NUMBER_OF_AUTO_GENERATED_PROPERTIES
        assert len(development_profile._extends) == 1
        assert development_profile._extends[0] == self.manifest.profile("all")
        assert len(development_profile.output_files) == 3

    def test_should_create_all_profile(self):
        all_profile = self.manifest.profile("all")
        assert all_profile.is_abstract == True
        assert len(
            all_profile.properties) == 2 + NUMBER_OF_AUTO_GENERATED_PROPERTIES
        assert len(all_profile._extends) == 0
Exemplo n.º 5
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     self.parser = ManifestParser()
     self.manifest = self.parser.parse(samples.simple_manifest_stream)
Exemplo n.º 6
0
"""
   Copyright 2011 Sami Dalouche

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
"""
from pkg_resources import resource_string
from genconf.manifest import ManifestParser, ManifestOverridesParser

simple_manifest_stream = resource_string('tests.genconftests.samples', 'simple.yaml')
simple_manifest = ManifestParser().parse(simple_manifest_stream)
development_profile = simple_manifest.profile("development")
all_profile = simple_manifest.profile("all")

simple_overrides_stream = resource_string('tests.genconftests.samples', 'simple-overrides.yaml')
simple_overrides = ManifestOverridesParser().parse(simple_overrides_stream)
Exemplo n.º 7
0
"""
   Copyright 2011 Sami Dalouche

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
"""
from pkg_resources import resource_string
from genconf.manifest import ManifestParser, ManifestOverridesParser

simple_manifest_stream = resource_string('tests.genconftests.samples',
                                         'simple.yaml')
simple_manifest = ManifestParser().parse(simple_manifest_stream)
development_profile = simple_manifest.profile("development")
all_profile = simple_manifest.profile("all")

simple_overrides_stream = resource_string('tests.genconftests.samples',
                                          'simple-overrides.yaml')
simple_overrides = ManifestOverridesParser().parse(simple_overrides_stream)
 def setUp(self):
     unittest.TestCase.setUp(self)
     self.parser = ManifestParser()
     self.manifest = self.parser.parse(samples.simple_manifest_stream)