Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. import os
  2. import io
  3.  
  4. def findTex(texPath = None, type = None):
  5. if texPath is None:
  6. print('Please specify a texture path')
  7. else:
  8. matPath = 'Art' + texPath.split('art')[1]
  9. matPath = matPath.strip('.png')
  10.  
  11. tgtpath = "E:/4.0.0/bin/client/art/models/terrain/"
  12.  
  13. tgtfiles, dirList, tgtList = [], [], []
  14.  
  15. for dirpath, subdirs, files in os.walk(tgtpath):
  16. for x in files:
  17. if x.endswith('.tgt'):
  18. tgtfiles.append(os.path.join(dirpath, x))
  19.  
  20.  
  21.  
  22. for tgt in tgtfiles:
  23. file = io.open(tgt, 'r', encoding = 'utf-16-le')
  24. contents = file.readlines()
  25. for line in contents:
  26. if matPath + 'c.mat' in line:
  27. tgtList.append(tgt)
  28. hit = os.path.split(tgt)[0]
  29. artpath = os.path.join(hit.split('bin/client')[0], hit.split('bin/client')[1])
  30.  
  31. dirList.append(artpath.replace('\\', '/'))
  32. elif matPath + 'cn.mat' in line:
  33. tgtList.append(tgt)
  34. hit = os.path.split(tgt)[0]
  35. artpath = os.path.join(hit.split('bin/client')[0], hit.split('bin/client')[1])
  36.  
  37. dirList.append(artpath.replace('\\', '/'))
  38. elif matPath + 'cns.mat' in line:
  39. tgtList.append(tgt)
  40. hit = os.path.split(tgt)[0]
  41. artpath = os.path.join(hit.split('bin/client')[0], hit.split('bin/client')[1])
  42. elif matPath + 'ns.mat' in line:
  43. tgtList.append(tgt)
  44. hit = os.path.split(tgt)[0]
  45. artpath = os.path.join(hit.split('bin/client')[0], hit.split('bin/client')[1])
  46.  
  47. dirList.append(artpath.replace('\\', '/'))
  48.  
  49.  
  50. dirList = list(dict.fromkeys(dirList))
  51.  
  52. if type == 'art':
  53. for dir in dirList:
  54. print(dir)
  55. elif type == 'tgt':
  56. for tgtpath in tgtList:
  57. print(tgtpath)
  58. elif type == None:
  59. for dir in dirList:
  60. print(dir)
  61.  
  62.  
  63.  
  64.  
  65. '''for tgt in tgtfiles:
  66. file = io.open(tgt, 'r', encoding = 'utf-16-le')
  67. content = file.readlines()
  68.  
  69. if '"Art/Textures/Environment/forest/RiverEdge/SharpRocksc.mat"' in content:
  70. print (tgt)'''
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. findTex('E:/4.0.0/art/Textures/Environment/Woods/Courtyard/Cliff_01.png', 'tgt')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement