2 #include "zypp/ZYppFactory.h"
3 #include "zypp/base/Logger.h"
4 #include "zypp/base/LogControl.h"
5 #include "zypp/base/Measure.h"
6 #include "zypp/cache/CacheStore.h"
7 #include "zypp/parser/yum/RepoParser.h"
9 #undef ZYPP_BASE_LOGGER_LOGGROUP
10 #define ZYPP_BASE_LOGGER_LOGGROUP "yumparsertest"
14 using namespace zypp::parser::yum;
15 using zypp::debug::Measure;
17 bool progress_function(ProgressData::value_type p)
19 cout << "Parsing YUM source [" << p << "%]" << endl;
20 // cout << "\rParsing YUM source [" << p << "%]" << flush;
24 int main(int argc, char **argv)
26 base::LogControl::instance().logfile("yumparsertest.log");
30 cout << "usage: yumparsertest path/to/yumsourcedir" << endl << endl;
36 ZYpp::Ptr z = getZYpp();
38 Measure open_repository_timer("CacheStore: lookupOrAppendRepository");
40 cache::CacheStore store(getenv("PWD"));
41 data::RecordId repository_id = store.lookupOrAppendRepository("somealias");
43 open_repository_timer.stop();
45 MIL << "creating PrimaryFileParser" << endl;
46 Measure parse_primary_timer("primary.xml.gz parsing");
48 parser::yum::RepoParser parser( repository_id, store, &progress_function);
49 parser.parse(argv[1]);
52 parse_primary_timer.stop();
56 catch ( const Exception &e )
58 cout << "Oops! " << e.msg() << std::endl;
64 // vim: set ts=2 sts=2 sw=2 et ai: