Added walkMods, some slight adjustments

- walklevel's level now defaults to 0
- shortened os.path.join to p
This commit is contained in:
Fierelier 2019-10-25 11:36:26 +02:00
parent 671d8a2a5b
commit ebee8880f9
1 changed files with 23 additions and 15 deletions

View File

@ -26,6 +26,7 @@ import time
import stat
scriptPath = os.path.dirname(os.path.realpath(__file__))
p = os.path.join
appPath = False
appName = False
originalAppPath = False
@ -42,20 +43,27 @@ def testAccess(path):
except:
return False
def cloneMods(modDir):
for root,dirs,files in walklevel(modDir,0):
def walkMods(modDir):
for root,dirs,files in walklevel(modDir):
for dir in dirs:
if dir[0] == "-": continue
if dir[0] == "[" and dir[-1:] == "]":
cloneMods(os.path.join(root,dir))
else:
print("Applying Mod: " +dir)
if os.path.isfile(os.path.join(root,dir,"uml_installscript.py")) == True:
file = open(os.path.join(root,dir,"uml_installscript.py"))
exec(file.read(),globals(),locals())
file.close()
else:
cloneFolder(os.path.join(root,dir),tmpAppPath,True,False,True)
for mod in getMods(p(root,dir)): yield mod
continue
yield p(root,dir)
def cloneMods(modDir):
for mod in walkMods(modDir):
modName = mod.replace(os.path.dirname(mod) + os.sep,"")
print("Applying Mod: " +modName)
if os.path.isfile(p(mod,"uml_installscript.py")) == True:
file = open(p(mod,"uml_installscript.py"))
exec(file.read(),globals(),locals())
file.close()
else:
cloneFolder(mod,tmpAppPath,True,False,True)
def loadMods(output = False, fast = False):
if fast == False:
@ -173,8 +181,8 @@ def cloneFolder(src,dst,rpl,ignoreMods = True, isMod = False):
if isMod == True:
if file[:4] == "uml_": continue
fullFile = os.path.join(root,file)
newFile = os.path.join(newRoot,file)
fullFile = p(root,file)
newFile = p(newRoot,file)
if os.path.isfile(newFile):
if rpl == True:
@ -185,7 +193,7 @@ def cloneFolder(src,dst,rpl,ignoreMods = True, isMod = False):
print("")
def walklevel(some_dir, level=1):
def walklevel(some_dir, level=0):
some_dir = some_dir.rstrip(os.path.sep)
assert os.path.isdir(some_dir)
num_sep = some_dir.count(os.path.sep)
@ -327,7 +335,7 @@ def setupVariables():
appName = appPath.replace(os.path.dirname(appPath)+ os.sep,"")
originalAppPath = appPath + " - umlOriginal"
tmpAppPath = appPath + " - umlTemp"
modPath = os.path.join(appPath + " - umlMods")
modPath = p(appPath + " - umlMods")
originalModPath = modPath
def init():