def setup_config(conf):
    config_struct = config.Struct()
    config.loadini(config_struct, os.devnull)
    for key, value in conf.items():
        if not hasattr(config_struct, key):
            raise ValueError("%r is not a valid config attribute" % (key, ))
        setattr(config_struct, key, value)
    return config_struct
Beispiel #2
0
def setup_config(conf):
    config_struct = config.Struct()
    config.loadini(config_struct, TEST_CONFIG)
    for key, value in conf.items():
        if not hasattr(config_struct, key):
            raise ValueError(f"{key!r} is not a valid config attribute")
        setattr(config_struct, key, value)
    return config_struct
Beispiel #3
0
    def test_load_theme(self):
        struct = config.Struct()
        struct.color_scheme = dict()
        config.load_theme(struct, TEST_THEME_PATH, struct.color_scheme, dict())
        expected = {"keyword": "y"}
        self.assertEquals(struct.color_scheme, expected)

        defaults = {"name": "c"}
        expected.update(defaults)
        config.load_theme(struct, TEST_THEME_PATH, struct.color_scheme, defaults)
        self.assertEquals(struct.color_scheme, expected)
Beispiel #4
0
    def load_temp_config(self, content, struct=None):
        """Write config to a temporary file and load it."""

        if struct is None:
            struct = config.Struct()

        with tempfile.NamedTemporaryFile() as f:
            f.write(content.encode("utf8"))
            f.flush()

            config.loadini(struct, f.name)

        return struct
Beispiel #5
0
    def test_load_theme(self):
        struct = config.Struct()
        struct.color_scheme = dict()
        config.load_theme(struct, TEST_THEME_PATH, struct.color_scheme, dict())
        expected = {'keyword': 'y'}
        self.assertEqual(struct.color_scheme, expected)

        defaults = {'name': 'c'}
        expected.update(defaults)
        config.load_theme(
            struct,
            TEST_THEME_PATH,
            struct.color_scheme,
            defaults)
        self.assertEqual(struct.color_scheme, expected)
def setup_config(conf):
    config_struct = config.Struct()
    config.loadini(config_struct, os.devnull)
    if 'autocomplete_mode' in conf:
        config_struct.autocomplete_mode = conf['autocomplete_mode']
    return config_struct
def setup_config():
    config_struct = config.Struct()
    config.loadini(config_struct, TEST_CONFIG)
    config_struct.cli_suggestion_width = 1
    return config_struct
Beispiel #8
0
def setup_config(conf):
    config_struct = config.Struct()
    config.loadini(config_struct, TEST_CONFIG)
    if conf is not None and "autocomplete_mode" in conf:
        config_struct.autocomplete_mode = conf["autocomplete_mode"]
    return config_struct
Beispiel #9
0
 def __init__(self):
     config_struct = config.Struct()
     config.loadini(config_struct, os.devnull)
     repl.Repl.__init__(self, repl.Interpreter(), config_struct)
     self.input_line = ""
def setup_config():
    config_struct = config.Struct()
    config.loadini(config_struct, os.devnull)
    return config_struct
Beispiel #11
0
def setup_config(conf):
    config_struct = config.Struct()
    config.loadini(config_struct, TEST_CONFIG)
    if 'autocomplete_mode' in conf:
        config_struct.autocomplete_mode = conf['autocomplete_mode']
    return config_struct
def setup_config():
    config_struct = config.Struct()
    config.loadini(config_struct, os.devnull)
    config_struct.cli_suggestion_width = 1
    return config_struct