Manual fixes to Python file
To see if I like the rules
This commit is contained in:
parent
34b545890d
commit
8179433c41
10 changed files with 612 additions and 547 deletions
|
@ -1,3 +1,8 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 --pure
|
||||
#! nix-shell -p python3 python3Packages.colorspacious python3Packages.numpy
|
||||
# vim: filetype=python
|
||||
|
||||
import argparse
|
||||
import json
|
||||
|
||||
|
@ -90,14 +95,14 @@ if args.polarity == "light":
|
|||
frogarized_rgb = np.vstack([frogarized_rgb[7::-1], frogarized_rgb[8:]])
|
||||
|
||||
# Output
|
||||
palette = dict()
|
||||
palette = {}
|
||||
for i in range(16):
|
||||
rgb = frogarized_rgb[i]
|
||||
r, g, b = rgb
|
||||
hex = f"#{r:02x}{g:02x}{b:02x}"
|
||||
palette[f"base{i:02X}"] = hex
|
||||
hexa = f"#{r:02x}{g:02x}{b:02x}"
|
||||
palette[f"base{i:02X}"] = hexa
|
||||
if args.output == "truecolor":
|
||||
print(f"\033[48;2;{r};{g};{b}m{hex}\033[0m") # ]]
|
||||
print(f"\033[48;2;{r};{g};{b}m{hexa}\033[0m") # ]]
|
||||
# treesitter is silly and will consider brackets in strings
|
||||
# as indentation, hence the comment above
|
||||
if args.output == "json":
|
||||
|
|
28
common/update-local-flakes/update-local-flakes.py
Executable file → Normal file
28
common/update-local-flakes/update-local-flakes.py
Executable file → Normal file
|
@ -1,6 +1,6 @@
|
|||
import argparse
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
|
||||
GET_INPUTS_CMD = [
|
||||
|
@ -12,28 +12,26 @@ GET_INPUTS_CMD = [
|
|||
]
|
||||
|
||||
|
||||
def process_flake(flakeUri: str) -> None:
|
||||
def process_flake(flake_uri: pathlib.Path) -> None:
|
||||
# get full path
|
||||
flakeUri = os.path.normpath(flakeUri)
|
||||
flakeFile = os.path.join(flakeUri, "flake.nix")
|
||||
if not os.path.isfile(flakeFile):
|
||||
raise FileNotFoundError(f"Flake not found: {flakeUri}")
|
||||
flake_file = flake_uri / "flake.nix"
|
||||
if not flake_file.is_file():
|
||||
msg = f"Flake not found: {flake_uri}"
|
||||
raise FileNotFoundError(msg)
|
||||
# import dependencies
|
||||
p = subprocess.run(GET_INPUTS_CMD, cwd=flakeUri, stdout=subprocess.PIPE, check=True)
|
||||
p = subprocess.run(
|
||||
GET_INPUTS_CMD, cwd=flake_uri, stdout=subprocess.PIPE, check=True
|
||||
)
|
||||
deps = json.loads(p.stdout)
|
||||
# for each dependency
|
||||
for dep_name, dep in deps.items():
|
||||
dep_url = dep["url"]
|
||||
# if not local path, continue
|
||||
if not (
|
||||
dep_url.startswith("path:") or dep_url.startswith("git+file:")
|
||||
):
|
||||
if not dep_url.startswith(("path:", "git+file:")):
|
||||
continue
|
||||
if dep.get("flake", True):
|
||||
# get flake file corresponding
|
||||
dep_path = dep_url.split(":")[1]
|
||||
if not dep_path.startswith("/"):
|
||||
dep_path = os.path.join(flakeUri, dep_path)
|
||||
dep_path = pathlib.Path(flake_uri, dep_url.split(":")[1])
|
||||
process_flake(dep_path)
|
||||
# update lockfile
|
||||
cmd = [
|
||||
|
@ -46,7 +44,7 @@ def process_flake(flakeUri: str) -> None:
|
|||
"update",
|
||||
dep_name,
|
||||
]
|
||||
p = subprocess.run(cmd, cwd=flakeUri, check=True)
|
||||
p = subprocess.run(cmd, cwd=flake_uri, check=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -54,6 +52,6 @@ if __name__ == "__main__":
|
|||
description="Recursively update lockfiles "
|
||||
"of flakes located on the system"
|
||||
)
|
||||
parser.add_argument("flake", help="Starting flake", default="/")
|
||||
parser.add_argument("flake", help="Starting flake", type=pathlib.Path)
|
||||
args = parser.parse_args()
|
||||
process_flake(args.flake)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue