コード例 #1
0
ファイル: manifest.py プロジェクト: TaikiAkita/GSMI
    def _load_data(self, new_data):
        """Load data.

        :type new_data: dict
        :param new_data: The data.
        :rtype : bool
        :return: True if succeed.
        """

        #  Check object type.
        if not isinstance(new_data, dict):
            return False

        for key in new_data:
            #  Check key type.
            if not isinstance(key, str):
                return False

            #  Check repository.
            repo_data = new_data[key]
            if (not _gs_utils.check_dictionary_key(repo_data, "name", str, False)) or \
                    (not _gs_utils.check_dictionary_key(repo_data, "clone_url", str, False)):
                return False

        #  Load the data.
        self.__data = new_data

        return True
コード例 #2
0
ファイル: configuration.py プロジェクト: TaikiAkita/GSMI
    def _load_data(self, new_data):
        """Load new data.

        :type new_data: dict
        :param new_data: The new data.
        :rtype : bool
        :return: True if succeed.
        """

        #  Check data type.
        if not isinstance(new_data, dict):
            return False

        #  Initialize the checking table.
        checks = [
            ("project", str),
            ("timeout.manifest", int),
            ("timeout.clone", int),
            ("timeout.fetch", int),
            ("retry.times", int),
            ("retry.delay", int),
            ("threads", int),
        ]

        #  Check the data.
        for check_path, check_type in checks:
            if not _gs_utils.check_dictionary_key(new_data, check_path, check_type, False):
                return False

        #  Load the new data.
        self.__data = new_data

        return True
コード例 #3
0
ファイル: repository.py プロジェクト: TaikiAkita/GSMI
    def _load_data(self, new_data):
        """Load new data.

        :type new_data: dict
        :param new_data: The new data.
        :rtype : bool
        :return: True if succeed.
        """

        #  Check data type.
        if not isinstance(new_data, dict):
            return False

        #  Check root dictionary.
        if (not _gs_utils.check_dictionary_key(new_data, "n->p", dict, False)) or \
                (not _gs_utils.check_dictionary_key(new_data, "p->n", dict, False)):
            return False

        #  Get two sub dictionaries.
        name_to_id = new_data["n->p"]
        id_to_name = new_data["p->n"]

        #  Check the length.
        if len(name_to_id) != len(id_to_name):
            return False

        for repo_id in id_to_name:
            #  Check the ID.
            if (not isinstance(repo_id, str)) or (not _check_repository_id(repo_id)):
                return False

            #  Check the value type.
            if not _gs_utils.check_dictionary_key(id_to_name, repo_id, str, False):
                return False

            #  Get the repository name.
            repo_name = id_to_name[repo_id]

            #  Reverse check.
            if repo_name not in name_to_id or name_to_id[repo_name] != repo_id:
                return False

        #  Load the new data.
        self.__data = new_data

        return True