def run(self, shell=None):
        if not self.args:
            self.out('Requires a config file argument')
            return 2
        print(self.args)

        if self.args.search_path:
            os.environ.setdefault('SSC_SEARCH_PATH',
                                  ':'.join(self.args.search_path))

        if self.args.yaml_search_path:
            os.environ.setdefault(
                'SSC_YAML_SEARCH_PATH',
                ':'.join(self.args.yaml_search_path))
        if self.args.yaml_search_recursive is not None:
            os.environ.setdefault(
                'SSC_YAML_SEARCH_RECURSIVE',
                '1' if self.args.yaml_search_recursive else '0')

        if self.args.xls_search_path:
            os.environ.setdefault(
                'SSC_XLS_SEARCH_PATH',
                ':'.join(self.args.xls_search_path))
        if self.args.xls_search_recursive is not None:
            os.environ.setdefault(
                'SSC_XLS_SEARCH_RECURSIVE',
                '1' if self.args.xls_search_recursive else '0')

        if self.args.json_base_path:
            os.environ.setdefault('SSC_JSON_BASE_PATH',
                                  self.args.json_base_path)

        if self.args.timezone:
            os.environ.setdefault('SSC_TIMEZONE',
                                  self.args.timezone)

        for config in self.args.config:
            converter = Converter(YamlConfig.get_config(config))
            converter.run()
def test_convert():
    Converter(YamlConfig.get_config("dummy1.yaml")).run()
    Converter(YamlConfig.get_config("dummy2.yaml")).run()
def test_nothing_foreignkey_convert_error():
    with pytest.raises(ForeignkeyTargetDataDoesNotExistError):
        Converter(YamlConfig.get_config("nothing_foreignkey.yaml")).run()
def test_nothing_field_convert_error():
    with pytest.raises(TargetFieldDoesNotExistError):
        Converter(YamlConfig.get_config("nothing_field.yaml")).run()
Beispiel #5
0
# -*- coding:utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
import os
from spreadsheetconverter import Converter, YamlConfig


if __name__ == "__main__":
    os.environ.setdefault("SSC_SEARCH_PATH", os.path.join(os.getcwd()))

    os.environ.setdefault("SSC_YAML_SEARCH_PATH", os.path.join(os.getcwd(), "yaml"))
    os.environ.setdefault("SSC_YAML_SEARCH_RECURSIVE", "1")

    os.environ.setdefault("SSC_XLS_SEARCH_PATH", os.path.join(os.getcwd(), "xls"))
    os.environ.setdefault("SSC_XLS_SEARCH_RECURSIVE", "1")

    os.environ.setdefault("SSC_JSON_BASE_PATH", os.path.join(os.getcwd(), "json"))

    converter = Converter(YamlConfig.get_config("user/user.yaml"))
    converter.run()
# -*- coding:utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
import os
from spreadsheetconverter import Converter, YamlConfig

if __name__ == '__main__':
    os.environ.setdefault('SSC_SEARCH_PATH', os.path.join(os.getcwd()))

    os.environ.setdefault('SSC_YAML_SEARCH_PATH',
                          os.path.join(os.getcwd(), 'yaml'))
    os.environ.setdefault('SSC_YAML_SEARCH_RECURSIVE', '1')

    os.environ.setdefault('SSC_XLS_SEARCH_PATH',
                          os.path.join(os.getcwd(), 'xls'))
    os.environ.setdefault('SSC_XLS_SEARCH_RECURSIVE', '1')

    os.environ.setdefault('SSC_JSON_BASE_PATH',
                          os.path.join(os.getcwd(), 'json'))

    converter = Converter(YamlConfig.get_config('user/user.yaml'))
    converter.run()
def test_nothing_foreignkey_convert_error():
    with pytest.raises(ForeignkeyTargetDataDoesNotExistError):
        Converter(YamlConfig.get_config('nothing_foreignkey.yaml')).run()
def test_nothing_field_convert_error():
    with pytest.raises(TargetFieldDoesNotExistError):
        Converter(YamlConfig.get_config('nothing_field.yaml')).run()
def test_convert():
    Converter(YamlConfig.get_config('dummy1.yaml')).run()
    Converter(YamlConfig.get_config('dummy2.yaml')).run()