Example #1
0
    def setUpClass(cls):
        cls.state = State(DEBUG_BUILD_CONFIG, DEBUG_BUILD_CONFIG.version, [],
                          [])
        cls.another = State(DEBUG_BUILD_CONFIG, DEBUG_BUILD_CONFIG.version,
                            ["__packages__"], ["__editor__"])

        cls.Init = InitCommand(DEBUG_BUILD_CONFIG)
        cls.Init.create_state_directory()

        cls.state.write()
Example #2
0
    def create_state_directory(self):
        """
        Create the directory for the state file, unless it already exists
        """

        ensure_root_access()
        os.makedirs(self.build_config.state_path.parent, exist_ok=True)

        new_state = State(self.build_config, self.build_config.version, [], [])
        new_state.write()

        os.makedirs(self.build_config.json_state_path,
                    exist_ok=True)  # for custom commands
    def setUpClass(cls, instance: EditorBaseKeyword):
        if not (issubclass(type(instance), EditorBaseKeyword)
                or issubclass(type(instance), AbstractKeyword)):
            raise ValueError(
                f'expecting subclass of `EditorBaseKeyword` or `AbstractKeyword`'
            )

        cls.state = State(instance.build_config, instance.build_config.version,
                          [], [])
        cls.Init = InitCommand(instance.build_config)
        cls.Init.create_state_directory()
        cls.state.write()

        cls.keyword = instance

        _type = type(cls.keyword)
        if (issubclass(_type, AbstractKeyword)
                and not issubclass(_type, EditorBaseKeyword)):
            cls.correct_attr = (True, False
                                )  # 0: regular keyword, 1: editorkeyword
        else:
            cls.correct_attr = (False, True)

        cls.generic_check_available_candidates()
        cls.generic_check_links()
 def setUpClass(cls):
     cls.state = State(DEBUG_BUILD_CONFIG, DEBUG_BUILD_CONFIG.version, [],
                       [])
     cls.custom = CustomCommand(DEBUG_BUILD_CONFIG)
     cls.init = InitCommand(DEBUG_BUILD_CONFIG)
     cls.init.create_state_directory()
     cls.state.write()
Example #5
0
    def execute(self, arguments: list):
        if not (isinstance(arguments, list)
                and all([isinstance(_, str)
                         for _ in arguments]) and not arguments):
            # this should also be caught when testing (give multiple args)
            raise ValueError

        if (STATE_PATH.exists()):
            raise UsageError("init has already been done")

        self.create_state_directory()

        self.configure_git()

        state = State(self.build_config, self.build_config.version, [],
                      ["atom"])
        state.write()

        print('[INFO] Tuffix init succeeded')
Example #6
0
    def rewrite_state(self, keyword: AbstractKeyword, install: bool):
        """
        Goal: update the state file
        """
        if not (issubclass(type(keyword), AbstractKeyword)
                and isinstance(install, bool)):
            raise ValueError

        current_state = read_state(self.build_config)
        _type, attribute = self.obtain_correct_attribute(
            keyword, current_state)

        if (not install):
            attribute.remove(keyword.name)
        else:
            attribute.append(keyword.name)

        new_state = State(
            self.build_config, self.build_config.version, attribute if
            (_type == "AbstractKeyword") else current_state.installed,
            attribute if
            (_type == "EditorBaseKeyword") else current_state.editors)
        new_state.write()