##// END OF EJS Templates
Merge branch 'rm-default-old-config'
Thomas Kluyver -
r4182:b1b1749b merge
parent child Browse files
Show More
@@ -16,6 +16,7 b' Utilities for path handling.'
16 16
17 17 import os
18 18 import sys
19 from hashlib import md5
19 20
20 21 import IPython
21 22 from IPython.utils import warn
@@ -402,6 +403,18 b' def target_update(target,deps,cmd):'
402 403 if target_outdated(target,deps):
403 404 system(cmd)
404 405
406 def filehash(path):
407 """Make an MD5 hash of a file, ignoring any differences in line
408 ending characters."""
409 with open(path, "rU") as f:
410 return md5(f.read()).hexdigest()
411
412 # If the config is unmodified from the default, we'll just delete it.
413 # These are consistent for 0.10.x, thankfully. We're not going to worry about
414 # older versions.
415 old_config_md5 = {'ipy_user_conf.py': 'fc108bedff4b9a00f91fa0a5999140d3',
416 'ipythonrc': '12a68954f3403eea2eec09dc8fe5a9b5'}
417
405 418 def check_for_old_config(ipython_dir=None):
406 419 """Check for old config files, and present a warning if they exist.
407 420
@@ -418,16 +431,26 b' def check_for_old_config(ipython_dir=None):'
418 431 for cfg in old_configs:
419 432 f = os.path.join(ipython_dir, cfg)
420 433 if os.path.exists(f):
421 warned = True
422 warn.warn("Found old IPython config file %r"%f)
434 if filehash(f) == old_config_md5.get(cfg, ''):
435 os.unlink(f)
436 else:
437 oldf = f+'.old'
438 i = 0
439 while os.path.exists(oldf):
440 oldf = f+'.old.%i'%i
441 i += 1
442 os.rename(f, oldf)
443 warn.warn("Renamed old IPython config file '%s' to '%s'." % (f, oldf))
444 warned = True
423 445
424 446 if warned:
425 warn.warn("""
426 The IPython configuration system has changed as of 0.11, and these files
427 will be ignored. See http://ipython.github.com/ipython-doc/dev/config for
428 details on the new config system. To start configuring IPython, do
429 `ipython profile create`, and edit `ipython_config.py` in
430 <ipython_dir>/profile_default, adding
431 `c.InteractiveShellApp.ignore_old_config=True`""")
447 warn.info("""
448 The IPython configuration system has changed as of 0.11, and these files will
449 be ignored. See http://ipython.github.com/ipython-doc/dev/config for details
450 of the new config system.
451 To start configuring IPython, do `ipython profile create`, and edit
452 `ipython_config.py` in <ipython_dir>/profile_default.
453 If you need to leave the old config files in place for an older version of
454 IPython, set `c.InteractiveShellApp.ignore_old_config=True` in the new config.""")
432 455
433 456
General Comments 0
You need to be logged in to leave comments. Login now