|
36 | 36 | #goes between RobotOS and rospy.
|
37 | 37 | const _rospy_imports = Dict{ASCIIString,ROSPackage}()
|
38 | 38 | const _rospy_objects = Dict{ASCIIString,PyObject}()
|
| 39 | +const _rospy_modules = Dict{ASCIIString,PyObject}() |
39 | 40 |
|
40 | 41 | const _ros_builtin_types = @compat Dict{ASCIIString, Symbol}(
|
41 | 42 | "bool" => :Bool,
|
@@ -175,8 +176,8 @@ function addtype!(mod::ROSSrvModule, typ::String)
|
175 | 176 |
|
176 | 177 | #Immediately import dependencies from the Request/Response classes
|
177 | 178 | #Repeats are OK
|
178 |
| - req_obj = pymod.pymember(string(typ,"Request")) |
179 |
| - resp_obj = pymod.pymember(string(typ,"Response")) |
| 179 | + req_obj = pymod[string(typ,"Request")] |
| 180 | + resp_obj = pymod[string(typ,"Response")] |
180 | 181 | deptypes = [req_obj[:_slot_types]; resp_obj[:_slot_types]]
|
181 | 182 | _importdeps!(mod, deptypes)
|
182 | 183 |
|
|
192 | 193 | function _pyvars(modname::String, typ::String)
|
193 | 194 | pymod = _import_rospy_pkg(modname)
|
194 | 195 | pyobj =
|
195 |
| - try pymod.pymember(typ) |
| 196 | + try pymod[typ] |
196 | 197 | catch ex
|
197 | 198 | if isa(ex, KeyError)
|
198 | 199 | throw(KeyError("'$typ' in package '$modname'"))
|
@@ -234,19 +235,17 @@ end
|
234 | 235 |
|
235 | 236 | #Bring in the python modules as needed
|
236 | 237 | function _import_rospy_pkg(package::String)
|
237 |
| - pkg, ptype = split(package, '.') |
238 |
| - pypkg = symbol(string("py_",pkg,"_",ptype)) |
239 |
| - if ! isdefined(RobotOS, pypkg) |
| 238 | + global _rospy_modules |
| 239 | + if ! haskey(_rospy_modules, package) |
240 | 240 | @debug("Importing python package: ", package)
|
241 |
| - pkgsym, mssym = symbol(pkg), symbol(ptype) |
242 | 241 | try
|
243 |
| - @eval @pyimport $(pkgsym).$(mssym) as $pypkg |
| 242 | + _rospy_modules[package] = pyimport(package) |
244 | 243 | catch ex
|
245 | 244 | show(ex)
|
246 | 245 | error("python import error: $(ex.val[:args][1])")
|
247 | 246 | end
|
248 | 247 | end
|
249 |
| - eval(pypkg) |
| 248 | + _rospy_modules[package] |
250 | 249 | end
|
251 | 250 |
|
252 | 251 | #The function that creates and fills the generated top-level modules
|
|
0 commit comments