Skip to content

Commit ffdf780

Browse files
committed
Fix typos and structure of CRAN class
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent e153a40 commit ffdf780

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/fetchcode/cran.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@
2020

2121

2222
class Cran:
23-
def get_download_url(purl: str):
23+
"""
24+
This class handles CRAN PURLs.
25+
"""
26+
27+
purl_pattern = "pkg:cran/.*"
28+
base_url = "https://cran.r-project.org"
29+
30+
@classmethod
31+
def get_download_url(cls, purl: str):
2432
"""
2533
Resolve a CRAN PURL to a verified, downloadable source tarball URL.
2634
Tries current contrib first, then Archive.
@@ -29,13 +37,11 @@ def get_download_url(purl: str):
2937
if not p.name or not p.version:
3038
return None
3139

32-
current_url = f"https://cran.r-project.org/src/contrib/{p.name}_{p.version}.tar.gz"
40+
current_url = f"{cls.base_url}/src/contrib/{p.name}_{p.version}.tar.gz"
3341
if _http_exists(current_url):
3442
return current_url
3543

36-
archive_url = (
37-
f"https://cran.r-project.org/src/contrib/Archive/{p.name}/{p.name}_{p.version}.tar.gz"
38-
)
44+
archive_url = f"{cls.base_url}/src/contrib/Archive/{p.name}/{p.name}_{p.version}.tar.gz"
3945
if _http_exists(archive_url):
4046
return archive_url
4147

0 commit comments

Comments
 (0)