commit:     ee2d2c671a98dfd61e61b1525975b1cfce94f160
Author:     Alexis Ballier <aballier <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  5 14:54:11 2020 +0000
Commit:     Alexis Ballier <aballier <AT> gentoo <DOT> org>
CommitDate: Wed Aug  5 15:30:09 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ee2d2c67

dev-ros/calibration_estimation: fix py3 compat

Closes: https://bugs.gentoo.org/734710
Package-Manager: Portage-3.0.1, Repoman-2.3.23
Signed-off-by: Alexis Ballier <aballier <AT> gentoo.org>

 .../calibration_estimation-0.10.14.ebuild          |  7 ++
 .../calibration_estimation-9999.ebuild             |  7 ++
 dev-ros/calibration_estimation/files/py3.patch     | 78 ++++++++++++++++++++++
 3 files changed, 92 insertions(+)

diff --git 
a/dev-ros/calibration_estimation/calibration_estimation-0.10.14.ebuild 
b/dev-ros/calibration_estimation/calibration_estimation-0.10.14.ebuild
index 804aef9eae2..c83819a9fef 100644
--- a/dev-ros/calibration_estimation/calibration_estimation-0.10.14.ebuild
+++ b/dev-ros/calibration_estimation/calibration_estimation-0.10.14.ebuild
@@ -30,3 +30,10 @@ DEPEND="${RDEPEND}
                dev-ros/rostest[${PYTHON_SINGLE_USEDEP}]
                $(python_gen_cond_dep "dev-python/nose[\${PYTHON_USEDEP}]")
        )"
+PATCHES=( "${FILESDIR}/py3.patch" )
+
+src_prepare() {
+       ros-catkin_src_prepare
+       sed -e 's/yaml.load/yaml.safe_load/g' -i src/*/*.py -i test/*.py || die
+       2to3 -w src/*/*.py src/*/*/*.py test/*.py || die
+}

diff --git a/dev-ros/calibration_estimation/calibration_estimation-9999.ebuild 
b/dev-ros/calibration_estimation/calibration_estimation-9999.ebuild
index 804aef9eae2..c83819a9fef 100644
--- a/dev-ros/calibration_estimation/calibration_estimation-9999.ebuild
+++ b/dev-ros/calibration_estimation/calibration_estimation-9999.ebuild
@@ -30,3 +30,10 @@ DEPEND="${RDEPEND}
                dev-ros/rostest[${PYTHON_SINGLE_USEDEP}]
                $(python_gen_cond_dep "dev-python/nose[\${PYTHON_USEDEP}]")
        )"
+PATCHES=( "${FILESDIR}/py3.patch" )
+
+src_prepare() {
+       ros-catkin_src_prepare
+       sed -e 's/yaml.load/yaml.safe_load/g' -i src/*/*.py -i test/*.py || die
+       2to3 -w src/*/*.py src/*/*/*.py test/*.py || die
+}

diff --git a/dev-ros/calibration_estimation/files/py3.patch 
b/dev-ros/calibration_estimation/files/py3.patch
new file mode 100644
index 00000000000..ad680c7a7c6
--- /dev/null
+++ b/dev-ros/calibration_estimation/files/py3.patch
@@ -0,0 +1,78 @@
+Index: 
calibration_estimation/src/calibration_estimation/sensors/chain_sensor.py
+===================================================================
+--- 
calibration_estimation.orig/src/calibration_estimation/sensors/chain_sensor.py
++++ calibration_estimation/src/calibration_estimation/sensors/chain_sensor.py
+@@ -135,7 +135,7 @@ class ChainSensor:
+         cov_angles = [x*x for x in 
self._full_chain.calc_block._chain._cov_dict['joint_angles']]
+         cov = matrix(Jt).T * matrix(diag(cov_angles)) * matrix(Jt)
+         
+-        if ( 
self._full_chain.calc_block._chain._cov_dict.has_key('translation') ):
++        if ( 'translation' in self._full_chain.calc_block._chain._cov_dict ):
+             translation_var = 
self._full_chain.calc_block._chain._cov_dict['translation'];
+             translation_cov = 
numpy.diag(translation_var*(self.get_residual_length()/3))
+             cov = cov + translation_cov
+Index: 
calibration_estimation/src/calibration_estimation/sensors/tilting_laser_sensor.py
+===================================================================
+--- 
calibration_estimation.orig/src/calibration_estimation/sensors/tilting_laser_sensor.py
++++ 
calibration_estimation/src/calibration_estimation/sensors/tilting_laser_sensor.py
+@@ -99,7 +99,7 @@ class TiltingLaserSensor:
+         gamma = matrix(zeros(cov.shape))
+         num_pts = self.get_residual_length()/3
+ 
+-        for k in range(num_pts):
++        for k in range(int(num_pts)):
+             first = 3*k
+             last = 3*k+3
+             sub_cov = matrix(cov[first:last, first:last])
+Index: calibration_estimation/test/chain_sensor_unittest.py
+===================================================================
+--- calibration_estimation.orig/test/chain_sensor_unittest.py
++++ calibration_estimation/test/chain_sensor_unittest.py
+@@ -59,7 +59,7 @@ from numpy import *
+ 
+ def loadSystem():
+     urdf = '''
+-<robot>
++<robot name="test">
+   <link name="base_link"/>
+   <joint name="j0" type="fixed">
+     <origin xyz="0 0 0" rpy="0 0 0"/>
+Index: calibration_estimation/test/full_chain_unittest.py
+===================================================================
+--- calibration_estimation.orig/test/full_chain_unittest.py
++++ calibration_estimation/test/full_chain_unittest.py
+@@ -50,7 +50,7 @@ import numpy
+ 
+ def loadSystem1():
+     urdf = '''
+-<robot>
++<robot name="test">
+   <link name="base_link"/>
+   <joint name="j0" type="fixed">
+     <origin xyz="10 0 0" rpy="0 0 0"/>
+Index: calibration_estimation/test/tilting_laser_sensor_unittest.py
+===================================================================
+--- calibration_estimation.orig/test/tilting_laser_sensor_unittest.py
++++ calibration_estimation/test/tilting_laser_sensor_unittest.py
+@@ -74,7 +74,7 @@ class TestTiltingLaserBundler(unittest.T
+ 
+ def loadSystem():
+     urdf = '''
+-<robot>
++<robot name="test">
+   <link name="base_link"/>
+   <joint name="j0" type="fixed">
+     <origin xyz="0 0 0" rpy="0 0 0"/>
+Index: calibration_estimation/test/tilting_laser_unittest.py
+===================================================================
+--- calibration_estimation.orig/test/tilting_laser_unittest.py
++++ calibration_estimation/test/tilting_laser_unittest.py
+@@ -47,7 +47,7 @@ from numpy import *
+ 
+ def loadSystem1():
+     urdf = '''
+-<robot>
++<robot name="test">
+   <link name="base_link"/>
+   <joint name="j0" type="fixed">
+     <origin xyz="0 0 10" rpy="0 0 0"/>

Reply via email to