sourceinclude_HEADERS = \
PackagesParser.h\
+ PackagesLangParser.h\
SuseTagsImpl.h \
SuseTagsSelectionImpl.h \
SuseTagsPatternImpl.h \
lib@PACKAGE@_source_susetags_la_SOURCES = \
PackagesParser.cc \
+ PackagesLangParser.cc \
SuseTagsImpl.cc \
SuseTagsSelectionImpl.cc \
SuseTagsPatternImpl.cc \
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/source/susetags/PackagesLangParser.cc
+ *
+*/
+#include <iostream>
+#include "zypp/base/Logger.h"
+
+#include "zypp/source/susetags/PackagesLangParser.h"
+#include "zypp/parser/tagfile/TagFileParser.h"
+#include "zypp/Package.h"
+#include "zypp/source/susetags/SuseTagsPackageImpl.h"
+
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace source
+ { /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace susetags
+ { /////////////////////////////////////////////////////////////////
+
+ using namespace parser::tagfile;
+
+ struct PackagesLangParser : public parser::tagfile::TagFileParser
+ {
+ const PkgContent & _content;
+ const Locale & _lang;
+ PkgImplPtr _current;
+
+ PackagesLangParser (const PkgContent & content_r, const Locale & lang_r)
+ : _content( content_r )
+ , _lang( lang_r)
+ { }
+
+ /* Consume SingleTag data. */
+ virtual void consume( const SingleTag & stag_r )
+ {
+ if ( stag_r.name == "Pkg" )
+ {
+ std::vector<std::string> words;
+ str::split( stag_r.value, std::back_inserter(words) );
+
+ if ( str::split( stag_r.value, std::back_inserter(words) ) != 4 )
+ ZYPP_THROW( ParseException( "Pkg" ) );
+
+ NVRAD nvrad ( words[0], Edition(words[1],words[2]), Arch(words[3]) );
+ PkgContent::const_iterator it = _content.find(nvrad);
+ if (it == _content.end()) {
+ WAR << words[0] << " " << words[1] << " " << words[2] << " " << Arch(words[3]) << " not found" << endl;
+ _current.reset();
+ }
+ else {
+ _current = it->second;
+ }
+
+ }
+ else if ( stag_r.name == "Sum" )
+ {
+ if (_current != NULL) {
+ _current->_summary = TranslatedText( stag_r.value, _lang);
+ }
+ }
+ }
+
+ /* Consume MulitTag data. */
+ virtual void consume( const MultiTag & mtag_r )
+ {
+ if ( mtag_r.name == "Des" )
+ {
+ if ( _current != NULL )
+ _current->_description = TranslatedText (mtag_r.values, _lang);
+ }
+ }
+ };
+
+ ////////////////////////////////////////////////////////////////////////////
+
+ void parsePackagesLang( const Pathname & file_r, const Locale & lang_r, const PkgContent & content_r )
+ {
+ PackagesLangParser p (content_r, lang_r);
+ p.parse( file_r );
+ return;
+ }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace susetags
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+ } // namespace source
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/source/susetags/PackagesLangParser.h
+ *
+*/
+#ifndef ZYPP_SOURCE_SUSETAGS_PACKAGESLANGPARSER_H
+#define ZYPP_SOURCE_SUSETAGS_PACKAGESLANGPARSER_H
+
+#include <iosfwd>
+#include <list>
+
+#include "zypp/Pathname.h"
+#include "zypp/Package.h"
+#include "zypp/source/susetags/PackagesParser.h"
+#include "zypp/source/susetags/SuseTagsImpl.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace source
+ { /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace susetags
+ { /////////////////////////////////////////////////////////////////
+
+ /** \deprecated Just temporary.
+ * \throws ParseException and others.
+ */
+ void parsePackagesLang( const Pathname & file_r, const Locale & lang_r, const PkgContent & content_r );
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace susetags
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+ } // namespace source
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SOURCE_SUSETAGS_PACKAGESLANGPARSER_H
#include "zypp/source/susetags/PackagesParser.h"
#include "zypp/parser/tagfile/TagFileParser.h"
#include "zypp/Package.h"
-#include "zypp/source/susetags/SuseTagsPackageImpl.h"
#include "zypp/CapFactory.h"
#include "zypp/CapSet.h"
struct PackagesParser : public parser::tagfile::TagFileParser
{
- std::list<Package::Ptr> result;
+ PkgContent result;
Source_Ref _source;
SuseTagsImpl::Ptr _sourceImpl;
- shared_ptr<source::susetags::SuseTagsPackageImpl> pkgImpl;
+ PkgImplPtr pkgImpl;
NVRAD nvrad;
bool pkgPending() const
{
if ( pkgPending() )
{
- result.push_back( detail::makeResolvableFromImpl( nvrad, pkgImpl ) );
+ result[nvrad] = pkgImpl;
}
pkgImpl = nextPkg_r;
}
////////////////////////////////////////////////////////////////////////////
- std::list<Package::Ptr> parsePackages( Source_Ref source_r, SuseTagsImpl::Ptr sourceImpl_r, const Pathname & file_r )
+ PkgContent parsePackages( Source_Ref source_r, SuseTagsImpl::Ptr sourceImpl_r, const Pathname & file_r )
{
PackagesParser p;
p._source = source_r;
#include <iosfwd>
#include <list>
+#include "zypp/base/PtrTypes.h"
#include "zypp/Pathname.h"
#include "zypp/Package.h"
+#include "zypp/NVRAD.h"
#include "zypp/source/susetags/SuseTagsImpl.h"
+#include "zypp/source/susetags/SuseTagsPackageImpl.h"
+
+typedef zypp::shared_ptr<zypp::source::susetags::SuseTagsPackageImpl> PkgImplPtr;
+typedef std::map<zypp::NVRAD, PkgImplPtr> PkgContent;
///////////////////////////////////////////////////////////////////
namespace zypp
/** \deprecated Just temporary.
* \throws ParseException and others.
*/
- std::list<Package::Ptr> parsePackages( Source_Ref source_r, SuseTagsImpl::Ptr, const Pathname & file_r );
+ PkgContent parsePackages( Source_Ref source_r, SuseTagsImpl::Ptr, const Pathname & file_r );
/////////////////////////////////////////////////////////////////
} // namespace susetags
#include "zypp/source/susetags/SuseTagsImpl.h"
#include "zypp/source/susetags/PackagesParser.h"
+#include "zypp/source/susetags/PackagesLangParser.h"
#include "zypp/source/susetags/SelectionTagFileParser.h"
#include "zypp/source/susetags/PatternTagFileParser.h"
#warning We use suse instead of <DATADIR> for now
Pathname p = provideFile(_path + "suse/setup/descr/packages");
DBG << "Going to parse " << p << endl;
- std::list<Package::Ptr> content( parsePackages( source_r, this, p ) );
- _store.insert( content.begin(), content.end() );
+ PkgContent content( parsePackages( source_r, this, p ) );
+#warning Should use correct locale
+ Locale lang;
+ p = provideFile(_path + "suse/setup/descr/packages.en");
+ DBG << "Going to parse " << p << endl;
+ parsePackagesLang( p, lang, content );
+
+ for (PkgContent::const_iterator it = content.begin(); it != content.end(); ++it) {
+ Package::Ptr pkg = detail::makeResolvableFromImpl( it->first, it->second );
+ _store.insert( pkg );
+ }
DBG << "SuseTagsImpl (fake) from " << p << ": "
<< content.size() << " packages" << endl;
SuseTagsPackageImpl::~SuseTagsPackageImpl()
{}
+
+ TranslatedText SuseTagsPackageImpl::summary() const
+ { return _summary; }
+
+ TranslatedText SuseTagsPackageImpl::description() const
+ { return _description; }
+
Date SuseTagsPackageImpl::buildtime() const
{ return Date(); }
/** \name Rpm Package Attributes. */
//@{
+ virtual TranslatedText summary() const;
+ virtual TranslatedText description() const;
+
/** */
virtual Date buildtime() const;
/** */
virtual License licenseToConfirm() const;
+ TranslatedText _summary;
+ TranslatedText _description;
PackageGroup _group;
std::list<std::string> _authors;
std::list<std::string> _keywords;