fix ruff checks (mostly documentation and dead code)
This commit is contained in:
@ -1,14 +1,23 @@
|
||||
"""Provides components to evaluate nix components and process the result."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Optional
|
||||
from flupdt.common import bash_wrapper
|
||||
import re
|
||||
|
||||
from flupdt.common import bash_wrapper
|
||||
|
||||
drv_re = re.compile(r".*(/nix/store/.*\.drv).*")
|
||||
|
||||
|
||||
def evaluate_output(path: str, output: str) -> Optional[str]:
|
||||
def evaluate_output(path: str, output: str) -> str | None:
|
||||
"""Evaluates a given output in a flake.
|
||||
|
||||
:param path: path to flake
|
||||
:param output: flake output to be evaluated
|
||||
:returns the .drv path on success or None on failure
|
||||
:raises RuntimeError: evaluation succeeds but no derivation is found
|
||||
"""
|
||||
logging.info(f"evaluating {output}")
|
||||
out = bash_wrapper(f"nix eval {path}#{output}")
|
||||
logging.debug(out[0])
|
||||
@ -17,10 +26,9 @@ def evaluate_output(path: str, output: str) -> Optional[str]:
|
||||
if out[2] != 0:
|
||||
logging.warning(f"output {output} did not evaluate correctly")
|
||||
return None
|
||||
else:
|
||||
drv_match = drv_re.match(out[0])
|
||||
if drv_match is None:
|
||||
out_msg = "derivation succeeded but output derivation does not contain a derivation"
|
||||
raise RuntimeError(out_msg)
|
||||
drv = drv_match.group(1)
|
||||
logging.debug(f"derivation evaluated to {drv}")
|
||||
drv_match = drv_re.match(out[0])
|
||||
if drv_match is None:
|
||||
out_msg = "derivation succeeded but output derivation does not contain a derivation"
|
||||
raise RuntimeError(out_msg)
|
||||
drv = drv_match.group(1)
|
||||
logging.debug(f"derivation evaluated to {drv}")
|
||||
|
Reference in New Issue
Block a user