From 992a56e7a3a0841283929dbea1bb645ef56ae681 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Thu, 16 Dec 2010 23:27:37 +0100 Subject: [PATCH] if the documentation is beeing generated, don't create instance of some core providers + force loading of all modules in kivy --- doc/autobuild.py | 17 +++++++++++++++++ kivy/core/__init__.py | 20 ++++---------------- kivy/core/clipboard/__init__.py | 2 +- kivy/core/window/__init__.py | 2 +- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/doc/autobuild.py b/doc/autobuild.py index 0807172c3..17724b7fb 100644 --- a/doc/autobuild.py +++ b/doc/autobuild.py @@ -13,7 +13,24 @@ from glob import glob os.environ['KIVY_SHADOW_WINDOW'] = '0' import kivy + +# force loading of kivy modules +import kivy.core.audio +import kivy.core.camera +import kivy.core.clipboard +import kivy.core.gl +import kivy.core.image +import kivy.core.spelling +import kivy.core.svg +import kivy.core.text +import kivy.core.video +import kivy.core.window import kivy.graphics +from kivy.factory import Factory + +# force loading of all classes from factory +for x in Factory.classes: + getattr(Factory, x) # Directory of doc diff --git a/kivy/core/__init__.py b/kivy/core/__init__.py index c4b84598b..9ebdb034d 100644 --- a/kivy/core/__init__.py +++ b/kivy/core/__init__.py @@ -8,12 +8,12 @@ from kivy.logger import Logger if 'KIVY_DOC' in os.environ: # stub for sphinx generation - def core_select_lib(category, llist): + def core_select_lib(category, llist, create_instance=False): pass def core_register_libs(category, libs): pass else: - def core_select_lib(category, llist): + def core_select_lib(category, llist, create_instance=True): category = category.lower() for option, modulename, classname in llist: try: @@ -33,6 +33,8 @@ else: # ok ! Logger.info('%s: using <%s> as %s provider' % (category.capitalize(), option, category)) + if create_instance: + cls = cls() return cls except Exception as e: @@ -66,17 +68,3 @@ else: (category.capitalize(), option)) Logger.debug('', exc_info=e) - -''' -from kivy.core.audio import * -from kivy.core.camera import * -from kivy.core.image import * -from kivy.core.text import * -from kivy.core.video import * -from kivy.core.svg import * -from kivy.core.spelling import * -from kivy.core.clipboard import * - -# only after core loading, load extensions -from text.markup import * -''' diff --git a/kivy/core/clipboard/__init__.py b/kivy/core/clipboard/__init__.py index 0df2a52e3..e597dd230 100644 --- a/kivy/core/clipboard/__init__.py +++ b/kivy/core/clipboard/__init__.py @@ -26,4 +26,4 @@ class ClipboardBase(object): Clipboard = core_select_lib('clipboard', ( ('pygame', 'clipboard_pygame', 'ClipboardPygame'), ('dummy', 'clipboard_dummy', 'ClipboardDummy') -))() +), True) diff --git a/kivy/core/window/__init__.py b/kivy/core/window/__init__.py index b5e10176f..de05f2ba3 100644 --- a/kivy/core/window/__init__.py +++ b/kivy/core/window/__init__.py @@ -405,5 +405,5 @@ class WindowBase(EventDispatcher): # Load the appropriate provider Window = core_select_lib('window', ( ('pygame', 'window_pygame', 'WindowPygame'), -))() +), True)