From a847e6314c9cdd034ba1ded553e04dec8c90e66a Mon Sep 17 00:00:00 2001 From: Renata Ravanelli Date: Wed, 20 Mar 2024 13:47:28 -0300 Subject: [PATCH] util: Rename function - Rename parse_mount to find_mount_root. - Address other small changes Signed-off-by: Renata Ravanelli --- osbuild/util/parsing.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/osbuild/util/parsing.py b/osbuild/util/parsing.py index 1e51cba6..f8fb2768 100644 --- a/osbuild/util/parsing.py +++ b/osbuild/util/parsing.py @@ -35,18 +35,19 @@ def parse_size(s: str) -> Union[int, str]: raise TypeError(f"invalid size value: '{s}'") -def parse_mount(url: ParseResult, args: Dict) -> os.PathLike: +def find_mount_root(url: ParseResult, args: Dict) -> os.PathLike: """ Parses the mount URL to extract the root path. Parameters: - url (ParseResult): The ParseResult object obtained from urlparse. - - args (Dict): A dictionary containing arguments including mounts information. + - args (Dict):A dictionary containing arguments including mounts and + path information as passed by osbuild.api.arguments() """ name = url.netloc if name: root = args["mounts"].get(name, {}).get("path") - if not root: + if root is None: raise ValueError(f"Unknown mount '{name}'") else: root = args["paths"]["mounts"] @@ -60,7 +61,8 @@ def parse_input(url: ParseResult, args: Dict) -> os.PathLike: Parameters: - url (ParseResult): The ParseResult object obtained from urlparse. - - args (Dict): A dictionary containing arguments including mounts information. + - args (Dict): A dictionary containing arguments including mounts and + path information as passed by osbuild.api.arguments() """ name = url.netloc root = args["inputs"].get(name, {}).get("path") @@ -76,7 +78,8 @@ def parse_location(location: str, args: Dict) -> str: Parameters: - location (str): The location URL to be parsed. - - args (Dict): A dictionary containing arguments including tree and mount information. + - args (Dict): A dictionary containing arguments including mounts and + path information as passed by osbuild.api.arguments() """ url = urlparse(location) @@ -85,7 +88,7 @@ def parse_location(location: str, args: Dict) -> str: if scheme == "tree": root = args["tree"] elif scheme == "mount": - root = parse_mount(url, args) + root = find_mount_root(url, args) elif scheme == "input": root = parse_input(url, args) else: