Show More
@@ -16,6 +16,7 b' Utilities for path handling.' | |||||
16 |
|
16 | |||
17 | import os |
|
17 | import os | |
18 | import sys |
|
18 | import sys | |
|
19 | from hashlib import md5 | |||
19 |
|
20 | |||
20 | import IPython |
|
21 | import IPython | |
21 | from IPython.utils import warn |
|
22 | from IPython.utils import warn | |
@@ -402,6 +403,18 b' def target_update(target,deps,cmd):' | |||||
402 | if target_outdated(target,deps): |
|
403 | if target_outdated(target,deps): | |
403 | system(cmd) |
|
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 | def check_for_old_config(ipython_dir=None): |
|
418 | def check_for_old_config(ipython_dir=None): | |
406 | """Check for old config files, and present a warning if they exist. |
|
419 | """Check for old config files, and present a warning if they exist. | |
407 |
|
420 | |||
@@ -418,8 +431,12 b' def check_for_old_config(ipython_dir=None):' | |||||
418 | for cfg in old_configs: |
|
431 | for cfg in old_configs: | |
419 | f = os.path.join(ipython_dir, cfg) |
|
432 | f = os.path.join(ipython_dir, cfg) | |
420 | if os.path.exists(f): |
|
433 | if os.path.exists(f): | |
|
434 | if filehash(f) == old_config_md5[cfg]: | |||
|
435 | os.unlink(f) | |||
|
436 | warn.info("Removed unmodified old IPython config file %r"%f) | |||
|
437 | else: | |||
421 | warned = True |
|
438 | warned = True | |
422 | warn.warn("Found old IPython config file %r"%f) |
|
439 | warn.warn("Found old IPython config file %r (modified by user)"%f) | |
423 |
|
440 | |||
424 | if warned: |
|
441 | if warned: | |
425 | warn.warn(""" |
|
442 | warn.warn(""" |
General Comments 0
You need to be logged in to leave comments.
Login now