Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import io
- def findTex(texPath = None, type = None):
- if texPath is None:
- print('Please specify a texture path')
- else:
- matPath = 'Art' + texPath.split('art')[1]
- matPath = matPath.strip('.png')
- tgtpath = "E:/4.0.0/bin/client/art/models/terrain/"
- tgtfiles, dirList, tgtList = [], [], []
- for dirpath, subdirs, files in os.walk(tgtpath):
- for x in files:
- if x.endswith('.tgt'):
- tgtfiles.append(os.path.join(dirpath, x))
- for tgt in tgtfiles:
- file = io.open(tgt, 'r', encoding = 'utf-16-le')
- contents = file.readlines()
- for line in contents:
- if matPath + 'c.mat' in line:
- tgtList.append(tgt)
- hit = os.path.split(tgt)[0]
- artpath = os.path.join(hit.split('bin/client')[0], hit.split('bin/client')[1])
- dirList.append(artpath.replace('\\', '/'))
- elif matPath + 'cn.mat' in line:
- tgtList.append(tgt)
- hit = os.path.split(tgt)[0]
- artpath = os.path.join(hit.split('bin/client')[0], hit.split('bin/client')[1])
- dirList.append(artpath.replace('\\', '/'))
- elif matPath + 'cns.mat' in line:
- tgtList.append(tgt)
- hit = os.path.split(tgt)[0]
- artpath = os.path.join(hit.split('bin/client')[0], hit.split('bin/client')[1])
- elif matPath + 'ns.mat' in line:
- tgtList.append(tgt)
- hit = os.path.split(tgt)[0]
- artpath = os.path.join(hit.split('bin/client')[0], hit.split('bin/client')[1])
- dirList.append(artpath.replace('\\', '/'))
- dirList = list(dict.fromkeys(dirList))
- if type == 'art':
- for dir in dirList:
- print(dir)
- elif type == 'tgt':
- for tgtpath in tgtList:
- print(tgtpath)
- elif type == None:
- for dir in dirList:
- print(dir)
- '''for tgt in tgtfiles:
- file = io.open(tgt, 'r', encoding = 'utf-16-le')
- content = file.readlines()
- if '"Art/Textures/Environment/forest/RiverEdge/SharpRocksc.mat"' in content:
- print (tgt)'''
- findTex('E:/4.0.0/art/Textures/Environment/Woods/Courtyard/Cliff_01.png', 'tgt')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement