1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/repo/RepoFileReader.cc
13 #include "zypp/base/Logger.h"
14 #include "zypp/base/String.h"
15 #include "zypp/base/InputStream.h"
16 #include "zypp/base/UserRequestException.h"
18 #include "zypp/parser/IniDict.h"
19 #include "zypp/parser/RepoFileReader.h"
22 using zypp::parser::IniDict;
24 ///////////////////////////////////////////////////////////////////
26 { /////////////////////////////////////////////////////////////////
27 ///////////////////////////////////////////////////////////////////
29 { /////////////////////////////////////////////////////////////////
32 * \short List of RepoInfo's from a file.
33 * \param file pathname of the file to read.
35 static void repositories_in_file( const Pathname &file,
36 const RepoFileReader::ProcessRepo &callback,
37 const ProgressData::ReceiverFnc &progress )
40 parser::IniDict dict(is);
41 for ( parser::IniDict::section_const_iterator its = dict.sectionsBegin();
42 its != dict.sectionsEnd();
48 for ( IniDict::entry_const_iterator it = dict.entriesBegin(*its);
49 it != dict.entriesEnd(*its);
52 //MIL << (*it).first << endl;
53 if (it->first == "name" )
54 info.setName(it-> second);
55 else if ( it->first == "enabled" )
56 info.setEnabled( str::strToTrue( it->second ) );
57 else if ( it->first == "priority" )
58 info.setPriority( str::strtonum<unsigned>( it->second ) );
59 else if ( it->first == "baseurl" && !it->second.empty())
60 info.addBaseUrl( Url(it->second) );
61 else if ( it->first == "path" )
62 info.setPath( Pathname(it->second) );
63 else if ( it->first == "type" )
64 info.setType(repo::RepoType(it->second));
65 else if ( it->first == "autorefresh" )
66 info.setAutorefresh( str::strToTrue( it->second ) );
67 else if ( it->first == "mirrorlist" && !it->second.empty())
68 info.setMirrorListUrl(Url(it->second));
69 else if ( it->first == "gpgkey" && !it->second.empty())
70 info.setGpgKeyUrl( Url(it->second) );
71 else if ( it->first == "gpgcheck" )
72 info.setGpgCheck( str::strToTrue( it->second ) );
73 else if ( it->first == "keeppackages" )
74 info.setKeepPackages( str::strToTrue( it->second ) );
75 else if ( it->first == "service" )
76 info.setService( it->second );
78 ERR << "Unknown attribute in [" << *its << "]: " << it->second << " ignored" << endl;
80 info.setFilepath(file);
82 // add it to the list.
84 //if (!progress.tick())
85 // ZYPP_THROW(AbortRequestException());
89 ///////////////////////////////////////////////////////////////////
91 // CLASS NAME : RepoFileReader
93 ///////////////////////////////////////////////////////////////////
95 RepoFileReader::RepoFileReader( const Pathname & repo_file,
96 const ProcessRepo & callback,
97 const ProgressData::ReceiverFnc &progress )
100 repositories_in_file(repo_file, _callback, progress);
101 //MIL << "Done" << endl;
104 RepoFileReader::~RepoFileReader()
107 std::ostream & operator<<( std::ostream & str, const RepoFileReader & obj )
112 /////////////////////////////////////////////////////////////////
113 } // namespace parser
114 ///////////////////////////////////////////////////////////////////
115 /////////////////////////////////////////////////////////////////
117 ///////////////////////////////////////////////////////////////////