##// END OF EJS Templates
refactor: Use pathlib in tools/
Martin Matějek -
Show More
@@ -7,28 +7,29 b' from __future__ import print_function'
7 7
8 8 import os
9 9 from glob import glob
10 from pathlib import Path
10 11 from subprocess import call
11 12 import sys
12 13
13 from toollib import (get_ipdir, pjoin, cd, execfile, sh, archive,
14 from toollib import (get_ipdir, cd, execfile, sh, archive,
14 15 archive_user, archive_dir)
15 16
16 17 # Get main ipython dir, this will raise if it doesn't pass some checks
17 18 ipdir = get_ipdir()
18 tooldir = pjoin(ipdir, 'tools')
19 distdir = pjoin(ipdir, 'dist')
19 tooldir = ipdir / 'tools'
20 distdir = ipdir / 'dist'
20 21
21 22 # Where I keep static backups of each release
22 ipbackupdir = os.path.expanduser('~/ipython/backup')
23 if not os.path.exists(ipbackupdir):
24 os.makedirs(ipbackupdir)
23 ipbackupdir = Path('~/ipython/backup').expanduser()
24 if not ipbackupdir.exists():
25 ipbackupdir.mkdir(parents=True, exist_ok=True)
25 26
26 27 # Start in main IPython dir
27 28 cd(ipdir)
28 29
29 30 # Load release info
30 31 version = None
31 execfile(pjoin('IPython','core','release.py'), globals())
32 execfile(Path('IPython','core','release.py'), globals())
32 33
33 34 # Build site addresses for file uploads
34 35 release_site = '%s/release/%s' % (archive, version)
@@ -5,8 +5,9 b''
5 5 import os
6 6 import sys
7 7
8 from pathlib import Path
9
8 10 # Useful shorthands
9 pjoin = os.path.join
10 11 cd = os.chdir
11 12
12 13 # Constants
@@ -34,13 +35,12 b' def get_ipdir():'
34 35 """Get IPython directory from command line, or assume it's the one above."""
35 36
36 37 # Initialize arguments and check location
37 ipdir = pjoin(os.path.dirname(__file__), os.pardir)
38
39 ipdir = os.path.abspath(ipdir)
38 ipdir = Path(__file__).parent / os.pardir
39 ipdir = ipdir.resolve()
40 40
41 41 cd(ipdir)
42 if not os.path.isdir('IPython') and os.path.isfile('setup.py'):
43 raise SystemExit('Invalid ipython directory: %s' % ipdir)
42 if not Path("IPython").is_dir() and Path("setup.py").is_file():
43 raise SystemExit("Invalid ipython directory: %s" % ipdir)
44 44 return ipdir
45 45
46 46 def execfile(fname, globs, locs=None):
General Comments 0
You need to be logged in to leave comments. Login now