Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,9 +11,8 @@ def clone_repo(url, repo_dir):
|
|
| 11 |
return False, result.stderr
|
| 12 |
return True, None
|
| 13 |
|
| 14 |
-
def get_file_summary(file_path):
|
| 15 |
size = os.path.getsize(file_path)
|
| 16 |
-
file_type = "binary" if size > 1024 * 1024 else "text"
|
| 17 |
return {
|
| 18 |
"name": os.path.relpath(file_path),
|
| 19 |
"type": file_type,
|
|
@@ -53,10 +52,10 @@ def extract_repo_content(url):
|
|
| 53 |
file_types = validate_file_types(repo_dir)
|
| 54 |
extracted_content = []
|
| 55 |
for file_path, file_type in file_types.items():
|
| 56 |
-
file_summary = get_file_summary(file_path)
|
| 57 |
content = {"header": file_summary}
|
| 58 |
|
| 59 |
-
if file_type
|
| 60 |
try:
|
| 61 |
content["content"] = read_file_content(file_path)
|
| 62 |
except Exception as e:
|
|
|
|
| 11 |
return False, result.stderr
|
| 12 |
return True, None
|
| 13 |
|
| 14 |
+
def get_file_summary(file_path, file_type):
|
| 15 |
size = os.path.getsize(file_path)
|
|
|
|
| 16 |
return {
|
| 17 |
"name": os.path.relpath(file_path),
|
| 18 |
"type": file_type,
|
|
|
|
| 52 |
file_types = validate_file_types(repo_dir)
|
| 53 |
extracted_content = []
|
| 54 |
for file_path, file_type in file_types.items():
|
| 55 |
+
file_summary = get_file_summary(file_path, file_type)
|
| 56 |
content = {"header": file_summary}
|
| 57 |
|
| 58 |
+
if file_type in ["txt", "python", "markdown", "yaml", "json", "csv", "tsv", "xml", "html"] and file_summary["size"] <= 1024 * 1024:
|
| 59 |
try:
|
| 60 |
content["content"] = read_file_content(file_path)
|
| 61 |
except Exception as e:
|