Пример #1
0
    def test_reading_generated_file(self):
        dump = self.config.dump()

        re_init_config = BootConfigParser(dump)
        re_init_dump = re_init_config.dump()

        self.assertEqual(dump.splitlines(), re_init_dump.splitlines())
    def test_reading_generated_file(self):
        dump = self.config.dump()

        re_init_config = BootConfigParser(dump)
        re_init_dump = re_init_config.dump()

        self.assertEqual(dump.splitlines(), re_init_dump.splitlines())
Пример #3
0
    def get_value(self, name, config_filter=Filter.ALL, fallback=True):
        lines = read_file_contents_as_lines(self.path)
        if not lines:
            return 0

        config = BootConfigParser(lines)
        return config.get(name, config_filter=config_filter, fallback=fallback)
Пример #4
0
    def get_value(self, name, config_filter=Filter.ALL, fallback=True, ignore_comments=False):
        lines = read_file_contents_as_lines(self.path)
        if not lines:
            return 0

        config = BootConfigParser(lines)
        return config.get(
            name,
            config_filter=config_filter,
            fallback=fallback,
            ignore_comments=ignore_comments
        )
Пример #5
0
    def set_value(self, name, value=None, config_filter=Filter.ALL):
        # if the value argument is None, the option will be commented out
        lines = read_file_contents_as_lines(self.path)
        if not lines:  # this is true if the file is empty, not sure that was intended.
            return

        logger.info('writing value to {} {} {}'.format(self.path, name, value))

        config = BootConfigParser(lines)
        config.set(name, value, config_filter=config_filter)

        with open_locked(self.path, "w") as boot_config_file:
            boot_config_file.write(config.dump())

            # flush changes to disk
            boot_config_file.flush()
            os.fsync(boot_config_file.fileno())
Пример #6
0
    def set_value(self, name, value=None, config_filter=Filter.ALL):
        # if the value argument is None, the option will be commented out
        lines = read_file_contents_as_lines(self.path)
        if not lines:  # this is true if the file is empty, not sure that was intended.
            return

        logger.info('writing value to {} {} {}'.format(self.path, name, value))

        config = BootConfigParser(lines)
        config.set(name, value, config_filter=config_filter)

        with open_locked(self.path, "w") as boot_config_file:
            boot_config_file.write(config.dump())

            # flush changes to disk
            boot_config_file.flush()
            os.fsync(boot_config_file.fileno())
Пример #7
0
 def test_empty_list_init(self):
     test = BootConfigParser([])
     self.check_null_get(test)
Пример #8
0
 def test_empty_string_init(self):
     test = BootConfigParser('')
     self.check_null_get(test)
Пример #9
0
 def test_none_init(self):
     test = BootConfigParser(None)
     self.check_null_get(test)
Пример #10
0
 def test_list_init(self):
     test = BootConfigParser(self.base_config.splitlines())
     self.compare_config_dumps(self.base_config, test.dump())
Пример #11
0
 def setUp(self):
     self.base_config = BASE_TEST_CONFIG
     self.config = BootConfigParser(self.base_config)
 def test_list_init(self):
     test = BootConfigParser(self.base_config.splitlines())
     self.compare_config_dumps(self.base_config, test.dump())