Dont throw on unknown yum resource type.
authorMichael Andres <ma@suse.de>
Fri, 9 Nov 2007 10:18:04 +0000 (10:18 +0000)
committerMichael Andres <ma@suse.de>
Fri, 9 Nov 2007 10:18:04 +0000 (10:18 +0000)
zypp/parser/yum/RepoParser.cc
zypp/repo/yum/ResourceType.cc
zypp/repo/yum/ResourceType.h

index 4a1ebfe..d7d0616 100644 (file)
@@ -7,7 +7,7 @@
 |                                                                      |
 \---------------------------------------------------------------------*/
 /** \file zypp/parser/yum/RepoParser.cc
- * YUM repository metadata parser implementation. 
+ * YUM repository metadata parser implementation.
  */
 #include <iostream>
 
@@ -103,7 +103,7 @@ namespace zypp
      *
      * \param package_r pointer to package data
      */
-    bool primary_CB(const data::Packagebase_Ptr & package_r); 
+    bool primary_CB(const data::Packagebase_Ptr & package_r);
 
     /**
      * Callback for processing data returned from \ref PatchesFileReader.
@@ -322,7 +322,7 @@ namespace zypp
      MIL << "Total files size: " << totalsize << endl;
     _ticks.range(totalsize);
     _ticks.toMin();
-    
+
     doJobs(cache_dir);
 
     _ticks.toMax();
@@ -338,10 +338,10 @@ namespace zypp
       RepoParserJob job = *it;
       // FIXME better way to do progress here?
       int jobsize = PathInfo(cache_dir + job.filename()).size();
-    
-      MIL << "going to parse " << job.type() << " file " 
+
+      MIL << "going to parse " << job.type() << " file "
           << job.filename() << " (" << jobsize << " bytes)" << endl;
-      
+
       switch(job.type().toEnum())
       {
         // parse primary.xml.gz
@@ -431,7 +431,7 @@ namespace zypp
           break;
         }
 
-        case ResourceType::PRODUCTS_e:
+        case ResourceType::PRODUCT_e:
         {
           ProductFileReader(
             cache_dir + job.filename(),
index 59300c0..f765118 100644 (file)
@@ -22,6 +22,7 @@ namespace zypp
 
   static std::map<std::string,ResourceType::Type> _table;
 
+  const ResourceType ResourceType::NONE(ResourceType::NONE_e);
   const ResourceType ResourceType::REPOMD(ResourceType::REPOMD_e);
   const ResourceType ResourceType::PRIMARY(ResourceType::PRIMARY_e);
   const ResourceType ResourceType::OTHER(ResourceType::OTHER_e);
@@ -29,7 +30,7 @@ namespace zypp
   const ResourceType ResourceType::GROUP(ResourceType::GROUP_e);
   const ResourceType ResourceType::PATCHES(ResourceType::PATCHES_e);
   const ResourceType ResourceType::PATCH(ResourceType::PATCH_e);
-  const ResourceType ResourceType::PRODUCTS(ResourceType::PRODUCTS_e);
+  const ResourceType ResourceType::PRODUCT(ResourceType::PRODUCT_e);
   const ResourceType ResourceType::PATTERNS(ResourceType::PATTERNS_e);
 
 
@@ -49,7 +50,7 @@ namespace zypp
       _table["group"] = ResourceType::GROUP_e;
       _table["patches"] = ResourceType::PATCHES_e;
       _table["patch"] = ResourceType::PATCH_e;
-      _table["products"] = ResourceType::PRODUCTS_e;
+      _table["product"] = ResourceType::PRODUCT_e;
       _table["patterns"] = ResourceType::PATTERNS_e;
       _table["NONE"] = _table["none"] = ResourceType::NONE_e;
     }
@@ -58,8 +59,7 @@ namespace zypp
       = _table.find(strval_r);
     if (it == _table.end())
     {
-      ZYPP_THROW(Exception(
-        "ResourceType parse: illegal string value '" + strval_r + "'"));
+      return ResourceType::NONE_e;
     }
     return it->second;
   }
@@ -78,7 +78,7 @@ namespace zypp
       _table[GROUP_e]   = "group";
       _table[PATCHES_e]   = "patches";
       _table[PATCH_e]  = "patch";
-      _table[PRODUCTS_e]  = "products";
+      _table[PRODUCT_e]  = "product";
       _table[PATTERNS_e]  = "patterns";
       _table[NONE_e] = "NONE";
     }
index 426478e..aa45e55 100644 (file)
@@ -22,10 +22,11 @@ namespace zypp
 
 
   /**
-   * 
+   *
    */
   struct ResourceType
   {
+    static const ResourceType NONE; // unknown
     static const ResourceType REPOMD;
     static const ResourceType PRIMARY;
     static const ResourceType OTHER;
@@ -55,7 +56,7 @@ namespace zypp
     explicit ResourceType(const std::string & strval_r);
 
     Type toEnum() const { return _type; }
-    
+
     ResourceType::Type parse(const std::string & strval_r);
 
     const std::string & asString() const;