Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,23 +31,22 @@ def parse_github_url(url):
|
|
| 31 |
owner = parts[github_index + 1]
|
| 32 |
repo = parts[github_index + 2]
|
| 33 |
|
| 34 |
-
# Handle paths
|
| 35 |
path_parts = parts[github_index + 3:]
|
| 36 |
if len(path_parts) > 0:
|
| 37 |
-
# Remove '
|
| 38 |
-
if path_parts[0]
|
| 39 |
-
path_parts = path_parts[2:]
|
| 40 |
path = '/'.join(path_parts)
|
| 41 |
else:
|
| 42 |
path = ''
|
| 43 |
|
| 44 |
return owner, repo, path
|
| 45 |
else:
|
| 46 |
-
raise ValueError("
|
| 47 |
-
|
| 48 |
except Exception as e:
|
| 49 |
-
|
| 50 |
-
raise ValueError("Please provide a valid GitHub repository URL")
|
| 51 |
|
| 52 |
def download_directory(self, owner: str, repo: str, path: str, local_path: str) -> bool:
|
| 53 |
"""Download an entire directory recursively."""
|
|
|
|
| 31 |
owner = parts[github_index + 1]
|
| 32 |
repo = parts[github_index + 2]
|
| 33 |
|
| 34 |
+
# Handle folder paths
|
| 35 |
path_parts = parts[github_index + 3:]
|
| 36 |
if len(path_parts) > 0:
|
| 37 |
+
# Remove 'tree' and branch name from path if present
|
| 38 |
+
if path_parts[0] == 'tree' and len(path_parts) > 1:
|
| 39 |
+
path_parts = path_parts[2:]
|
| 40 |
path = '/'.join(path_parts)
|
| 41 |
else:
|
| 42 |
path = ''
|
| 43 |
|
| 44 |
return owner, repo, path
|
| 45 |
else:
|
| 46 |
+
raise ValueError("Invalid GitHub URL format")
|
| 47 |
+
|
| 48 |
except Exception as e:
|
| 49 |
+
raise ValueError(f"Error parsing GitHub URL: {str(e)}")
|
|
|
|
| 50 |
|
| 51 |
def download_directory(self, owner: str, repo: str, path: str, local_path: str) -> bool:
|
| 52 |
"""Download an entire directory recursively."""
|