hf_extractor / display_utils.py
dwb2023's picture
Create display_utils.py
065e16a verified
raw
history blame
1.03 kB
def format_output(extracted_content, repo_url):
formatted_output = f"# Repository URL: {repo_url}\n\n"
for file_data in extracted_content:
if isinstance(file_data, dict) and 'header' in file_data:
formatted_output += f"### File: {file_data['header']['name']}\n"
formatted_output += f"**Type:** {file_data['header']['type']}\n"
formatted_output += f"**Size:** {file_data['header']['size']} bytes\n"
formatted_output += f"**Created:** {file_data['header']['creation_date']}\n"
formatted_output += f"**Modified:** {file_data['header']['modification_date']}\n"
formatted_output += "#### Content:\n"
formatted_output += f"```\n{file_data['content']}\n```\n\n"
if file_data["summary"]:
formatted_output += "#### Summary:\n"
formatted_output += f"```\n{file_data['summary']}\n```\n\n"
else:
formatted_output += "Error in file data format.\n"
return formatted_output