mirror of
https://github.com/karma-riuk/crab.git
synced 2025-07-05 05:28:13 +02:00
now removing from output also the list of
unapproved licenses
This commit is contained in:
@ -136,12 +136,19 @@ def remove_dir(dir: str) -> None:
|
|||||||
if os.listdir(parent) == []:
|
if os.listdir(parent) == []:
|
||||||
shutil.rmtree(parent)
|
shutil.rmtree(parent)
|
||||||
|
|
||||||
def clean_output(output: bytes) -> str:
|
def merge_download_lines(lines: list) -> list:
|
||||||
output_lines = output.decode().split("\n")
|
"""
|
||||||
cleaned_lines = []
|
Merges lines that are part of the same download block in Maven output.
|
||||||
downloading_block = False
|
|
||||||
|
|
||||||
for line in output_lines:
|
Args:
|
||||||
|
lines (list): The lines to merge.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list: The merged lines.
|
||||||
|
"""
|
||||||
|
downloading_block = False
|
||||||
|
cleaned_lines = []
|
||||||
|
for line in lines:
|
||||||
if re.match(r"\[INFO\] Download(ing|ed) from", line):
|
if re.match(r"\[INFO\] Download(ing|ed) from", line):
|
||||||
if not downloading_block:
|
if not downloading_block:
|
||||||
cleaned_lines.append("[CRAB] Downloading stuff")
|
cleaned_lines.append("[CRAB] Downloading stuff")
|
||||||
@ -149,6 +156,37 @@ def clean_output(output: bytes) -> str:
|
|||||||
else:
|
else:
|
||||||
cleaned_lines.append(line)
|
cleaned_lines.append(line)
|
||||||
downloading_block = False
|
downloading_block = False
|
||||||
|
return cleaned_lines
|
||||||
|
|
||||||
|
def merge_unapproved_licences(lines: list) -> list:
|
||||||
|
"""
|
||||||
|
Merges lines that are part of the same unapproved licences block in Maven output.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
lines (list): The lines to merge.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list: The merged lines.
|
||||||
|
"""
|
||||||
|
licenses_block = False
|
||||||
|
cleaned_lines = []
|
||||||
|
for line in lines:
|
||||||
|
if re.match(r"\[WARNING\] Files with unapproved licenses:", line):
|
||||||
|
cleaned_lines.append(line)
|
||||||
|
cleaned_lines.append("[CRAB] List of all the unapproved licenses...")
|
||||||
|
licenses_block = True
|
||||||
|
elif licenses_block and not re.match(r"\s+\?\/\.m2\/repository", line):
|
||||||
|
licenses_block = False
|
||||||
|
|
||||||
|
if not licenses_block:
|
||||||
|
cleaned_lines.append(line)
|
||||||
|
return cleaned_lines
|
||||||
|
|
||||||
|
def clean_output(output: bytes) -> str:
|
||||||
|
output_lines = output.decode().split("\n")
|
||||||
|
|
||||||
|
cleaned_lines = merge_download_lines(output_lines)
|
||||||
|
cleaned_lines = merge_unapproved_licences(cleaned_lines)
|
||||||
|
|
||||||
return "\n".join(cleaned_lines)
|
return "\n".join(cleaned_lines)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user