写了第一个python程序,感觉很爽。
files = []
file_object = open('G:\_python\package.txt')
try:
for line in file_object:
line = line.rstrip()
if line.endswith('.js'):
[obj_name,file_name] = line.split(',')
ns = obj_name.split('.')
if file_name.startswith('//'):
full_name = 'app//%s' % file_name
else:
if len(ns) == 4:
full_name = 'app//%s//%s//%s' % (ns[1],ns[2],file_name)
else:
full_name = 'app//%s//%s' % (ns[1],file_name)
if full_name not in files:
files.append(full_name)
finally:
file_object.close()
print files
print tuple(files)
package.txt中的内容如下:
MainObjectName,FileName
Divo.app.ChangePassword,ChangePassword.js
Divo.app.ChangePassword,/common/form/passwordfield/js/Ext.ux.PasswordField.js
Divo.app.ChangePassword,/common/form/passwordfield/js/Ext.ux.PasswordField.js
Divo.app.misc.Support,Support.js