nehajiya8 commited on
Commit
dcaecb3
·
verified ·
1 Parent(s): 4386571

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
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 'blob/main', 'blob/master', 'tree/main', 'tree/master' from path
38
- if path_parts[0] in ['blob', 'tree'] and len(path_parts) > 1:
39
- path_parts = path_parts[2:] # Skip both the 'blob'/'tree' and branch name
40
  path = '/'.join(path_parts)
41
  else:
42
  path = ''
43
 
44
  return owner, repo, path
45
  else:
46
- raise ValueError("Please provide a valid GitHub repository URL")
47
-
48
  except Exception as e:
49
- print(f"Error parsing URL: {str(e)}") # Debug log
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."""