|
@@ -18,10 +18,10 @@ def get_directory_tree(path):
|
|
|
|
|
|
|
|
|
def filter_file(item, condition):
|
|
|
- if condition == '.tif':
|
|
|
- result = os.path.splitext(item)[-1] == condition
|
|
|
+ # if condition == '.tif':
|
|
|
+ # result = os.path.splitext(item)[-1] == condition
|
|
|
|
|
|
- elif condition == 'tileset.json':
|
|
|
+ if condition == 'tileset.json':
|
|
|
result = os.path.basename(item) == condition
|
|
|
|
|
|
else:
|
|
@@ -30,18 +30,41 @@ def filter_file(item, condition):
|
|
|
return result
|
|
|
|
|
|
|
|
|
+def path_replace(path, ext):
|
|
|
+ if ext == '.tif':
|
|
|
+ result = path
|
|
|
+ elif ext == 'tileset.json':
|
|
|
+ result = path.replace(config.common.TILESET_PATH, '')
|
|
|
+ else:
|
|
|
+ result = False
|
|
|
+
|
|
|
+ return result
|
|
|
+
|
|
|
+
|
|
|
def dir_and_file_tree(path, ext, temp_list=[]):
|
|
|
path_tree = os.listdir(path) # 获取当前目录下的文件和目录
|
|
|
for item in path_tree:
|
|
|
subtree = path + '/' + item
|
|
|
if os.path.isdir(subtree): # 判断是否为目录
|
|
|
x1 = []
|
|
|
- item_dict = {'label': item, 'type': 'directory', 'value': path.replace(config.common.TILESET_PATH, ''),
|
|
|
- 'children': x1}
|
|
|
+ item_dict = {
|
|
|
+ 'label': item,
|
|
|
+ 'type': 'directory',
|
|
|
+ 'node': path_replace(path, ext),
|
|
|
+ 'value': path_replace(subtree, ext),
|
|
|
+ 'children': x1
|
|
|
+ }
|
|
|
temp_list.append(item_dict)
|
|
|
dir_and_file_tree(subtree, ext, x1) # 递归深度优先遍历
|
|
|
else:
|
|
|
if filter_file(item, ext):
|
|
|
- temp_list.append({'label': item, 'type': 'file', 'value': path.replace(config.common.TILESET_PATH, '')})
|
|
|
+ temp_list.append(
|
|
|
+ {
|
|
|
+ 'label': item,
|
|
|
+ 'type': 'file',
|
|
|
+ 'node': path_replace(path, ext),
|
|
|
+ 'value': path_replace(subtree, ext)
|
|
|
+ }
|
|
|
+ )
|
|
|
|
|
|
return temp_list
|