1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/repo/RepoFileReader.cc
13 #include "zypp/base/Logger.h"
14 #include "zypp/base/InputStream.h"
15 #include "zypp/base/UserRequestException.h"
17 #include "zypp/parser/IniDict.h"
18 #include "zypp/parser/RepoFileReader.h"
21 using zypp::parser::IniDict;
23 ///////////////////////////////////////////////////////////////////
25 { /////////////////////////////////////////////////////////////////
26 ///////////////////////////////////////////////////////////////////
28 { /////////////////////////////////////////////////////////////////
31 * \short List of RepoInfo's from a file.
32 * \param file pathname of the file to read.
34 static void repositories_in_file( const Pathname &file,
35 const RepoFileReader::ProcessRepo &callback,
36 const ProgressData::ReceiverFnc &progress )
39 parser::IniDict dict(is);
40 for ( parser::IniDict::section_const_iterator its = dict.sectionsBegin();
41 its != dict.sectionsEnd();
44 MIL << (*its) << endl;
49 for ( IniDict::entry_const_iterator it = dict.entriesBegin(*its);
50 it != dict.entriesEnd(*its);
53 //MIL << (*it).first << endl;
54 if (it->first == "name" )
55 info.setName(it-> second);
56 else if ( it->first == "enabled" )
57 info.setEnabled( it->second == "1" );
58 else if ( it->first == "baseurl" && !it->second.empty())
59 info.addBaseUrl( Url(it->second) );
60 else if ( it->first == "path" )
61 info.setPath( Pathname(it->second) );
62 else if ( it->first == "type" )
63 info.setType(repo::RepoType(it->second));
64 else if ( it->first == "autorefresh" )
65 info.setAutorefresh( it->second == "1" );
66 else if ( it->first == "mirrorlist" && !it->second.empty())
67 info.setMirrorListUrl(Url(it->second));
68 else if ( it->first == "gpgkey" && !it->second.empty())
69 info.setGpgKeyUrl( Url(it->second) );
70 else if ( it->first == "gpgcheck" )
71 info.setGpgCheck( it->second == "1" );
73 ERR << "Unknown attribute " << it->second << " ignored" << endl;
75 MIL << "Linking repo info with file " << file << endl;
76 info.setFilepath(file);
77 // add it to the list.
79 //if (!progress.tick())
80 // ZYPP_THROW(AbortRequestException());
84 ///////////////////////////////////////////////////////////////////
86 // CLASS NAME : RepoFileReader
88 ///////////////////////////////////////////////////////////////////
90 RepoFileReader::RepoFileReader( const Pathname & repo_file,
91 const ProcessRepo & callback,
92 const ProgressData::ReceiverFnc &progress )
95 repositories_in_file(repo_file, _callback, progress);
96 //MIL << "Done" << endl;
99 RepoFileReader::~RepoFileReader()
102 std::ostream & operator<<( std::ostream & str, const RepoFileReader & obj )
107 /////////////////////////////////////////////////////////////////
108 } // namespace parser
109 ///////////////////////////////////////////////////////////////////
110 /////////////////////////////////////////////////////////////////
112 ///////////////////////////////////////////////////////////////////