@@ -78,12 +78,6 @@ class VersionPathPair(NamedTuple):
7878 path : Path
7979
8080
81- def _removeprefix (s : str , prefix : str ) -> str :
82- if s .startswith (prefix ):
83- return s [len (prefix ) :]
84- return s
85-
86-
8781LATEST_README_URL = "https://ftp.ebi.ac.uk/pub/databases/chembl/ChEMBLdb/latest/README"
8882
8983
@@ -99,7 +93,10 @@ def latest() -> str:
9993 for line in res .iter_lines (decode_unicode = True ):
10094 line = line .decode ("utf8" )
10195 if line .startswith (RELEASE_PREFIX ):
102- return _removeprefix (_removeprefix (line , RELEASE_PREFIX ).strip (), "chembl_" )
96+ line = line .removeprefix (RELEASE_PREFIX )
97+ line = line .strip ()
98+ line = line .removeprefix ("chembl_" )
99+ return line
103100 raise ValueError ("could not find latest ChEMBL version" )
104101
105102
@@ -912,14 +909,15 @@ def download_readme(
912909 )
913910
914911
915- def get_date (version : str , ** kwargs : Any ) -> str :
912+ def get_date (version : VersionHint | None = None , ** kwargs : Any ) -> str :
916913 """Get the date of a given version."""
917914 path = download_readme (version = version , return_version = False , ** kwargs )
918915 try :
919- date_p = _removeprefix (
920- next (line for line in path .read_text ().splitlines () if line .startswith ("* Date:" )),
921- DATE_PREFIX ,
922- ).lstrip ()
916+ date_p = next (
917+ line for line in path .read_text ().splitlines () if line .startswith (DATE_PREFIX )
918+ )
919+ date_p = date_p .removeprefix (DATE_PREFIX )
920+ date_p = date_p .lstrip ()
923921 except StopIteration :
924922 return "" # happens on 22.1 and 24.1
925923 else :
0 commit comments