Skip to content

Commit 8896814

Browse files
committed
fix minor bugs
1 parent 297b96e commit 8896814

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
project = "LeanDojo"
1414
copyright = "2023, LeanDojo Team"
1515
author = "Kaiyu Yang"
16-
release = "2.1.0"
16+
release = "2.1.1"
1717

1818
# -- General configuration ---------------------------------------------------
1919
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ exclude = [
1212

1313
[project]
1414
name = "lean-dojo"
15-
version = "2.1.0"
15+
version = "2.1.1"
1616
authors = [
1717
{ name="Kaiyu Yang", email="kaiyuy@meta.com" },
1818
]

src/lean_dojo/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
load_dotenv()
1616

17-
__version__ = "2.1.0"
17+
__version__ = "2.1.1"
1818

1919
logger.remove()
2020
if "VERBOSE" in os.environ or "DEBUG" in os.environ:

src/lean_dojo/data_extraction/lean.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -736,15 +736,23 @@ def _parse_lakefile_toml_dependencies(
736736

737737
def get_license(self) -> Optional[str]:
738738
"""Return the content of the ``LICENSE`` file."""
739-
assert "github.com" in self.url, f"Unsupported URL: {self.url}"
740-
url = self.url.replace("github.com", "raw.githubusercontent.com")
741-
license_url = f"{url}/{self.commit}/LICENSE"
742-
try:
743-
return read_url(license_url)
744-
except urllib.error.HTTPError: # type: ignore
745-
return None
739+
if self.repo_type == RepoType.GITHUB:
740+
assert "github.com" in self.url, f"Unsupported URL: {self.url}"
741+
url = self.url.replace("github.com", "raw.githubusercontent.com")
742+
license_url = f"{url}/{self.commit}/LICENSE"
743+
try:
744+
return read_url(license_url)
745+
except urllib.error.HTTPError: # type: ignore
746+
return None
747+
else:
748+
license_path = Path(self.repo.working_dir) / "LICENSE"
749+
if license_path.exists():
750+
return license_path.open("r").read()
751+
else:
752+
return None
746753

747754
def _get_config_url(self, filename: str) -> str:
755+
assert self.repo_type == RepoType.GITHUB
748756
assert "github.com" in self.url, f"Unsupported URL: {self.url}"
749757
url = self.url.replace("github.com", "raw.githubusercontent.com")
750758
return f"{url}/{self.commit}/{filename}"
@@ -767,13 +775,21 @@ def get_config(self, filename: str, num_retries: int = 2) -> Dict[str, Any]:
767775

768776
def uses_lakefile_lean(self) -> bool:
769777
"""Check if the repo uses a ``lakefile.lean``."""
770-
url = self._get_config_url("lakefile.lean")
771-
return url_exists(url)
778+
if self.repo_type == RepoType.GITHUB:
779+
url = self._get_config_url("lakefile.lean")
780+
return url_exists(url)
781+
else:
782+
lakefile_path = Path(self.repo.working_dir) / "lakefile.lean"
783+
return lakefile_path.exists()
772784

773785
def uses_lakefile_toml(self) -> bool:
774786
"""Check if the repo uses a ``lakefile.toml``."""
775-
url = self._get_config_url("lakefile.toml")
776-
return url_exists(url)
787+
if self.repo_type == RepoType.GITHUB:
788+
url = self._get_config_url("lakefile.toml")
789+
return url_exists(url)
790+
else:
791+
lakefile_path = Path(self.repo.working_dir) / "lakefile.toml"
792+
return lakefile_path.exists()
777793

778794

779795
@dataclass(frozen=True)

0 commit comments

Comments
 (0)