provide Product resolvable for susetags source
authorStanislav Visnovsky <visnov@suse.cz>
Mon, 13 Feb 2006 17:25:48 +0000 (17:25 +0000)
committerStanislav Visnovsky <visnov@suse.cz>
Mon, 13 Feb 2006 17:25:48 +0000 (17:25 +0000)
zypp/source/susetags/ProductMetadataParser.cc
zypp/source/susetags/ProductMetadataParser.h
zypp/source/susetags/SuseTagsImpl.cc

index 4b0be26..3e27788 100644 (file)
@@ -53,7 +53,7 @@ namespace zypp
       //       METHOD NAME : Parser::parse
       //       METHOD TYPE : void
       //
-      void ProductMetadataParser::parse( const Pathname & file_r )
+      void ProductMetadataParser::parse( const Pathname & file_r, Source_Ref source_r )
       {
         std::ifstream file(file_r.asString().c_str());
 
@@ -146,6 +146,8 @@ namespace zypp
           ERR << excpt_r << endl;
           throw "Cannot create product object";
         }
+       
+       prodImpl->_source = source_r;
       }
 
       void ProductMetadataParser::parseLine( const string &key, const string &modif, const string &value, map< string, list<string> > &container)
@@ -177,10 +179,10 @@ namespace zypp
           str::split( value, std::back_inserter(container), " ");
       }
 
-      Product::Ptr parseContentFile( const Pathname & file_r )
+      Product::Ptr parseContentFile( const Pathname & file_r, Source_Ref source_r )
       {
         ProductMetadataParser p;
-        p.parse( file_r );
+        p.parse( file_r, source_r );
         return p.result;
       }
       /////////////////////////////////////////////////////////////////
index fd13e29..975add5 100644 (file)
@@ -36,7 +36,7 @@ namespace zypp
        * Please access the parser using this method.
        * Returns a product from a content file \a file_r
        */
-      Product::Ptr parseContentFile( const Pathname & file_r );
+      Product::Ptr parseContentFile( const Pathname & file_r, Source_Ref source_r );
   
       ///////////////////////////////////////////////////////////////////
       //
@@ -55,7 +55,7 @@ namespace zypp
          * \throw ParseException
          * \todo more doc on Ecaptions.
         */
-        void parse( const Pathname & file_r);
+        void parse( const Pathname & file_r, Source_Ref source_r);
         /* Parse a key.modifier (std::list of std::strings)
          * That means, translatable tag with multiple values
          * the default modifier will get the modifier of default (LABEL.de, LABEL as LANGUAGE.default)
index e96d97e..ded0296 100644 (file)
@@ -21,6 +21,7 @@
 #include "zypp/source/susetags/PackagesLangParser.h"
 #include "zypp/source/susetags/SelectionTagFileParser.h"
 #include "zypp/source/susetags/PatternTagFileParser.h"
+#include "zypp/source/susetags/ProductMetadataParser.h"
 
 #include "zypp/SourceFactory.h"
 #include "zypp/ZYppCallbacks.h"
@@ -110,8 +111,24 @@ namespace zypp
        
        report->startData( url() );
        
+        Pathname p = provideFile(_path + "content");
+
+       SourceFactory factory;
+
+       try {
+           DBG << "Going to parse content file " << p << endl;
+           
+           Product::Ptr product = parseContentFile( p, factory.createFrom(this) );
+
+           MIL << "Product: " << product->displayName() << endl;
+           _store.insert( product );
+       }
+       catch (Exception & excpt_r) {
+           ERR << "cannot parse content file" << endl;
+       }
+       
 #warning We use suse instead of <DATADIR> for now
-        Pathname p = provideFile(_path + "suse/setup/descr/packages");
+        p = provideFile(_path + "suse/setup/descr/packages");
         DBG << "Going to parse " << p << endl;
         PkgContent content( parsePackages( source_r, this, p ) );