1- """This script takes a version string as a commandline argument and updates
1+ """Python 2 version
2+
3+ This script takes a version string as a commandline argument and updates
24the links in `docs/{version}` that point to code in the `master` branch of
35FCP-INDI/C-PAC to code in the tagged version.
46
1012import os
1113import sys
1214
13- from glob import glob
15+ from fnmatch import filter as fnfilter
16+
17+
18+ def glob (pattern , recursive = True ):
19+ split_pattern = pattern .split ('/' )
20+ filepath = '/' .join (split_pattern [0 :- 1 ])
21+ pattern = split_pattern [- 1 ]
22+ del split_pattern
23+
24+ matches = []
25+ for root , dirnames , filenames in os .walk (filepath ):
26+ for filename in fnfilter (filenames , pattern ):
27+ matches .append (os .path .join (root , filename ))
28+ return matches
1429
1530
1631def set_version (version ):
@@ -25,9 +40,9 @@ def set_version(version):
2540 # Replace links to master branch with links to specified branch
2641 with open (filepath , 'r' ) as openfile :
2742 file = openfile .read ().replace (
28- patterns [0 ], f 'FCP-INDI/C-PAC/blob/{ version } '
43+ patterns [0 ], 'FCP-INDI/C-PAC/blob/{}' . format ( version )
2944 ).replace (
30- patterns [1 ], f 'FCP-INDI/C-PAC/{ version } '
45+ patterns [1 ], 'FCP-INDI/C-PAC/{}' . format ( version )
3146 )
3247 with open (filepath , 'w' ) as openfile :
3348 openfile .write (file )
0 commit comments