<commit_before>#include "dataload_ros.h"
#include <QTextStream>
#include <QFile>
#include <QMessageBox>
#include <QDebug>
#include <QApplication>
#include <QProgressDialog>
#include <QElapsedTimer>

#include <rosbag/view.h>

#include "../dialog_select_ros_topics.h"
#include "../shape_shifter_factory.hpp"
#include "../rule_editing.h"


DataLoadROS::DataLoadROS()
{
    _extensions.push_back( "bag");
}

const std::vector<const char*> &DataLoadROS::compatibleFileExtensions() const
{
    return _extensions;
}

PlotDataMap DataLoadROS::readDataFromFile(const std::string& file_name,
                                          std::string &load_configuration  )
{
    using namespace RosIntrospection;

    std::vector<std::pair<QString,QString>> all_topics;
    PlotDataMap plot_map;

    rosbag::Bag bag;
    bag.open( file_name, rosbag::bagmode::Read );


    rosbag::View bag_view ( bag, ros::TIME_MIN, ros::TIME_MAX, true );
    auto first_time = bag_view.getBeginTime();
    std::vector<const rosbag::ConnectionInfo *> connections = bag_view.getConnections();

    // create a list and a type map for each topic
    std::map<std::string,ROSTypeList> type_map;

    for(unsigned i=0;  i<connections.size(); i++)
    {
        const auto&  topic      =  connections[i]->topic;
        const auto&  md5sum     =  connections[i]->md5sum;
        const auto&  data_type  =  connections[i]->datatype;
        const auto&  definition =  connections[i]->msg_def;

        all_topics.push_back( std::make_pair(QString( topic.c_str()), QString( data_type.c_str()) ) );

        auto topic_map = buildROSTypeMapFromDefinition( data_type, definition);
        type_map.insert( std::make_pair(data_type,topic_map));
<commit_msg>catch the exception<commit_after>#include "dataload_ros.h"
#include <QTextStream>
#include <QFile>
#include <QMessageBox>
#include <QDebug>
#include <QApplication>
#include <QProgressDialog>
#include <QElapsedTimer>

#include <rosbag/view.h>

#include "../dialog_select_ros_topics.h"
#include "../shape_shifter_factory.hpp"
#include "../rule_editing.h"


DataLoadROS::DataLoadROS()
{
    _extensions.push_back( "bag");
}

const std::vector<const char*> &DataLoadROS::compatibleFileExtensions() const
{
    return _extensions;
}

PlotDataMap DataLoadROS::readDataFromFile(const std::string& file_name,
                                          std::string &load_configuration  )
{
    using namespace RosIntrospection;

    std::vector<std::pair<QString,QString>> all_topics;
    PlotDataMap plot_map;

    rosbag::Bag bag;
    try{
        bag.open( file_name, rosbag::bagmode::Read );
    }
    catch( rosbag::BagException&  ex)
    {
        QMessageBox::warning(0, tr("Error"),
                             QString("rosbag::open thrown an exception:\n")+
                             QString(ex.what()) );
        return plot_map;
    }

    rosbag::View bag_view ( bag, ros::TIME_MIN, ros::TIME_MAX, true );
    auto first_time = bag_view.getBeginTime();
    std::vector<const rosbag::ConnectionInfo *> connections = bag_view.getConnections();

    // create a list and a type map for each topic
    std::map<std::string,ROSTypeList> type_map;

    for(unsigned i=0;  i<connections.size(); i++)
    {
        const auto&  topic      =  connections[i]->topic;
        const auto&  md5sum     =  connections[i]->md5sum;
        const auto&  data_type  =  connections[i]->datatype;
        const auto&  definition =  connections[i]->msg_def;

        all_topics.push_back( std::make_pair(QString( topic.c_str()), QString( data_type.c_str()) ) );

        auto topic_map = buildROSTypeMapFromDefinition( data_type, definition);
        type_map.insert( std::make_pair(data_type,topic_map));

{'fraction_non_alphanumeric': 0.13180592991913748, 'fraction_numerical': 0.0018867924528301887, 'mean_word_length': 3.547794117647059, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1676558', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1192, 'n_words': 233}