Exemplo n.º 1
0
 def fill_dir_tree(dirs, byte_size, file_nums, file_ext_list):
     tree = []
     total_dirs = len(dirs)
     chose_flag = True
     copy_ext_list = file_ext_list[:]
     for i in range(total_dirs):
         ext_list = []
         if chose_flag:
             if (len(copy_ext_list) > 0):
                 ext = random.choice(copy_ext_list)
                 ext_list.append(ext)
                 copy_ext_list.remove(ext)
             else:
                 chose_flag = False
                 copy_ext_list = file_ext_list[:]
                 ext_list.append(JRand.chose_nearest(copy_ext_list))
         else:
             ext_list.append(JRand.chose_nearest(copy_ext_list))
         dir_size = JRand.rand_lave(byte_size, total_dirs, i)
         dir_sons = JRand.rand_lave(file_nums, total_dirs, i)
         byte_size -= dir_size
         file_nums -= dir_sons
         tree.append(JFillerFolder(dirs[i], dir_size, dir_sons, ext_list))
     return tree
Exemplo n.º 2
0
 def __make__declare(self):
     var_list = self.variables.keys()
     # 生成指令表
     msgNums = 1 + JRand.rand_nearest(4)  # [1, 5]
     for i in range(msgNums):
         while (True):
             n = JOcHelper.var(self.messages)
             if (n not in var_list):
                 self.messages.append(n)
                 break
     # 生成参数表
     argNums = msgNums if (msgNums != 1) else (0 if (
         random.random() < 0.5) else 1)
     if (argNums > 0):
         self.argTypes = []
         self.argNames = []
         for i in range(argNums):
             self.argTypes.append(JRand.chose_nearest(OC_BASE))
             while (True):
                 n = JOcHelper.var(self.argNames)
                 if (n not in var_list):
                     self.argNames.append(n)
                     break
Exemplo n.º 3
0
 def makeDeclare(self, scope):
     self.scope = scope
     self.ret = JRand.chose_nearest(OC_RET)
     self.__make__declare()