# coding: utf8 import os import sys import re from subprocess import Popen DATA_ROOT = r'D:\dev\lr\rawres\res_ui\data\editor_data' + '\\' EDITOR_ROOT = ur'D:\dev\dev_coco\设计文档\svn\editors'.encode('cp936') LOCAL_DIR = r'..\rawres\res_ui\output\pc\ui.lua' def call_editor(exe, arg): cwd = os.getcwd() os.chdir(EDITOR_ROOT) Popen([exe, arg]) os.chdir(cwd) def openui(name): with open(LOCAL_DIR, 'r') as f: c = f.read() cex = re.compile(r'\n\texport = "{}"'.format(name)) cfi = re.compile(r'\n\t-- file: (.*?)\n') for m in re.finditer(r'\n{\n.*?\n},', c, re.S): e = m.group() mex = cex.search(e) if not mex: continue mfi = cfi.search(e) if not mfi: continue path = mfi.group(1) # easyui mui = re.match(r'^(.*)_wrapper_complex\[gen\]\.json$', path) if mui: final = DATA_ROOT + mui.group(1) + '_uiwnd.json' call_editor('easyui.exe', final) break # easycomplex mcx = re.match(r'^(.*)_complex\.json$', path) if mcx: final = DATA_ROOT + path call_editor('easycomplex.exe', final) break # TODO: anim json print 'unknown path type:', path break else: print 'not found:', name if __name__ == '__main__': if len(sys.argv) == 2: openui(sys.argv[1])