More fixes for Python 3 compatibility (#13008)

* More fixes for Python 3 compatibility

* Workaround if the six module is not pip installed

* Lose the semicolons
This commit is contained in:
Christian Clauss
2019-12-19 02:05:55 -08:00
committed by Julian Oes
parent 2a848c365c
commit 6dc55f97d4
14 changed files with 107 additions and 105 deletions
+4 -8
View File
@@ -3,10 +3,12 @@
Script to read an yaml file containing the RTPS message IDs and update the naming convention to PascalCase
"""
import errno
import os
import yaml
import sys
import argparse
import six
__author__ = 'PX4 Development Team'
__copyright__ = \
@@ -91,14 +93,8 @@ def update_dict(list):
if verbose:
num_of_msgs = 0
for i, dictionary in enumerate(list["rtps"]):
# implementation depends on the Python version being used
if sys.version_info[0] < 3:
dict = {k: v.title().replace('_', '') if isinstance(
v, basestring) else v for k, v in dictionary.iteritems()}
else:
dict = {k: v.title().replace('_', '') if isinstance(
v, str) else v for k, v in dictionary.items()}
list["rtps"][i] = dict
list["rtps"][i] = {k: v.title().replace('_', '') if isinstance(
v, six.string_types) else v for k, v in six.iteritems(dictionary)}
if verbose:
num_of_msgs += 1
if verbose: