Use os.path more

Add Enemizer note
This commit is contained in:
Mike A. Trethewey
2020-03-28 19:03:08 -07:00
parent 6c484745a2
commit 599985e4b1
16 changed files with 59 additions and 35 deletions

View File

@@ -40,6 +40,7 @@
"made.rom": "Patched ROM: %s",
"made.playthrough": "Printed Playthrough: %s",
"made.spoiler": "Printed Spoiler: %s",
"used.enemizer": "Enemized: %s",
"done": "Done. Enjoy.",
"total.time": "Total Time: %s",
"finished.run": "Finished run",

View File

@@ -23,7 +23,7 @@ def prepare_env():
# get app version
APP_VERSION = ""
APP_VERSION_FILE = "./resources/app/meta/manifests/app_version.txt"
APP_VERSION_FILE = os.path.join(".","resources","app","meta","manifests","app_version.txt")
if os.path.isfile(APP_VERSION_FILE):
with open(APP_VERSION_FILE,"r") as f:
APP_VERSION = f.readlines()[0].strip()

View File

@@ -6,7 +6,7 @@ from shutil import unpack_archive
# only do stuff if we don't have a UPX folder
if not os.path.isdir("./upx"):
if not os.path.isdir(os.path.join(".","upx")):
# get env vars
env = common.prepare_env()
# set up download url
@@ -25,7 +25,7 @@ if not os.path.isdir("./upx"):
print("Getting UPX: " + UPX_FILE)
with open("./" + UPX_FILE,"wb") as upx:
with open(os.path.join(".",UPX_FILE),"wb") as upx:
UPX_REQ = urllib.request.Request(
UPX_URL,
data=None
@@ -34,9 +34,9 @@ if not os.path.isdir("./upx"):
UPX_DATA = UPX_REQ.read()
upx.write(UPX_DATA)
unpack_archive(UPX_FILE,"./")
unpack_archive(UPX_FILE,os.path.join("."))
os.rename("./" + UPX_SLUG,"./upx")
os.remove("./" + UPX_FILE)
os.rename(os.path.join(".",UPX_SLUG),os.path.join(".","upx"))
os.remove(os.path.join(".",UPX_FILE))
print("UPX should " + ("not " if not os.path.isdir("./upx") else "") + "be available.")
print("UPX should " + ("not " if not os.path.isdir(os.path.join(".","upx")) else "") + "be available.")

View File

@@ -1,20 +1,28 @@
import subprocess # do stuff at the shell level
import os
def git_clean():
def git_clean(clean_ignored=True, clean_user=False):
excludes = [
".vscode", # vscode IDE files
".idea", # idea IDE files
"*.json", # keep JSON files for that one time I just nuked all that I was working on, oops
"*app*version.*", # keep appversion files
"EnemizerCLI" # keep EnemizerCLI
"EnemizerCLI" # keep EnemizerCLI files
]
if not clean_user:
excludes.append(os.path.join("resources","user*")) # keep user resources
excludes = ['--exclude={0}'.format(exclude) for exclude in excludes]
# d: directories, f: files, x: ignored files
switches = "df" + ("x" if clean_ignored else "")
# clean the git slate
subprocess.check_call([
"git", # run a git command
"clean", # clean command
"-dfx", # d: directories, f: files, x: ignored files
"-" + switches,
*excludes])
if __name__ == "__main__":

View File

@@ -0,0 +1,3 @@
from git_clean import git_clean
git_clean(clean_user=True)