Пример #1
0
def create_standard_tables():
    parser = optparse.OptionParser(
        usage='usage: %prog [options]',
        description='Create all content for the standard database')
    parser.add_option('-c',
                      '--configuration',
                      dest='configuration',
                      metavar='YAML',
                      type='string',
                      help='The absolute path to the configuration yaml file.')
    parser.add_option(
        '-s',
        '--section',
        dest='section',
        metavar='SECTION',
        type='string',
        default='pyramid_oereb',
        help=
        'The section which contains configuration (default is: pyramid_oereb).'
    )
    parser.add_option('-T',
                      '--tables-only',
                      dest='tables_only',
                      action='store_true',
                      default=False,
                      help='Use this flag to skip the creation of the schema.')
    parser.add_option('--sql-file',
                      type='string',
                      help='Generate an SQL file.')
    parser.add_option(
        '--c2ctemplate-style',
        dest='c2ctemplate_style',
        action='store_true',
        default=False,
        help='Is the yaml file using a c2ctemplate style (starting with vars)')
    options, args = parser.parse_args()
    if not options.configuration:
        parser.error('No configuration file set.')

    if options.sql_file is None:
        create_tables_from_standard_configuration(
            configuration_yaml_path=options.configuration,
            section=options.section,
            c2ctemplate_style=options.c2ctemplate_style,
            tables_only=options.tables_only)
    else:
        with open(options.sql_file, 'w') as sql_file:
            create_tables_from_standard_configuration(
                configuration_yaml_path=options.configuration,
                section=options.section,
                c2ctemplate_style=options.c2ctemplate_style,
                sql_file=sql_file)
Пример #2
0
            plr_source_class = DottedNameResolver().maybe_resolve(
                plr.get('source').get('class'))
            plr_sources.append(plr_source_class(**plr))

        extract_reader = ExtractReader(plr_sources, plr_cadastre_authority,
                                       logos)
        self.processor = Processor(
            real_estate_reader=real_estate_reader,
            municipality_reader=municipality_reader,
            exclusion_of_liability_reader=exclusion_of_liability_reader,
            glossary_reader=glossary_reader,
            plr_sources=plr_sources,
            extract_reader=extract_reader,
        )

    @property
    def pyramid_oereb_processor(self):
        return self.processor

    def current_route_url(self, *elements, **kw):
        if self._current_route_url:
            return self._current_route_url
        else:
            return super(MockRequest, self).current_route_url(*elements, **kw)


# Set up test database
create_tables_from_standard_configuration(pyramid_oereb_test_yml)
dummy_data = DummyData(config())
dummy_data.init()
Пример #3
0
def test_create_standard_db():
    assert pyramid_oereb_test_yml is not None
    from pyramid_oereb.standard import create_tables_from_standard_configuration
    create_tables_from_standard_configuration(pyramid_oereb_test_yml)