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