def _rewrite_rviz_file(self, rviz_file, tmp_dir):
    data = None
    with open(rviz_file, 'r') as stream:
        try:
            data = yaml.safe_load(stream)
        except yaml.YAMLError as exc:
            self._logger.warning(('Cannot rewrite malformed rviz file: %s' % str(exc)))
            return rviz_file
    data['Window Geometry']['Height'] = self.config('height')
    data['Window Geometry']['Width'] = ((self.config('width') - self.config('margin_left')) - self.config('margin_right'))
    data['Window Geometry']['Y'] = 0
    data['Window Geometry']['X'] = self.config('margin_left')
    data['Window Geometry']['Hide Left Dock'] = True
    data['Window Geometry']['Hide Right Dock'] = True
    data['Window Geometry']['Selection']['collapsed'] = True
    data['Window Geometry']['Time']['collapsed'] = False
    data['Window Geometry']['Tool Properties']['collapsed'] = True
    data['Window Geometry']['Views']['collapsed'] = True
    data['Window Geometry']['Displays']['collapsed'] = True
    rewritten_rviz_file = (tmp_dir + '/rviz.rviz')
    with open(rewritten_rviz_file, 'w') as outfile:
        yaml.safe_dump(data, outfile, default_flow_style=False)
    return rewritten_rviz_file
def _rewrite_rviz_file(self, rviz_file, tmp_dir):
    data = None
    with open(rviz_file, 'r') as stream:
        try:
            data = yaml.safe_load(stream)
        except yaml.YAMLError as exc:
            self._logger.warning(('Cannot rewrite malformed rviz file: %s' % str(exc)))
            return rviz_file
    data['Window Geometry']['Height'] = self.config('height')
    data['Window Geometry']['Width'] = ((self.config('width') - self.config('margin_left')) - self.config('margin_right'))
    data['Window Geometry']['Y'] = 0
    data['Window Geometry']['X'] = self.config('margin_left')
    data['Window Geometry']['Hide Left Dock'] = True
    data['Window Geometry']['Hide Right Dock'] = True
    data['Window Geometry']['Selection']['collapsed'] = True
    data['Window Geometry']['Time']['collapsed'] = False
    data['Window Geometry']['Tool Properties']['collapsed'] = True
    data['Window Geometry']['Views']['collapsed'] = True
    data['Window Geometry']['Displays']['collapsed'] = True
    rewritten_rviz_file = (tmp_dir + '/rviz.rviz')
    with open(rewritten_rviz_file, 'w') as outfile:
        yaml.safe_dump(data, outfile, default_flow_style=False)
    return rewritten_rviz_file