diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2018-08-17 13:34:23 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2018-08-17 13:35:29 -0400 |
commit | 646cf91a749358a8ac24d444c8c2d651df47141a (patch) | |
tree | d994149b454a6a1cf7942b047c2790c3d4987cfc | |
parent | 25e8037be2aa98f189193da36f6aac4c9775c15a (diff) | |
download | cherrypy-git-646cf91a749358a8ac24d444c8c2d651df47141a.tar.gz |
Consolidate logic around registering for autoreload.
-rw-r--r-- | cherrypy/_cpconfig.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/cherrypy/_cpconfig.py b/cherrypy/_cpconfig.py index edd84cf3..8e3fd612 100644 --- a/cherrypy/_cpconfig.py +++ b/cherrypy/_cpconfig.py @@ -123,14 +123,19 @@ from cherrypy._cpcompat import text_or_bytes from cherrypy.lib import reprconf +def _if_filename_register_autoreload(ob): + """Register for autoreload if ob is a string (presumed filename).""" + is_filename = isinstance(ob, text_or_bytes) + is_filename and cherrypy.engine.autoreload.files.add(ob) + + def merge(base, other): """Merge one app config (from a dict, file, or filename) into another. If the given config is a filename, it will be appended to the list of files to monitor for "autoreload" changes. """ - if isinstance(other, text_or_bytes): - cherrypy.engine.autoreload.files.add(other) + _if_filename_register_autoreload(other) # Load other into base for section, value_map in reprconf.Parser.load(other).items(): @@ -148,9 +153,7 @@ class Config(reprconf.Config): def update(self, config): """Update self from a dict, file or filename.""" - if isinstance(config, text_or_bytes): - # Filename - cherrypy.engine.autoreload.files.add(config) + _if_filename_register_autoreload(config) super(Config, self).update(config) def _apply(self, config): |