source: orange/Orange/__init__.py @ 11692:356c325c0efb

Revision 11692:356c325c0efb, 5.2 KB checked in by Ales Erjavec <ales.erjavec@…>, 7 months ago (diff)

Removed 'Earth' code from Orange (moved to 'orangecontrib.earth' package).

Line 
1from __future__ import absolute_import
2
3# This is overwritten with version from version.py, which is generated by
4# setup.py automatically
5__version__ = "unknown"
6
7ADDONS_ENTRY_POINT = 'orange.addons'
8
9import os, sys
10
11if not os.environ.get('READTHEDOCS', None):
12    from . import orange
13    # Definitely ugly, but I see no other workaround.
14    # When, e.g. data.io executes "from orange import ExampleTable"
15    # orange gets imported again since it is not in sys.modules
16    # before this entire file is executed
17    sys.modules["orange"] = orange
18
19# Little trick so that legacy imports work automatically
20import Orange.orng
21sys.path = Orange.orng.__path__ + sys.path
22
23import warnings
24import pkg_resources
25
26alreadyWarned = False
27disabledMsg = "Some features will be disabled due to failing modules\n"
28def _import(name):
29    global alreadyWarned
30    try:
31        __import__(name, globals(), locals(), [], -1)
32    except ImportError, err:
33        warnings.warn("%sImporting '%s' failed: %s" %
34            (disabledMsg if not alreadyWarned else "", name, err),
35            UserWarning, 2)
36        alreadyWarned = True
37
38
39def _import_addons():
40    globals_dict = globals()
41    for entry_point in pkg_resources.iter_entry_points(ADDONS_ENTRY_POINT):
42        try:
43            module = entry_point.load()
44            # Dot is not allowed in an entry point name (it should
45            # be a Python identifier, because it is used as a class
46            # name), so we are using __ instead
47            name = entry_point.name.replace('__', '.')
48            if '.' not in name:
49                globals_dict[name] = module
50            else:
51                path, mod = name.rsplit('.', 1)
52                parent_module_name = 'Orange.%s' % (path,)
53                try:
54                    parent_module = sys.modules[parent_module_name]
55                except KeyError:
56                    warnings.warn("Loading add-on '%s' failed because destination namespace point '%s' was not found." % (entry_point.name, parent_module_name), UserWarning, 2)
57                    continue
58                setattr(parent_module, mod, module)
59            sys.modules['Orange.%s' % (name,)] = module
60        except ImportError, err:
61            warnings.warn("Importing add-on '%s' failed: %s" % (entry_point.name, err), UserWarning, 2)
62        except pkg_resources.DistributionNotFound, err:
63            warnings.warn("Loading add-on '%s' failed because of a missing dependency: '%s'" % (entry_point.name, err), UserWarning, 2)
64        except Exception, err:
65            warnings.warn("An exception occurred during the loading of '%s':\n%r" %(entry_point.name, err), UserWarning, 2)
66
67
68_import("utils")
69
70_import("data")
71_import("data.io")
72_import("data.sample")
73_import("data.outliers")
74_import("data.preprocess")
75_import("data.preprocess.scaling")
76_import("data.utils")
77_import("data.discretization")
78_import("data.continuization")
79_import("data.filter")
80_import("data.imputation")
81
82_import("feature")
83_import("feature.construction")
84_import("feature.construction.functionDecomposition")
85_import("feature.construction.univariate")
86_import("feature.discretization")
87_import("feature.imputation")
88_import("feature.scoring")
89_import("feature.selection")
90
91_import("stat")
92
93_import("statistics")
94_import("statistics.estimate")
95_import("statistics.contingency")
96_import("statistics.distribution")
97_import("statistics.basic")
98_import("statistics.evd")
99
100_import("classification")
101_import("classification.tree")
102
103_import("classification.rules")
104
105_import("classification.lookup")
106_import("classification.bayes")
107_import("classification.svm")
108_import("classification.logreg")
109_import("classification.knn")
110_import("classification.majority")
111_import("classification.neural")
112
113_import("tuning")
114
115_import("projection")
116_import("projection.linear")
117_import("projection.mds")
118_import("projection.som")
119
120_import("ensemble")
121_import("ensemble.bagging")
122_import("ensemble.boosting")
123_import("ensemble.forest")
124_import("ensemble.stacking")
125
126_import("regression")
127_import("regression.base")
128_import("regression.lasso")
129_import("regression.linear")
130_import("regression.mean")
131_import("regression.pls")
132_import("regression.tree")
133
134_import("multilabel")
135_import("multilabel.multibase")
136_import("multilabel.br")
137_import("multilabel.lp")
138_import("multilabel.mlknn")
139_import("multilabel.brknn")
140_import("multilabel.mulan")
141
142_import("associate")
143
144_import("distance")
145
146_import("wrappers")
147
148_import("featureConstruction")
149_import("featureConstruction.univariate")
150_import("featureConstruction.functionDecomposition")
151
152_import("evaluation")
153_import("evaluation.scoring")
154_import("evaluation.testing")
155
156_import("clustering")
157_import("clustering.kmeans")
158_import("clustering.hierarchical")
159_import("clustering.consensus")
160
161_import("misc")
162
163_import("utils") #TODO hide utils from the user
164_import("utils.environ")
165_import("utils.counters")
166_import("utils.addons")
167_import("utils.render")
168_import("utils.serverfiles")
169
170_import_addons()
171
172try:
173    from . import version
174    # Always use short_version here (see PEP 386)
175    __version__ = version.short_version
176    __hg_revision__ = version.hg_revision
177except ImportError:
178    # Leave the default version defined at the top.
179    pass
180
181del _import
182del _import_addons
183del alreadyWarned
184del disabledMsg
Note: See TracBrowser for help on using the repository browser.