Coding style.
- pydoc expects scripts that do little when imported. So all python scripts really need 'if __name__ == "__main__":'
This commit is contained in:
parent
aea93874cc
commit
07a73e006c
3 changed files with 69 additions and 56 deletions
|
|
@ -20,11 +20,6 @@ The script should only be run from the root of the local eris repository.
|
|||
"""
|
||||
|
||||
|
||||
if len(sys.argv) != 4:
|
||||
print(USAGE)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def patch_manifest(manifest_path, patched_manifest_path):
|
||||
with open(manifest_path) as manifest_file:
|
||||
manifest = json.load(manifest_file)
|
||||
|
|
@ -34,12 +29,21 @@ def patch_manifest(manifest_path, patched_manifest_path):
|
|||
json.dump(manifest, patched_manifest_file, indent=2)
|
||||
|
||||
|
||||
manifest_path, build_dir, state_dir = sys.argv[1:4]
|
||||
patched_manifest_path = "manifests-cache/patched-manifest.json"
|
||||
patch_manifest(manifest_path, patched_manifest_path)
|
||||
subprocess.run(["flatpak-builder", build_dir, patched_manifest_path,
|
||||
"--force-clean", "--state-dir", state_dir, "--disable-updates"],
|
||||
check=True)
|
||||
subprocess.run(["flatpak", "build", build_dir, "test-all"], check=True)
|
||||
subprocess.run(["flatpak", "build", build_dir, "eris", "--help"], check=True)
|
||||
print("Build successful:", build_dir)
|
||||
def main(argv):
|
||||
if len(argv) != 4:
|
||||
print(USAGE)
|
||||
sys.exit(1)
|
||||
manifest_path, build_dir, state_dir = argv[1:4]
|
||||
patched_manifest_path = "manifests-cache/patched-manifest.json"
|
||||
patch_manifest(manifest_path, patched_manifest_path)
|
||||
subprocess.run(["flatpak-builder", build_dir, patched_manifest_path,
|
||||
"--force-clean", "--state-dir", state_dir,
|
||||
"--disable-updates"], check=True)
|
||||
subprocess.run(["flatpak", "build", build_dir, "test-all"], check=True)
|
||||
subprocess.run(["flatpak", "build", build_dir, "eris", "--help"],
|
||||
check=True)
|
||||
print("Build successful:", build_dir)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
||||
|
|
|
|||
|
|
@ -441,35 +441,39 @@ def make_combined_manifest(all_modules):
|
|||
SUBSTITUTIONS = {"shellcheck": "haskell/ShellCheck",
|
||||
"pandoc": "haskell/pandoc"}
|
||||
|
||||
|
||||
manifests_dir = os.path.join(os.getcwd(), "manifests-cache")
|
||||
os.makedirs(manifests_dir, exist_ok=True)
|
||||
deps = {SUBSTITUTIONS.get(dep, dep) for dep in eris.tools.dependencies()}
|
||||
all_modules = []
|
||||
for dep in sorted(deps - DEPS_IN_RUNTIME) + ["eris"]:
|
||||
build_func, package = get_build_func(dep)
|
||||
dep_name = os.path.basename(package)
|
||||
manifest_path = os.path.join(manifests_dir, dep_name+".json")
|
||||
print(f"Making manifest for {dep} …".ljust(70), end="", flush=True)
|
||||
if os.path.exists(manifest_path):
|
||||
print(" (cached)")
|
||||
with open(manifest_path) as json_file:
|
||||
modules = json.load(json_file)["modules"]
|
||||
def main():
|
||||
manifests_dir = os.path.join(os.getcwd(), "manifests-cache")
|
||||
os.makedirs(manifests_dir, exist_ok=True)
|
||||
deps = {SUBSTITUTIONS.get(dep, dep) for dep in eris.tools.dependencies()}
|
||||
all_modules = []
|
||||
for dep in sorted(deps - DEPS_IN_RUNTIME) + ["eris"]:
|
||||
build_func, package = get_build_func(dep)
|
||||
dep_name = os.path.basename(package)
|
||||
manifest_path = os.path.join(manifests_dir, dep_name+".json")
|
||||
print(f"Making manifest for {dep} …".ljust(70), end="", flush=True)
|
||||
if os.path.exists(manifest_path):
|
||||
print(" (cached)")
|
||||
with open(manifest_path) as json_file:
|
||||
modules = json.load(json_file)["modules"]
|
||||
all_modules.extend(modules)
|
||||
continue
|
||||
elif dep == "eris":
|
||||
modules = eris_modules()
|
||||
elif dep == "nodejs":
|
||||
modules = nodejs_modules()
|
||||
else:
|
||||
modules = build_func(package)
|
||||
print()
|
||||
all_modules.extend(modules)
|
||||
continue
|
||||
elif dep == "eris":
|
||||
modules = eris_modules()
|
||||
elif dep == "nodejs":
|
||||
modules = nodejs_modules()
|
||||
else:
|
||||
modules = build_func(package)
|
||||
save_manifest(make_manifest(modules, dep), manifest_path)
|
||||
eris_module = all_modules[-1]
|
||||
eris_module["sources"][0]["commit"] = get_latest_commit()
|
||||
manifest = make_combined_manifest(all_modules)
|
||||
manifest_path = "com.github.ahamilton.eris.json"
|
||||
print()
|
||||
all_modules.extend(modules)
|
||||
save_manifest(make_manifest(modules, dep), manifest_path)
|
||||
eris_module = all_modules[-1]
|
||||
eris_module["sources"][0]["commit"] = get_latest_commit()
|
||||
manifest = make_combined_manifest(all_modules)
|
||||
manifest_path = "com.github.ahamilton.eris.json"
|
||||
print()
|
||||
print(f"Saving manifest file: ./{manifest_path}")
|
||||
save_manifest(manifest, manifest_path)
|
||||
print(f"Saving manifest file: ./{manifest_path}")
|
||||
save_manifest(manifest, manifest_path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -13,15 +13,16 @@ def tool_markup(tool):
|
|||
return (tool.__name__ if url is None else f"[{tool.__name__}]({url})")
|
||||
|
||||
|
||||
all_tools = ([(["*"], tools.generic_tools() +
|
||||
[tools.git_blame, tools.git_log])] +
|
||||
tools.TOOLS_FOR_EXTENSIONS)
|
||||
tool_set = set()
|
||||
extension_set = set()
|
||||
for extensions, tools_ in all_tools:
|
||||
tool_set.update(tools_)
|
||||
extension_set.update(extensions)
|
||||
print(f"""\
|
||||
def main():
|
||||
all_tools = ([(["*"], tools.generic_tools() +
|
||||
[tools.git_blame, tools.git_log])] +
|
||||
tools.TOOLS_FOR_EXTENSIONS)
|
||||
tool_set = set()
|
||||
extension_set = set()
|
||||
for extensions, tools_ in all_tools:
|
||||
tool_set.update(tools_)
|
||||
extension_set.update(extensions)
|
||||
print(f"""\
|
||||
# Eris Codebase Monitor
|
||||
|
||||
### Summary
|
||||
|
|
@ -49,6 +50,10 @@ then to run:
|
|||
|
||||
Extensions({len(extension_set)-1}) | Tools({len(tool_set)})
|
||||
----------:| -----""")
|
||||
for extensions, tools_ in all_tools:
|
||||
print("%s | %s" % (" ".join("." + extension for extension in extensions),
|
||||
" • ".join(tool_markup(tool) for tool in tools_)))
|
||||
for extensions, tools_ in all_tools:
|
||||
print("%s | %s" % (" ".join("." + extension for extension in extensions),
|
||||
" • ".join(tool_markup(tool) for tool in tools_)))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue