mirror of
https://github.com/wentasah/ros2nix.git
synced 2025-06-09 15:52:23 +03:00
Don't generate extra empty lines in src expressions
This commit is contained in:
parent
e523ecb7f5
commit
f2893e44b9
1 changed files with 7 additions and 4 deletions
|
@ -213,6 +213,9 @@ def comma_separated(arg: str) -> list[str]:
|
||||||
return [i.strip() for i in arg.split(",")]
|
return [i.strip() for i in arg.split(",")]
|
||||||
|
|
||||||
|
|
||||||
|
def strip_empty_lines(text: str) -> str:
|
||||||
|
return os.linesep.join([s for s in text.splitlines() if s and not s.isspace()])
|
||||||
|
|
||||||
def ros2nix(args):
|
def ros2nix(args):
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
prog="ros2nix", formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
prog="ros2nix", formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
||||||
|
@ -440,23 +443,23 @@ def ros2nix(args):
|
||||||
sparse_checkout = f"sparseCheckout = [\"{prefix}\"];" if (prefix and args.use_package_git_hash) else ""
|
sparse_checkout = f"sparseCheckout = [\"{prefix}\"];" if (prefix and args.use_package_git_hash) else ""
|
||||||
if match is not None:
|
if match is not None:
|
||||||
kwargs["src_param"] = "fetchFromGitHub"
|
kwargs["src_param"] = "fetchFromGitHub"
|
||||||
kwargs["src_expr"] = dedent(f'''
|
kwargs["src_expr"] = strip_empty_lines(dedent(f'''
|
||||||
fetchFromGitHub {{
|
fetchFromGitHub {{
|
||||||
owner = "{match["owner"]}";
|
owner = "{match["owner"]}";
|
||||||
repo = "{match["repo"]}";
|
repo = "{match["repo"]}";
|
||||||
rev = "{info["rev"]}";
|
rev = "{info["rev"]}";
|
||||||
sha256 = "{info["sha256"]}";
|
sha256 = "{info["sha256"]}";
|
||||||
{sparse_checkout}
|
{sparse_checkout}
|
||||||
}}''').strip()
|
}}''')).strip()
|
||||||
else:
|
else:
|
||||||
kwargs["src_param"] = "fetchgit"
|
kwargs["src_param"] = "fetchgit"
|
||||||
kwargs["src_expr"] = dedent(f'''
|
kwargs["src_expr"] = strip_empty_lines(dedent(f'''
|
||||||
fetchgit {{
|
fetchgit {{
|
||||||
url = "{url}";
|
url = "{url}";
|
||||||
rev = "{info["rev"]}";
|
rev = "{info["rev"]}";
|
||||||
sha256 = "{info["sha256"]}";
|
sha256 = "{info["sha256"]}";
|
||||||
{sparse_checkout}
|
{sparse_checkout}
|
||||||
}}''').strip()
|
}}''')).strip()
|
||||||
|
|
||||||
if prefix:
|
if prefix:
|
||||||
# kwargs["src_expr"] = f'''let fullSrc = {kwargs["src_expr"]}; in "${{fullSrc}}/{prefix}"'''
|
# kwargs["src_expr"] = f'''let fullSrc = {kwargs["src_expr"]}; in "${{fullSrc}}/{prefix}"'''
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue