1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
import random
import os
import string
def text_createH(fileNmae,msg,msg1,propertyNumber,methodArray,msg3):
full_path = '/Users/zhoujinglin/Desktop/python-H-M/' + fileNmae + '.h'
file = open(full_path, 'w')
file.write('//\n// '+fileNmae+'.h\n// SajiaoShopping\n\n// Created by Kaaaaai bo on 18/06/28.\n// Copyright © 2018年 Kaaaaai. All rights reserved.\n//\n\n')
file.write(msg)
file.write(msg1)
propryNameArray = []
for index in range(1,propertyNumber):
propryNameArray.append(random.choice(array))
propryNameArray = list(set(propryNameArray))
for propertyName in propryNameArray: file.write('@property(nonatomic,strong)'+random.choice(classArray)+' * '+propertyName+';\n')
file.write('\n\n')
for methodName in methodArray:
file.write('- (void)pushTo'+methodName+'VC:(NSDictionary *)info;\n')
file.write(msg3)
file.close()
print('Done')
def text_createM(fileNmae,msg,msg1,methodArray,msg3):
full_path = '/Users/zhoujinglin/Desktop/python-H-M/' + fileNmae + '.m'
file = open(full_path, 'w')
file.write('//\n// '+fileNmae+'.m\n// SajiaoShopping\n\n// Created by Kaaaaai bo on 18/06/28.\n// Copyright © 2017年 Kaaaaai. All rights reserved.\n//\n\n')
file.write(msg)
file.write(msg1)
for methodName in methodArray:
file.write('- (void)pushTo'+methodName+'VC:(NSDictionary *)info\n{\n\n NSMutableArray *array = [NSMutableArray array];\n')
number = random.randint(3, 10)
for i in range(1,number):
file.write(' [array addObject:@"'+random.choice(array)+'"];\n')
file.write('\n}\n\n')
file.write(msg3)
file.close()
print('Done')
classArray = ['NSString','UILabel','NSDictionary','NSData','UIScrollView','UIView']
array = ['HwxrFvrj', 'QnzduQbtdd', 'PvcrwLtqhf', 'UvdhDbjn', 'SuntmyTxvyzg', 'CvlxwBipbp', 'GzrdyzIbimvz', 'CqsjqMmgsp', 'OxaaeuWjhasc', 'NjiardRvwgbi', 'NcculmLtpljq', 'ApoqQrll', 'GkgokDyvjb', 'EblldkVouplj', 'KfdrFvnw', 'SfhyhObftc', 'SmruByoc', 'YzcccvXmpmit', 'OmqvaHpxat', 'XzytsUyvyd', 'MjforNnnyi', 'ZvjhuIdogs', 'BzfrxzSeahxc', 'PycycwFjtpny', 'XvngtoSedljr', 'DktiaCbucd', 'AqbplNuodc', 'MzkvgZuala', 'KdwzIoej', 'AaynatUpqcfd', 'IyvwhZvtjc', 'UmijGmsy', 'AoayndXxghym']
array = list(set(array))
for name in array:
number = random.randint(3, 10)
methodArray = []
for i in range(1,5):
methodArray.append(random.choice(array))
methodArray = list(set(methodArray))
text_createH(name+'ViewController', '#import <UIKit/UIKit.h>\n','@interface '+name+ 'ViewController:'+ 'UIViewController\n\n',number,methodArray,'\n\n@end')
text_createM(name+'ViewController', '#import "'+name+'ViewController.h"\n\n' '@interface '+ name+'ViewController()\n\n @end\n\n','@implementation '+name+'ViewController\n\n- (void)viewDidLoad { \n\n [super viewDidLoad];\n\n}\n\n',methodArray,'\n\n@end')
|