Ignore:
Timestamp:
01/25/13 17:42:19 (15 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Changed discovery to run from arbitrary entry points iterator/group.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/config.py

    r11250 r11285  
    77import logging 
    88import cPickle as pickle 
    9  
    10 log = logging.getLogger(__name__) 
     9import itertools 
     10 
     11import pkg_resources 
    1112 
    1213from PyQt4.QtGui import QDesktopServices 
     
    1415 
    1516from .utils.settings import Settings, config_slot 
     17 
     18log = logging.getLogger(__name__) 
    1619 
    1720 
     
    2124 
    2225    .. note:: This should not be run before QApplication has been initialized. 
    23               Otherwise it can brake Qt's plugin search paths. 
     26              Otherwise it can break Qt's plugin search paths. 
    2427 
    2528    """ 
     
    191194        with open(recent_filename, "wb") as f: 
    192195            pickle.dump(scheme_list, f) 
     196 
     197 
     198WIDGETS_ENTRY = "orange.widgets" 
     199 
     200 
     201# This could also be achieved by declaring the entry point in 
     202# Orange's setup.py, but that would not guaranty this entry point 
     203# is the first in a list. 
     204 
     205def default_entry_point(): 
     206    """ 
     207    Return a default orange.widgets entry point for loading 
     208    default Orange Widgets. 
     209 
     210    """ 
     211    dist = pkg_resources.get_distribution("Orange") 
     212    ep = pkg_resources.EntryPoint("Orange Widgets", "Orange.OrangeWidgets", 
     213                                  dist=dist) 
     214    return ep 
     215 
     216 
     217def widgets_entry_points(): 
     218    """ 
     219    Return an `EntryPoint` iterator for all 'orange.widget' entry 
     220    points plus the default Orange Widgets. 
     221 
     222    """ 
     223    ep_iter = pkg_resources.iter_entry_points(WIDGETS_ENTRY) 
     224    chain = [[default_entry_point()], 
     225             ep_iter 
     226             ] 
     227    return itertools.chain(*chain) 
Note: See TracChangeset for help on using the changeset viewer.