@@ -16,6 +16,8 @@ def main():
1616 "--version" , "-v" , required = True , type = str , help = "The new version to add"
1717 )
1818 args = parser .parse_args ()
19+ # drop the "v" prefix
20+ new_version_without_prefix = args .version [1 :]
1921
2022 # Setup path to switcher.json (relative to this script) and load it
2123 switcher_path = os .path .join (os .path .dirname (__file__ ), "_static" , "switcher.json" )
@@ -24,17 +26,16 @@ def main():
2426
2527 # first we get the version number of the previous version
2628 for i , version in enumerate (switcher ):
27- if version [ "version" ] == " latest" :
29+ if version . get ( "name" , "" ). startswith ( " latest") :
2830 latest_index = i
29- previous_version = re .search (
30- r"latest \(([v.\d]+)\)" , version ["name" ]
31- ).group (1 )
32- if previous_version == args .version :
33- print (f"Version { args .version } already is the latest version. Exiting." )
31+ previous_version = version ["version" ]
32+ if previous_version == new_version_without_prefix :
33+ print (f"Version { new_version_without_prefix } already is the latest version. Exiting." )
3434 return
3535
36- # now replace the name of this one with the new version
37- switcher [i ]["name" ] = f"latest ({ args .version } )"
36+ # now replace the name and version of this one with the new version
37+ switcher [i ]["name" ] = f"latest ({ new_version_without_prefix } )"
38+ switcher [i ]["version" ] = new_version_without_prefix
3839 break
3940 else :
4041 raise ValueError ("'latest' version not found in switcher.json" )
@@ -47,7 +48,7 @@ def main():
4748 else :
4849 previous_version_entry = {
4950 "version" : previous_version ,
50- "url" : f"https://python-visualization.github.io/folium/{ previous_version } /" ,
51+ "url" : f"https://python-visualization.github.io/folium/v { previous_version } /" ,
5152 }
5253 switcher .insert (latest_index + 1 , previous_version_entry )
5354
0 commit comments