Skip to content

Commit

Permalink
buildifier: adopt best practices for method args
Browse files Browse the repository at this point in the history
For some reason the linter recomends having a name argument, and also
making it explicit which are the required arguments to the methods
  • Loading branch information
manuelnaranjo committed Jul 17, 2024
1 parent 96bd80d commit 4aedba6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
1 change: 0 additions & 1 deletion internal/rpm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ filegroup(
def _rpm_impl(ctx):
if ctx.attr.urls:
downloaded_file_path = "downloaded"
download_path = ctx.path("rpm/" + downloaded_file_path)
download_info = ctx.download(
url = ctx.attr.urls,
output = "rpm/" + downloaded_file_path,
Expand Down
42 changes: 19 additions & 23 deletions internal/rpmtree.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,16 @@ _tar2files = rule(
toolchains = [BAZELDNF_TOOLCHAIN],
)

def rpmtree(**kwargs):
def rpmtree(name, **kwargs):
"""Creates a tar file from a list of rpm files."""
kwargs.pop("files", None)
basename = kwargs["name"]
kwargs.pop("name", None)
tarname = basename + ".tar"
tarname = name + ".tar"
_rpm2tar(
name = basename,
name = name,
out = tarname,
**kwargs
)

def tar2files(**kwargs):
def tar2files(name, files = None, **kwargs):
"""Extracts files from a tar file.
Args:
Expand All @@ -125,19 +122,18 @@ def tar2files(**kwargs):
If not provided, the function will fail.
**kwargs: Additional keyword arguments to be passed to the _tar2files function.
"""
files = kwargs["files"]
kwargs.pop("files", None)
basename = kwargs["name"]
kwargs.pop("name", None)
if files:
for k, v in files.items():
name = basename + k
files = []
for file in v:
files = files + [name + "/" + file]
_tar2files(
name = name,
prefix = k,
out = files,
**kwargs
)
if not files:
fail("files is a required attribute")

basename = name
for k, v in files.items():
name = basename + k
files = []
for file in v:
files.append(name + "/" + file)
_tar2files(
name = name,
prefix = k,
out = files,
**kwargs
)

0 comments on commit 4aedba6

Please sign in to comment.