コード例 #1
0
    def scheme_of_file_by_path(self):
        # type:  () -> Optional[str]
        """Running on given regexes from `constants` to find out what type of file it is

        Returns:
            (str): Type of file by scheme name
        """

        for scheme_name, regex_list in SCHEMA_TO_REGEX.items():
            if checked_type_by_reg(self.file_path, regex_list):
                return scheme_name

        pretty_formatted_string_of_regexes = json.dumps(SCHEMA_TO_REGEX, indent=4, sort_keys=True)

        error_message, error_code = Errors.structure_doesnt_match_scheme(pretty_formatted_string_of_regexes)
        self.handle_error(error_message, error_code, file_path=self.file_path)

        return None
コード例 #2
0
ファイル: structure.py プロジェクト: luongthomas/demisto-sdk
    def scheme_of_file_by_path(self):
        # type:  () -> Optional[str]
        """Running on given regexes from `constants` to find out what type of file it is

        Returns:
            (str): Type of file by scheme name
        """

        for scheme_name, regex_list in SCHEMA_TO_REGEX.items():
            if get_matching_regex(self.file_path, regex_list):
                return scheme_name

        if get_matching_regex(self.file_path, [REPUTATION_REGEX]):
            return 'reputation'

        pretty_formated_string_of_regexes = json.dumps(SCHEMA_TO_REGEX, indent=4, sort_keys=True)

        print_error(f"The file {self.file_path} does not match any scheme we have please, refer to the following list"
                    f" for the various file name options we have in our repo {pretty_formated_string_of_regexes}")
        return None