format python, add poetry shell
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
This commit is contained in:
		@@ -21,7 +21,7 @@ def configure_logger(level: str = "INFO") -> None:
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def bash_wrapper(command: str, path:str = '.') -> tuple[str, int]:
 | 
			
		||||
def bash_wrapper(command: str, path: str = ".") -> tuple[str, int]:
 | 
			
		||||
    """Execute a bash command and capture the output.
 | 
			
		||||
 | 
			
		||||
    Args:
 | 
			
		||||
@@ -33,7 +33,7 @@ def bash_wrapper(command: str, path:str = '.') -> tuple[str, int]:
 | 
			
		||||
        the error output (stderr) as a string (optional), and the return code as an integer.
 | 
			
		||||
    """
 | 
			
		||||
    # This is a acceptable risk
 | 
			
		||||
    process = Popen(command.split(), stdout=PIPE, stderr=PIPE,cwd = path)  # noqa: S603
 | 
			
		||||
    process = Popen(command.split(), stdout=PIPE, stderr=PIPE, cwd=path)  # noqa: S603
 | 
			
		||||
    output, _ = process.communicate()
 | 
			
		||||
 | 
			
		||||
    return output.decode(), process.returncode
 | 
			
		||||
 
 | 
			
		||||
@@ -4,24 +4,29 @@ import json
 | 
			
		||||
from app.common import bash_wrapper
 | 
			
		||||
import shutil
 | 
			
		||||
 | 
			
		||||
def traverse_json_base(json_dict:dict ,path: list[str]):
 | 
			
		||||
 | 
			
		||||
def traverse_json_base(json_dict: dict, path: list[str]):
 | 
			
		||||
    final_paths = []
 | 
			
		||||
    for (key,value) in json_dict.items():
 | 
			
		||||
        if isinstance(value,dict):
 | 
			
		||||
    for key, value in json_dict.items():
 | 
			
		||||
        if isinstance(value, dict):
 | 
			
		||||
            keys = value.keys()
 | 
			
		||||
            if 'type' in keys and value['type'] in ['nixos-configuration','derivation']:
 | 
			
		||||
                final_paths += ['.'.join(path + [key])]
 | 
			
		||||
            if "type" in keys and value["type"] in [
 | 
			
		||||
                "nixos-configuration",
 | 
			
		||||
                "derivation",
 | 
			
		||||
            ]:
 | 
			
		||||
                final_paths += [".".join(path + [key])]
 | 
			
		||||
            else:
 | 
			
		||||
                final_paths += traverse_json_base(value,path+[key])
 | 
			
		||||
                final_paths += traverse_json_base(value, path + [key])
 | 
			
		||||
    return final_paths
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def traverse_json(json_dict: dict):
 | 
			
		||||
    return traverse_json_base(json_dict,[])
 | 
			
		||||
    return traverse_json_base(json_dict, [])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_derivations(path_to_flake: str):
 | 
			
		||||
    nix_path = shutil.which("nix")
 | 
			
		||||
    flake_show = bash_wrapper(f"{nix_path} flake show --json", path = path_to_flake)
 | 
			
		||||
    flake_show = bash_wrapper(f"{nix_path} flake show --json", path=path_to_flake)
 | 
			
		||||
    if flake_show[1] != 0:
 | 
			
		||||
        raise RuntimeError("flake show returned non-zero exit code")
 | 
			
		||||
    flake_show_json = json.loads(flake_show[0])
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user