12 from __future__
import print_function
17 This class is only defined to implement a path of attribute 18 to store entity commands. It has no members except those automatically 19 defined at run time (which should be CommandPath or functions). 25 privateName = name +
"_obj" 26 if privateName
in self.__dict__:
27 obj = getattr(self, privateName)
30 return object.__getattr__(self, name)
34 def createGetter(name):
36 obj = getattr(self, name)
42 privateName = name +
"_obj" 45 if not isinstance(target, CommandPath):
46 setattr(target, name, property(createGetter(privateName)))
63 if isinstance(target, CommandPath):
64 privateName = name +
"_obj" 67 setattr(target, name, fun)
72 Create in target an new attribute with value path (available at 73 target.path1. ... .pathn). 77 if isinstance(path, str):
78 path = path.split(
".")
79 for tokenk
in path[0:-1]:
80 if (
not read) | (tokenk
not in pathk.__dict__):
83 pathk = getattr(pathk, tokenk +
"_obj")
84 if callable(attribute):
87 print(
"Should not happen")
88 setattr(pathk, path[-1], attribute)
93 Get in target the value located at path (available at 94 target.path1. ... .pathn). 97 if isinstance(path, str):
98 path = path.split(
".")
100 privateName = tokenk +
"_obj" 101 if hasattr(pathk, privateName):
102 pathk = getattr(pathk, privateName)
104 if hasattr(pathk, tokenk):
105 pathk = getattr(pathk, tokenk)
108 'Path does not exist -- while accessing "' 118 Check for the existence in target of a value located at path (available at 119 target.path1. ... .pathn). 122 if isinstance(path, str):
123 path = path.split(
".")
124 for tokenk
in path[0:-1]:
125 print(
"check ", tokenk)
126 privateName = tokenk +
"_obj" 127 if privateName
not in pathk.__dict__:
129 pathk = getattr(pathk, privateName)
131 privateName = name +
"_obj" 132 return (name
in pathk.__dict__) | (privateName
in pathk.__dict__)
def getattrpath(target, path)
def existattrpath(target, path)
def createCommandLauncher(target, name, fun)
def createCommandModule(target, name)
def __getattr__(self, name)
def setattrpath(target, path, attribute)