Pārlūkot izejas kodu

Initial release of mission merger

Kleinburger 7 gadi atpakaļ
vecāks
revīzija
702744def7
1 mainītis faili ar 39 papildinājumiem un 8 dzēšanām
  1. 39 8
      Util/Mission Merger/mission_merger.py

+ 39 - 8
Util/Mission Merger/mission_merger.py

@@ -1,24 +1,33 @@
 #This was written for the 501st Starsim unit in Arma3
 #For faster mission integration with mission scripts
 #Written by CC Klein copyright 2018 
+#Authors email: ethan.leas@gmail.com
 
 import os
 import subprocess
 from distutils.dir_util import *
+from distutils.file_util import *
+
+def isDir(dir):
+    return os.path.isdir(dir)
+
+def pathName(dir, rPath):
+    return os.path.join(dir, rPath)
+
+def listDir(dir):
+    return os.listdir(dir)	
+
 
 #Creating String values for Directory Structure
 dir = os.path.dirname(__file__)
-filename = os.path.join(dir, '../../Missions/')
+root_dir = pathName(dir, '../../')
+filename = pathName(dir, '../../Missions/')
 tmp_file = filename+"Temp/"
-script_files = os.path.join(dir, '../../Scripts/')
-mission_files = os.listdir(filename)
-pbo_tool_files = os.path.join(dir, '../../Util/Tools/')
+script_files = pathName(dir, '../../Scripts/')
+mission_files = listDir(filename)
+pbo_tool_files = pathName(dir, '../../Util/Tools/')
 pbo_tool = pbo_tool_files+"MakePbo.exe"
 
-#If temp dir exists delete then continue
-if os.path.isdir(tmp_file) == True:
-    remove_tree(tmp_file)
-
 #For each mission folder in mission_files copy them to
 #tmp dir then copy scripts into mission tmp dir	
 for name in mission_files:
@@ -30,4 +39,26 @@ for name in mission_files:
         copy_tree(src_dir, tmp_dir)
         copy_tree(script_files, tmp_dir)
         subprocess.call([pbo_tool, "-P",tmp_dir])
+
+#Get list of tmp dir after being populated		
+pbo_files = listDir(tmp_file)
+pbo_dir = root_dir+"Pbo Files/"
+
+#If pbo dir does not exist create it
+#else delete it then create it
+if isDir(pbo_dir) == False:
+    mkpath(pbo_dir)
+else:
+    remove_tree(pbo_dir)
+    mkpath(pbo_dir)
+	
+#For each listing in tmp dir filter out .pbo files for copy
+for name in pbo_files:
+    if name.endswith('.pbo') == True:
+        src_file = tmp_file+name
+        move_file(src_file, pbo_dir)
 		
+#Cleanup
+#If temp dir exists delete
+if isDir(tmp_file) == True:
+    remove_tree(tmp_file)