|
41 | 41 | from typing_extensions import Literal |
42 | 42 |
|
43 | 43 |
|
44 | | -REMOTE_FILEPATH_REGEX = re.compile(r"^\w[\w\/]*(\.\w+)?$") |
| 44 | +REMOTE_FILEPATH_REGEX = re.compile(r"^\w[\w\/\-]*(\.\w+)?$") |
45 | 45 | # ^^ No trailing slash, no backslash, no spaces, no relative parts ("." or "..") |
46 | 46 | # Only word characters and an optional extension |
47 | 47 |
|
@@ -590,13 +590,24 @@ def list_repo_files( |
590 | 590 | self, |
591 | 591 | repo_id: str, |
592 | 592 | revision: Optional[str] = None, |
| 593 | + repo_type: Optional[str] = None, |
593 | 594 | token: Optional[str] = None, |
594 | 595 | timeout: Optional[float] = None, |
595 | | - ) -> ModelInfo: |
| 596 | + ) -> List[str]: |
596 | 597 | """ |
597 | 598 | Get the list of files in a given repo. |
598 | 599 | """ |
599 | | - info = self.model_info(repo_id, revision=revision, token=token, timeout=timeout) |
| 600 | + if repo_type is None: |
| 601 | + info = self.model_info( |
| 602 | + repo_id, revision=revision, token=token, timeout=timeout |
| 603 | + ) |
| 604 | + elif repo_type == "dataset": |
| 605 | + info = self.dataset_info( |
| 606 | + repo_id, revision=revision, token=token, timeout=timeout |
| 607 | + ) |
| 608 | + else: |
| 609 | + raise ValueError("Spaces are not available yet.") |
| 610 | + |
600 | 611 | return [f.rfilename for f in info.siblings] |
601 | 612 |
|
602 | 613 | def list_repos_objs( |
|
0 commit comments