forked from mantidproject/mantid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmantidplotrc.py
80 lines (72 loc) · 2.87 KB
/
mantidplotrc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#-------------------------------------------------------------------------------
# mantidplotrc.py
#
# Startup script for MantidPlot, executed once when the python environment
# is initialized. Any definitions added here will affect all Python scopes
# within the program.
#
#-------------------------------------------------------------------------------
# Do NOT add __future__ imports here as they will NOT be confined to this
# file.
if __name__ == '__main__':
try:
import matplotlib as _mpl
_mpl.use("module://pymantidplot.mpl.backend_mtdqt4agg")
del _mpl
except ImportError:
pass
from six import iteritems as _iteritems
# Import MantidPlot python commands
import mantidplot
from mantidplot import *
try:
# The MantidPlot namespace is not ready for the python3-style range function
# so we ensure we revert back to the current built-in version
del range
except NameError:
pass
# Make Mantid available
import mantid
# Make everything available without imports
from mantid import *
from mantid.kernel import *
from mantid.geometry import *
from mantid.api import *
from mantid.simpleapi import *
# Common imports (here for backwards compatability)
import os
import sys
#---------------------------------------------------------------------------
# Autocomplete helper method
#---------------------------------------------------------------------------
import inspect as _inspect
import __main__
def _ScopeInspector_GetFunctionAttributes(definitions):
if type(definitions) != dict:
return []
from mantid.simpleapi import _get_function_spec
keywords = []
for name,obj in _iteritems(definitions):
if name.startswith('_') : continue
if _inspect.isclass(obj) or _inspect.ismodule(obj):
continue
if _inspect.isfunction(obj) or _inspect.isbuiltin(obj):
keywords.append(name + _get_function_spec(obj))
continue
# Object could be a proxy so check and use underlying object
if hasattr(obj,"_getHeldObject"):
obj = obj._getHeldObject()
attrs = dir(obj)
for att in attrs:
try:
fattr = getattr(obj,att)
except Exception:
continue # not much we do if not even calling it causes an exception
if att.startswith('_'):
continue
if _inspect.isfunction(fattr) or _inspect.ismethod(fattr) or \
hasattr(fattr,'im_func'):
keywords.append(name + '.' + att + _get_function_spec(fattr))
return keywords;
else:
raise ImportError("mantidplotrc.py is an initialization file for MantidPlot not an importable module")