MCPcopy
hub / github.com/celery/celery / settings

Function settings

celery/bin/upgrade.py:72–91  ·  view source on GitHub ↗

Migrate settings from Celery 3.x to Celery 4.x.

(filename, django, compat, no_backup)

Source from the content-addressed store, hash-verified

70 help_group='Upgrading Options',
71 help="Don't backup original files.")
72def 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)

Callers

nothing calls this directly

Calls 5

_slurpFunction · 0.85
_to_new_keyFunction · 0.85
_backupFunction · 0.85
openMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected