White space and switch to .format() strings

This commit is contained in:
Ryan Jarvis 2018-06-28 15:05:18 -07:00 committed by Ani
parent 345f92ab0a
commit a545e23b00

View File

@ -1,11 +1,11 @@
import os
import re
import shutil
import xml.etree.ElementTree as ET
import re
RPCS3DIR = ""
cmake_dirs = ["CMakeFiles",]
cmake_dirs = ["CMakeFiles"]
cmake_files = ["INSTALL.vcxproj",
"INSTALL.vcxproj.filters",
@ -65,6 +65,7 @@ vcxproj_files = ["lib\Analysis\LLVMAnalysis.vcxproj",
"utils\TableGen\llvm-tblgen.vcxproj",
]
def get_parent_dir():
path = os.getcwd()
os.chdir("..")
@ -72,24 +73,27 @@ def get_parent_dir():
os.chdir(path)
return rpcs3_dir
def rem_cmake_files(root_path):
for root, dirs, files in os.walk(root_path):
for directory in dirs:
if directory in cmake_dirs:
print("deleting: " + os.path.join(root,directory))
print("deleting: {}".format(os.path.join(root, directory)))
shutil.rmtree(os.path.join(root, directory))
dirs = [item for item in dirs if item not in cmake_dirs]
for file in files:
if file in cmake_files:
print("deleting: " + os.path.join(root,file))
print("deleting: {}".format(os.path.join(root, file)))
os.remove(os.path.join(root, file))
def repl_cmake_copy(match):
newtext = "copy /y "
files = match.group(1)
files = files.replace('/', '\\')
return newtext + files
def make_paths_relative(file):
global vcxproj_files
global vcxproj_files_blacklist
@ -97,18 +101,18 @@ def make_paths_relative(file):
if this_vcxproj in vcxproj_files_blacklist:
return
if (file.find('.vcxproj') != len(file) - 8) and (file.find('.vcxproj.filters') != len(file) - 16):
print('ERROR: File "'+file+'" is not vcxproj file')
print('ERROR: File "{}" is not vcxproj file'.format(file))
return
proj_path = os.path.dirname(file)
if proj_path[1] != ':':
print('ERROR: Path "'+proj_path+'" is not in the Windows format')
print('ERROR: Path "{}" is not in the Windows format'.format(proj_path))
return
# check if we expected this project file
if file[-8:] == '.vcxproj':
if this_vcxproj in vcxproj_files:
vcxproj_files.remove(this_vcxproj)
else:
print('ERROR: unexpected vcxproj file: "' + this_vcxproj +'" please update the script')
print('ERROR: unexpected vcxproj file: "{}" please update the script'.format(this_vcxproj))
return
# open the file and text-replace the absolute paths
@ -135,8 +139,7 @@ def make_paths_relative(file):
rgx = re.compile(r'[^\r\n<>]+ml64.exe"?([^\r\n]*)')
text, num_rep2 = rgx.subn(r'"$(VCInstallDir)bin\x86_amd64\ml64.exe" \1', text)
num_rep += num_rep2
#if (text.find('cmake') != -1) or (text.find('python') != -1):
# parent.remove(element)
if num_rep > 0:
element.text = text
@ -152,13 +155,15 @@ def iterate_proj_file(root_path):
if file.find('.vcxproj') != -1:
make_paths_relative(os.path.join(root, file))
def main_func():
global RPCS3DIR
RPCS3DIR = get_parent_dir()
rem_cmake_files(os.getcwd())
iterate_proj_file(os.getcwd())
for a in vcxproj_files:
print('ERROR: project file was not found "'+ a + '"')
print('ERROR: project file was not found "{}"'.format(a))
if __name__ == "__main__":
main_func()