1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #coding=utf-8
- import re
- import sys
- reload(sys)
- sys.setdefaultencoding('utf8')
- profile_name = 'BYHRoomStringKeyProfile'
- profile_h = '/Room/' + profile_name + '.h'
- profile_m = '/Room/' + profile_name + '.m'
- en_strings = '/Room/en.lproj/Room.strings'
- zh_strings = '/Room/zh-Hans.lproj/Room.strings'
- table_key = 'BYHRoomTable'
- table_value = 'Room'
- host = sys.path[0] + '/BuYao/BuYao'
- f=open(host + profile_h, "r+")
- f.truncate()
- f.write('#import <UIKit/UIKit.h>\n#import <JXHMacro.h>\n#import "BYHLocalizationManager.h"\n\n' + 'CONST_STRING_INTERFACE ' + table_key + ';\n')
- f.close()
- f=open(host + profile_m, "r+")
- f.truncate()
- f.write('#import "' + profile_name + '.h"\n\n' + 'CONST_STRING ' + table_key + ' = @"' + table_value + '";\n')
- f.close()
- f=open(host + en_strings, "r+")
- f.truncate()
- f.close()
- f = open(host + zh_strings, 'r')
- lines = f.readlines()
- for line in lines:
- if line == "\n":
- print "换行"
- f = open(host + profile_h, 'a')
- f.write('\n')
- f.close()
- f = open(host + profile_m, 'a')
- f.write('\n')
- f.close()
- f = open(host + en_strings, 'a')
- f.write('\n')
- f.close()
- continue
- if line.startswith('///'):
- print "小注释"
- f = open(host + profile_h, 'a')
- f.write(line[1:len(line)])
- f.close()
- f = open(host + profile_m, 'a')
- f.write(line[1:len(line)])
- f.close()
- f = open(host + en_strings, 'a')
- f.write(line)
- f.close()
- continue
- if line.startswith('//'):
- print "大注释"
- f = open(host + profile_h, 'a')
- f.write('#pragma mark - ' + line[2:len(line)])
- f.close()
- f = open(host + profile_m, 'a')
- f.write('#pragma mark - ' + line[2:len(line)])
- f.close()
- f = open(host + en_strings, 'a')
- f.write(line)
- f.close()
- continue
- matchObj = re.match('\"([^\"]*)\"', line, flags=0)
- if matchObj:
- f = open(host + profile_h, 'a')
- f.write('CONST_STRING_INTERFACE ' + matchObj.group(1) + 'StringKey;\n')
- f.close()
- f = open(host + profile_m, 'a')
- f.write('CONST_STRING ' + matchObj.group(1) + 'StringKey' + ' = @"' + matchObj.group(1) + '";\n')
- f.close()
- f = open(host + en_strings, 'a')
- # f.write(matchObj.group() + ' = "";\n')
- f.write(line)
- f.close()
- print "matchObj.group(1) : ", matchObj.group(1)
- else:
- print "No match!!"
|