예제 #1
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
예제 #2
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')
예제 #3
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()