def get_extension_classes(sort, extra_extension_paths=None):
all_classes = {}<EOL>deps_map = {}<EOL>for entry_point in pkg_resources.iter_entry_points(<EOL>group='<STR_LIT>', name='<STR_LIT>'):<EOL><INDENT>if entry_point.module_name == '<STR_LIT>':<EOL><INDENT>continue<EOL><DEDENT>try:<EOL><INDENT>activation_function = entry_point.load()<EOL>classes = activation_function()<EOL><DEDENT>except Exception as exc:<EOL><INDENT>info("<STR_LIT>" % entry_point.module_name, exc)<EOL>debug(traceback.format_exc())<EOL>continue<EOL><DEDENT>for klass in classes:<EOL><INDENT>all_classes[klass.extension_name] = klass<EOL><DEDENT><DEDENT>if extra_extension_paths:<EOL><INDENT>for klass in __get_extra_extension_classes(extra_extension_paths):<EOL><INDENT>all_classes[klass.extension_name] = klass<EOL><DEDENT><DEDENT>klass_list = list(all_classes.values())<EOL>if not sort:<EOL><INDENT>return klass_list<EOL><DEDENT>for i, klass in enumerate(klass_list):<EOL><INDENT>deps = klass.get_dependencies()<EOL>topodeps = set()<EOL>for dep in deps:<EOL><INDENT>if dep.dependency_name not in all_classes:<EOL><INDENT>if dep.optional:<EOL><INDENT>continue<EOL><DEDENT>else:<EOL><INDENT>error("<STR_LIT>",<EOL>"<STR_LIT>" %<EOL>(dep.dependency_name, klass.extension_name))<EOL><DEDENT><DEDENT>if dep.is_upstream:<EOL><INDENT>topodeps.add(<EOL>klass_list.index(all_classes[dep.dependency_name]))<EOL><DEDENT><DEDENT>deps_map[i] = topodeps<EOL><DEDENT>sorted_class_indices = toposort_flatten(deps_map)<EOL>sorted_classes = [klass_list[i] for i in sorted_class_indices]<EOL>return sorted_classes<EOL>
Banana banana