Added subfolder support to importantFiles and versionFiles

This commit is contained in:
jonpas
2015-08-25 20:28:33 +02:00
parent 21aa4da4ad
commit e512a3675a

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# vim: set fileencoding=utf-8 : # vim: set fileencoding=utf-8 :
# make.py # make.py
@ -73,8 +73,8 @@ dssignfile = ""
prefix = "ace" prefix = "ace"
pbo_name_prefix = "ace_" pbo_name_prefix = "ace_"
signature_blacklist = ["ace_server.pbo"] signature_blacklist = ["ace_server.pbo"]
importantFiles = ["mod.cpp", "README.md", "AUTHORS.txt", "LICENSE", "logo_ace3_ca.paa"] importantFiles = ["mod.cpp", "README.md", "documentation\\README_DE.md", "documentation\\README_PL.md", "AUTHORS.txt", "LICENSE", "logo_ace3_ca.paa"]
versionFiles = ["README.md", "mod.cpp"] versionFiles = ["README.md", "documentation\\README_DE.md", "documentation\\README_PL.md", "mod.cpp"]
############################################################################### ###############################################################################
# http://akiscode.com/articles/sha-1directoryhash.shtml # http://akiscode.com/articles/sha-1directoryhash.shtml
@ -331,15 +331,20 @@ def copy_important_files(source_dir,destination_dir):
originalDir = os.getcwd() originalDir = os.getcwd()
#copy importantFiles # Copy importantFiles
try: try:
print_blue("\nSearching for important files in {}".format(source_dir)) print_blue("\nSearching for important files in {}".format(source_dir))
print("Source_dir: {}".format(source_dir)) print("Source_dir: {}".format(source_dir))
print("Destination_dir: {}".format(destination_dir)) print("Destination_dir: {}".format(destination_dir))
for file in importantFiles: for file in importantFiles:
filePath = os.path.join(module_root_parent, file)
# Take only file name for destination path (to put it into root of release dir)
if "\\" in file:
count = file.count("\\")
file = file.split("\\", count)[-1]
print_green("Copying file => {}".format(os.path.join(source_dir,file))) print_green("Copying file => {}".format(os.path.join(source_dir,file)))
shutil.copyfile(os.path.join(source_dir,file),os.path.join(destination_dir,file)) shutil.copyfile(os.path.join(source_dir,filePath),os.path.join(destination_dir,file))
except: except:
print_error("COPYING IMPORTANT FILES.") print_error("COPYING IMPORTANT FILES.")
raise raise
@ -664,6 +669,10 @@ def stash_version_files_for_building():
try: try:
for file in versionFiles: for file in versionFiles:
filePath = os.path.join(module_root_parent, file) filePath = os.path.join(module_root_parent, file)
# Take only file name for stash location if in subfolder (otherwise it gets removed when removing folders from release dir)
if "\\" in file:
count = file.count("\\")
file = file.split("\\", count)[-1]
stashPath = os.path.join(release_dir, file) stashPath = os.path.join(release_dir, file)
print("Temporarily stashing {} => {}.bak for version update".format(filePath, stashPath)) print("Temporarily stashing {} => {}.bak for version update".format(filePath, stashPath))
shutil.copy(filePath, "{}.bak".format(stashPath)) shutil.copy(filePath, "{}.bak".format(stashPath))
@ -680,6 +689,10 @@ def restore_version_files():
try: try:
for file in versionFiles: for file in versionFiles:
filePath = os.path.join(module_root_parent, file) filePath = os.path.join(module_root_parent, file)
# Take only file name for stash path if in subfolder (otherwise it gets removed when removing folders from release dir)
if "\\" in file:
count = file.count("\\")
file = file.split("\\", count)[-1]
stashPath = os.path.join(release_dir, file) stashPath = os.path.join(release_dir, file)
print("Restoring {}".format(filePath)) print("Restoring {}".format(filePath))
shutil.move("{}.bak".format(stashPath), filePath) shutil.move("{}.bak".format(stashPath), filePath)