@@ -40,36 +40,46 @@ def CloneBindings(self, parent):
40
40
pass
41
41
42
42
def __dir__ (self ):
43
+ robot = self .GetRobot ()
44
+
43
45
# We have to manually perform a lookup in InstanceDeduplicator because
44
46
# __methods__ bypass __getattribute__.
45
47
self = bind .InstanceDeduplicator .get_canonical (self )
46
48
47
49
# Add planning methods to the tab-completion list.
48
50
method_names = set (self .__dict__ .keys ())
49
- method_names .update (self .GetRobot ().planner .get_planning_method_names ())
50
- method_names .update (self .GetRobot ().actions .get_actions ())
51
+
52
+ if hasattr (robot , 'planner' ) and robot .planner is not None :
53
+ method_names .update (robot .planner .get_planning_method_names ())
54
+ if hasattr (robot , 'actions' ) and robot .actions is not None :
55
+ method_names .update (robot .actions .get_actions ())
56
+
51
57
return list (method_names )
52
58
53
59
def __getattr__ (self , name ):
54
60
# We have to manually perform a lookup in InstanceDeduplicator because
55
61
# __methods__ bypass __getattribute__.
56
62
self = bind .InstanceDeduplicator .get_canonical (self )
63
+ robot = self .GetRobot ()
57
64
58
65
# Resolve planner calls through the robot.planner field.
59
66
# FIXME: We need to replicate the _PlanWrapper functionality here.
60
- if self .GetRobot ().planner .has_planning_method (name ):
61
- delegate_method = getattr (self .GetRobot ().planner , name )
67
+ if (hasattr (robot , 'planner' ) and robot .planner is not None
68
+ and robot .planner .has_planning_method (name )):
69
+
70
+ delegate_method = getattr (robot .planner , name )
62
71
@functools .wraps (delegate_method )
63
- def wrapper_method (* args , ** kw_args ):
64
- return self ._PlanWrapper (delegate_method , args , kw_args )
72
+ def wrapper_method (* args , ** kwargs ):
73
+ return self ._PlanWrapper (delegate_method , args , kwargs )
65
74
return wrapper_method
66
- elif self .GetRobot ().actions .has_action (name ):
67
- delegate_method = self .GetRobot ().actions .get_action (name )
75
+
76
+ elif (hasattr (robot , 'actions' ) and robot .actions is not None
77
+ and robot .actions .has_action (name )):
78
+
79
+ delegate_method = robot .actions .get_action (name )
68
80
@functools .wraps (delegate_method )
69
- def wrapper_method (obj , * args , ** kw_args ):
70
- return delegate_method (self .GetRobot (), obj ,
71
- manip = self ,
72
- * args , ** kw_args )
81
+ def wrapper_method (obj , * args , ** kwargs ):
82
+ return delegate_method (robot , obj , manip = self , * args , ** kwargs )
73
83
return wrapper_method
74
84
75
85
raise AttributeError ('{0:s} is missing method "{1:s}".' .format (repr (self ), name ))
0 commit comments