-
Notifications
You must be signed in to change notification settings - Fork 3
rebased to the recent master #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,7 +51,8 @@ def create(ros_msg_class, | |
|
|
||
| members_types = _get_rosmsg_fields_as_dict(ros_msg_class) | ||
| members = {} | ||
| for s, stype in six.iteritems(members_types): | ||
| schema_instance = RosSchema() | ||
| for s, stype in members_types.iteritems(): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. iteritems() is not py2/py3 compatible. please use methods that work in both. |
||
| # Note here we rely entirely on _opt_slots from the class to be set properly | ||
| # for both Nested or List representation of optional fields | ||
| ros_schema_inst = None | ||
|
|
@@ -80,28 +81,24 @@ def create(ros_msg_class, | |
| ros_schema_inst = RosNested(create(stype)) # we need to nest the next (Ros)Schema | ||
|
|
||
| members.setdefault(s, ros_schema_inst) | ||
| schema_instance.declared_fields[s] = ros_schema_inst | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems very hacky to me. |
||
| schema_instance.fields[s] = ros_schema_inst | ||
|
|
||
| # supporting extra customization of the serialization | ||
| if pre_load_fun: | ||
| members['_helper_pre_load'] = pre_load(pre_load_fun) | ||
| schema_instance.declared_fields['_helper_pre_load'] = pre_load(pre_load_fun) | ||
| if post_load_fun: | ||
| members['_helper_post_load'] = post_load(post_load_fun) | ||
| schema_instance.declared_fields['_helper_post_load'] = post_load(post_load_fun) | ||
| if pre_dump_fun: | ||
| members['_helper_pre_dump'] = pre_dump(pre_dump_fun) | ||
| schema_instance.declared_fields['_helper_pre_dump'] = pre_dump(pre_dump_fun) | ||
| if post_dump_fun: | ||
| members['_helper_post_dump'] = post_dump(post_dump_fun) | ||
| schema_instance.declared_fields['_helper_post_dump'] = post_dump(post_dump_fun) | ||
|
|
||
| # adding extra members if needed | ||
| for k, v in kwargs: | ||
| members[k] = v | ||
| schema_instance.declared_fields[k] = v | ||
|
|
||
| members['_valid_ros_msgtype'] = ros_msg_class | ||
| members['_generated_ros_msgtype'] = ros_msg_class | ||
|
|
||
| MsgSchema = type(ros_msg_class.__name__ + 'Schema', (RosSchema,), members) | ||
|
|
||
| # Generating the schema instance | ||
| # TODO : nicer way ? | ||
| schema_instance = MsgSchema() | ||
| schema_instance._valid_ros_msgtype = ros_msg_class | ||
| schema_instance._generated_ros_msgtype = ros_msg_class | ||
|
|
||
| return schema_instance | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you mean that instead of creating a child class (CustomMsgSchema) of RosSchema, and taking and instance of that class,
it is better to instantiate a RosSchema and usedirectly that instance ?
How about the second time we need that Schema, we have to create it again it seems ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to solve your source as much as possible without modifying it if possible. So I did not try various methods. Sorry and thank you of your efforts.