Skip to content

Commit

Permalink
Reorganized functions
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Oct 16, 2018
1 parent ec3122d commit 967c3ae
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions bokeh/util/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,20 +364,6 @@ def dependencies(self):
def module(self):
return "custom/%s" % snakify(self.full_name)

def _get_custom_models(models):
"""Returns CustomModels for models with a custom `__implementation__`"""
custom_models = {}
for cls in models:
impl = getattr(cls, "__implementation__", None)

if impl is not None:
model = CustomModel(cls)
custom_models[model.full_name] = model

if not custom_models:
return None
return custom_models

def _model_cache_no_op(implementation):
"""Return cached compiled implementation"""
return None
Expand All @@ -393,6 +379,20 @@ def set_cache_hook(hook):
global _CACHING_IMPLEMENTATION
_CACHING_IMPLEMENTATION = hook

def _get_custom_models(models):
"""Returns CustomModels for models with a custom `__implementation__`"""
custom_models = {}
for cls in models:
impl = getattr(cls, "__implementation__", None)

if impl is not None:
model = CustomModel(cls)
custom_models[model.full_name] = model

if not custom_models:
return None
return custom_models

def _compile_models(models):
"""Returns the compiled implementation of supplied `models`. """
custom_models = _get_custom_models(models)
Expand Down Expand Up @@ -426,22 +426,23 @@ def _compile_models(models):
def bundle_models(models):
"""Create a bundle of `models`. """

custom_models = _get_custom_models(models)
if custom_models is None:
return

exports = []
modules = []

def read_json(name):
with io.open(join(bokehjs_dir, "js", name + ".json"), encoding="utf-8") as f:
return json.loads(f.read())

modules = []
exports = []

bundles = ["bokeh", "bokeh-api", "bokeh-widgets", "bokeh-tables", "bokeh-gl"]
known_modules = set(sum([ read_json(name) for name in bundles ], []))
extra_modules = {}

custom_models = _get_custom_models(models)
if custom_models is None:
return
custom_impls = _compile_models(models)

extra_modules = {}

def resolve_modules(to_resolve, root):
resolved = {}
for module in to_resolve:
Expand Down

0 comments on commit 967c3ae

Please sign in to comment.