Migrate settings from Celery 3.x to Celery 4.x.
(filename, django, compat, no_backup)
| 70 | help_group='Upgrading Options', |
| 71 | help="Don't backup original files.") |
| 72 | def settings(filename, django, compat, no_backup): |
| 73 | """Migrate settings from Celery 3.x to Celery 4.x.""" |
| 74 | lines = _slurp(filename) |
| 75 | keyfilter = _compat_key if django or compat else pass1 |
| 76 | print(f'processing {filename}...', file=sys.stderr) |
| 77 | # gives list of tuples: ``(did_change, line_contents)`` |
| 78 | new_lines = [ |
| 79 | _to_new_key(line, keyfilter) for line in lines |
| 80 | ] |
| 81 | if any(n[0] for n in new_lines): # did have changes |
| 82 | if not no_backup: |
| 83 | _backup(filename) |
| 84 | with codecs.open(filename, 'w', 'utf-8') as write_fh: |
| 85 | for _, line in new_lines: |
| 86 | write_fh.write(line) |
| 87 | print('Changes to your setting have been made!', |
| 88 | file=sys.stdout) |
| 89 | else: |
| 90 | print('Does not seem to require any changes :-)', |
| 91 | file=sys.stdout) |
nothing calls this directly
no test coverage detected