opus.tweak = Munch() opus.tweak.apply = Munch() def _tweakApplyReg(tag,rtgName,rtgFile): opus.main.output("\n>> [" +tag+ "] applying tweaks: registry -> " +rtgName,1) opus.reg.mount(opus.wim.path(rtgFile)) for tweakRoot,tweaks,_ in opus.path.walklevel(pJoin(opus.path.tweaks,tag)): for tweak in tweaks: ftweak = os.path.join(tweakRoot,tweak) if not os.path.isfile(pJoin(ftweak,"reg",rtgName + ".REG")): continue opus.reg.imprt(pJoin(ftweak,"reg",rtgName + ".REG")) opus.reg.unmount() opus.tweak.apply.reg = _tweakApplyReg def _tweakApplyWim(tag): opus.main.output("\n>> [" +tag+ "] applying tweaks: wim",1) for tweakRoot,tweaks,_ in opus.path.walklevel(pJoin(opus.path.tweaks,tag)): for tweak in tweaks: ftweak = os.path.join(tweakRoot,tweak) if not os.path.isdir(pJoin(ftweak,"wim")): continue opus.main.output("> applying: " +tweak,1) for root,dirs,files in os.walk(pJoin(ftweak,"wim")): for dir in dirs: fdir = os.path.join(root,dir) nfdir = fdir.replace(pJoin(ftweak,"wim"),opus.wim.path()) if not os.path.isdir(nfdir): opus.main.output("creating directory: " +nfdir,2) os.makedirs(nfdir) for file in files: ffile = os.path.join(root,file) nffile = ffile.replace(pJoin(ftweak,"wim"),opus.wim.path()) opus.main.output("adding file: " +nffile,2) if os.path.isdir(nffile): os.remove(nffile) shutil.copyfile(ffile,nffile) opus.tweak.apply.wim = _tweakApplyWim def _tweakApplyIso(tag): opus.main.output("\n>> [" +tag+ "] applying tweaks: iso",1) for tweakRoot,tweaks,_ in opus.path.walklevel(pJoin(opus.path.tweaks,tag)): for tweak in tweaks: ftweak = os.path.join(tweakRoot,tweak) if not os.path.isdir(pJoin(ftweak,"iso")): continue opus.main.output("> applying: " +tweak,1) for root,dirs,files in os.walk(pJoin(ftweak,"iso")): for dir in dirs: fdir = os.path.join(root,dir) nfdir = fdir.replace(pJoin(ftweak,"iso"),opus.path.target) if not os.path.isdir(nfdir): opus.main.output("creating directory: " +nfdir,2) os.makedirs(nfdir) for file in files: ffile = os.path.join(root,file) nffile = ffile.replace(pJoin(ftweak,"iso"),opus.path.target) opus.main.output("adding file: " +nffile,2) if os.path.isdir(nffile): os.remove(nffile) shutil.copyfile(ffile,nffile) opus.tweak.apply.iso = _tweakApplyIso