2525 pathlib .Path ('antlr-3.3-complete.jar' )),
2626 'Open Fortran Parser 0.8.4-2' : (
2727 urllib .parse .urlparse (
28- 'https://github.com/mbdevpl/open-fortran-parser/releases/download/v0.8.4-2/' ),
29- pathlib .Path ('OpenFortranParser-0.8.4-2.jar' )),
28+ # 'https://github.com/mbdevpl/open-fortran-parser/releases/download/v0.8.4-2/'),
29+ 'https://dl.bintray.com/mbdevpl/pkgs/open-fortran-parser-v0.8.5.dev4+8f933cfc/linux-openjdk7/' ),
30+ pathlib .Path ('OpenFortranParser-0.8.4-3.jar' )),
3031 'Apache Commons CLI 1.4' : (
3132 urllib .parse .urlparse (
3233 'https://github.com/mbdevpl/open-fortran-parser-xml/releases/download/v0.1.0/' ),
4546
4647DEPENDENCIES_PATH = pathlib .Path (__file__ ).resolve ().parent
4748
48- OUTDATED_DEPENDENCIES = {
49- 'Open Fortran Parser 0.8.4-1' : pathlib .Path ('OpenFortranParser-0.8.4-2.jar' )}
50-
5149
5250def ensure_dependencies (
5351 dependencies : t .Mapping [str , t .Tuple [urllib .parse .ParseResult , pathlib .Path ]],
@@ -73,5 +71,27 @@ def ensure_dependencies(
7371 if platform .system () != 'Windows' :
7472 _LOG .warning ('export CLASSPATH="${CLASSPATH}:%s"' , classpath )
7573
76- if __name__ == '__main__' :
77- ensure_dependencies (DEPENDENCIES , DEPENDENCIES_PATH )
74+
75+ OUTDATED_DEPENDENCIES = {
76+ 'Open Fortran Parser 0.8.4-1' : pathlib .Path ('OpenFortranParser-0.8.4-1.jar' ),
77+ 'Open Fortran Parser 0.8.4-2' : pathlib .Path ('OpenFortranParser-0.8.4-2.jar' )}
78+
79+
80+ def cleanup_old_dependencies (
81+ outdated_dependencies , current_dir : pathlib .Path ,
82+ backup_dir : t .Optional [pathlib .Path ] = None ):
83+ if backup_dir is not None and not backup_dir .exists ():
84+ _LOG .warning ('Creating directory "%s"...' , backup_dir )
85+ os .makedirs (str (backup_dir ), exist_ok = True )
86+ for dependency , filename in outdated_dependencies .items ():
87+ path = current_dir .joinpath (filename )
88+ if not path .is_file ():
89+ _LOG .debug ('%s already does not exist.' , dependency )
90+ continue
91+ if backup_dir is None :
92+ _LOG .warning ('Deleting %s in path "%s"...' , dependency , current_dir )
93+ path .unlink ()
94+ else :
95+ _LOG .warning ('Moving %s from path "%s" to path "%s"...' ,
96+ dependency , current_dir , backup_dir )
97+ path .move ()
0 commit comments