39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
import os
|
|
from typing import List
|
|
|
|
def succesfullBuilds_to_string(succesfullBuilds: List[str]):
|
|
return ", ".join(succesfullBuilds)
|
|
|
|
def array_to_string(arr):
|
|
if not arr:
|
|
return ''
|
|
|
|
arr = [str(item) for item in arr]
|
|
|
|
if len(arr) == 1:
|
|
return arr[0]
|
|
if len(arr) == 2:
|
|
return f"{arr[0]} and {arr[1]}"
|
|
|
|
return f"{', '.join(arr[:-1])}, and {arr[-1]}"
|
|
|
|
def read_last_lines(file_path, num_lines=10):
|
|
if os.path.exists(file_path):
|
|
with open(file_path, 'r') as file:
|
|
lines = file.readlines()[-num_lines:] # Get the last `num_lines` lines
|
|
return "\n".join([line.strip() + "\n" for line in lines])
|
|
else:
|
|
return None
|
|
|
|
def format_objects_to_markdown(objects):
|
|
markdown_output = ""
|
|
for obj in objects:
|
|
directory = obj.get("directory", "Unknown Object")
|
|
error_log = obj.get("errorLog", "No error log available")
|
|
|
|
markdown_output += f"\n# {directory}\n\n"
|
|
markdown_output += "Error Output:\n"
|
|
markdown_output += f"```\n{array_to_string(error_log).replace(',', '')}\n```\n\n"
|
|
|
|
return markdown_output
|