コード例 #1
0
    def generate_function_name(random_prev_length=3,
                               random_end_length=3,
                               max_word=5,
                               prev_probability=10,
                               auto_add_prev_probability=80):
        name = ""
        if random.randint(0, 100) < prev_probability:
            name += function_prev_words[random.randint(
                0, function_prev_words_lenth - 1)]
        elif random_prev_length > 0 and random.randint(
                0, 100) < auto_add_prev_probability:
            name += RandomGenerater.generate_string_first_lower(
                random_prev_length, random_prev_length)

        word_count = random.randint(1, max_word)

        indexs = range(function_main_words_lenth)

        for i in range(word_count):
            indx = random.randint(0, function_main_words_lenth - 1 - i)
            name += function_main_words[indexs[indx]]
            indexs[indx] = indexs[-1 - i]

        if random_end_length > 0:
            name += RandomGenerater.generate_string_first_upper(
                random_end_length, random_end_length)
        return name[0].lower() + name[1:]
コード例 #2
0
    def generate_file(self, out_folder_path, class_index):
        class_name = RandomGenerater.generate_string_first_upper(8, 16)
        head_file_name = os.path.join(out_folder_path, class_name + ".h")
        source_file_name = os.path.join(out_folder_path,
                                        class_name + self.source_file_ext)
        self.generated_files.append(head_file_name)
        self.generated_files.append(source_file_name)
        self.generated_head_files.append(class_name + ".h")

        field_count = gc_utils.get_range_count("field_count",
                                               self.generate_config, 3)
        method_count = gc_utils.get_range_count("method_count",
                                                self.generate_config, 5)
        parameter_count = gc_utils.get_range_count("parameter_count",
                                                   self.generate_config, 3)
        return_probability = gc_utils.get_range_count("return_probability",
                                                      self.generate_config, 5)

        generator = ObjcFile({
            "head_file": head_file_name,
            "source_file": source_file_name,
            "tpl_folder": self.tpl_folder_path,
            "class_name": class_name,
            "field_count": field_count,
            "method_count": method_count,
            "parameter_count": parameter_count,
            "return_probability": return_probability,
            "call_others": self.generate_config["call_others"],
            "search_path": self.generate_config["search_path"]
        })

        generator.prepare()
        generator.generate_code()
        return generator.get_class_execute_chain(class_index)
コード例 #3
0
    def generate_rule_name(random_prev_length=3,
                           random_end_length=3,
                           max_word=5,
                           prev_probability=10):
        name = RandomGenerater.generate_string_first_upper(
            random_prev_length, random_prev_length)
        if random.randint(0, 100) < prev_probability:
            name += name_prev_words[random.randint(0,
                                                   name_prev_words_lenth - 1)]

        word_count = random.randint(1, max_word)
        for _ in range(word_count):
            name += name_main_words[random.randint(0,
                                                   name_main_words_lenth - 1)]

        name += RandomGenerater.generate_string_first_upper(
            random_end_length, random_end_length)
        return name