[paludis-commits] r4074 - trunk/paludis/repositories/cran

ciaranm at svn.pioto.org ciaranm at svn.pioto.org
Fri Dec 14 18:15:32 UTC 2007


Author: ciaranm
Date: 2007-12-14 18:15:21 +0000 (Fri, 14 Dec 2007)
New Revision: 4074

Modified:
   trunk/paludis/repositories/cran/cran_package_id.cc
   trunk/paludis/repositories/cran/keys.cc
   trunk/paludis/repositories/cran/keys.hh
Log:
More CRAN work


Modified: trunk/paludis/repositories/cran/cran_package_id.cc
===================================================================
--- trunk/paludis/repositories/cran/cran_package_id.cc	2007-12-14 13:14:24 UTC (rev 4073)
+++ trunk/paludis/repositories/cran/cran_package_id.cc	2007-12-14 18:15:21 UTC (rev 4074)
@@ -63,9 +63,10 @@
         VersionSpec version;
 
         tr1::shared_ptr<LiteralMetadataFSEntryKey> fs_location_key;
-        tr1::shared_ptr<SimpleURIKey> homepage_key;
+        tr1::shared_ptr<LiteralMetadataStringKey> url_key;
         tr1::shared_ptr<LiteralMetadataStringKey> short_description_key;
         tr1::shared_ptr<LiteralMetadataStringKey> long_description_key;
+        tr1::shared_ptr<LiteralMetadataStringKey> license_key;
         tr1::shared_ptr<PackageIDKey> contained_in_key;
         tr1::shared_ptr<PackageIDSequenceKey> contains_key;
         tr1::shared_ptr<DepKey> depends_key;
@@ -149,11 +150,20 @@
             _imp->version = VersionSpec(cran_version_to_internal(file.get("Version")));
         }
 
+        if (! file.get("License").empty())
+        {
+            /* License often isn't in the format the spec requires, so we can't parse it. */
+            Context local_context("When handling License: key:");
+            _imp->license_key.reset(new LiteralMetadataStringKey("License", "License", mkt_dependencies, file.get("License")));
+            add_metadata_key(_imp->license_key);
+        }
+
         if (! file.get("URL").empty())
         {
+            /* URL is also in stupid formats */
             Context local_context("When handling URL: key:");
-            _imp->homepage_key.reset(new SimpleURIKey("URL", "URL", file.get("URL"), mkt_significant));
-            add_metadata_key(_imp->homepage_key);
+            _imp->url_key.reset(new LiteralMetadataStringKey("URL", "URL", mkt_significant, file.get("URL")));
+            add_metadata_key(_imp->url_key);
         }
 
         if (! file.get("Title").empty())
@@ -176,16 +186,23 @@
                         mkt_normal, file.get("BundleDescription")));
         }
 
+        if (! file.get("Date").empty())
+        {
+            Context local_context("When handling Date: key:");
+            /* no guarantee on the format */
+            add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("Date", "Date", mkt_normal, file.get("Date"))));
+        }
+
         if (! file.get("Author").empty())
         {
             Context local_context("When handling Author: key:");
-            add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("Author", "Author", mkt_normal, file.get("Author"))));
+            add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("Author", "Author", mkt_author, file.get("Author"))));
         }
 
         if (! file.get("Maintainer").empty())
         {
             Context local_context("When handling Maintainer: key:");
-            add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("Maintainer", "Maintainer", mkt_normal, file.get("Maintainer"))));
+            add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("Maintainer", "Maintainer", mkt_author, file.get("Maintainer"))));
         }
 
         if (! file.get("Contains").empty())
@@ -216,6 +233,13 @@
             add_metadata_key(_imp->suggests_key);
         }
 
+        if (! file.get("SystemRequirements").empty())
+        {
+            Context local_context("When handling SystemRequirements: key:");
+            add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("SystemRequirements", "System Requirements", mkt_normal,
+                            file.get("SystemRequirements"))));
+        }
+
         if (! file.get("Depends").empty())
         {
             Context local_context("When handling Depends: key:");
@@ -231,37 +255,6 @@
             << e.message() << "' (" << e.what() << ")";
         add_mask(make_shared_ptr(new BrokenMask('B', "Broken", "Got exception '" + stringify(e.message()) + "' (" + e.what() + "')")));
     }
-
-#if 0
-    for (cranrepository::DescriptionFile::Iterator i(file.begin()), i_end(file.end()) ;
-            i != i_end ; ++i)
-    {
-        if (("Package" == key) || ("Bundle" == key))
-        {
-            metadata->set_homepage("http://cran.r-project.org/src/contrib/Descriptions/" + value + ".html");
-            if ("Package" == key)
-            {
-                CRANDescription::normalise_name(value);
-                if (n != value)
-                    Log::get_instance()->message(ll_warning, lc_context) << "Inconsistent package name in file '" <<
-                        f << "': '" << value << "'";
-            }
-            else
-                metadata->cran_interface->is_bundle = true;
-        }
-        else if ("Depends" == key)
-        {
-            if (value.empty())
-                value = "R";
-            else
-                value.append(", R");
-            metadata->deps_interface->set_build_depend(value);
-            metadata->deps_interface->set_run_depend(value);
-        }
-        else if ("Suggests" == key)
-            metadata->deps_interface->set_suggested_depend(value);
-    }
-#endif
 }
 
 CRANPackageID::CRANPackageID(const Environment * const e,
@@ -370,7 +363,7 @@
 const tr1::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> >
 CRANPackageID::homepage_key() const
 {
-    return _imp->homepage_key;
+    return tr1::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> >();
 }
 
 const tr1::shared_ptr<const MetadataStringKey>

Modified: trunk/paludis/repositories/cran/keys.cc
===================================================================
--- trunk/paludis/repositories/cran/keys.cc	2007-12-14 13:14:24 UTC (rev 4073)
+++ trunk/paludis/repositories/cran/keys.cc	2007-12-14 18:15:21 UTC (rev 4074)
@@ -35,30 +35,6 @@
 using namespace paludis;
 using namespace paludis::cranrepository;
 
-SimpleURIKey::SimpleURIKey(const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
-    MetadataSpecTreeKey<SimpleURISpecTree>(r, h, t),
-    _v(v)
-{
-}
-
-const tr1::shared_ptr<const SimpleURISpecTree::ConstItem>
-SimpleURIKey::value() const
-{
-    return make_shared_ptr(new TreeLeaf<SimpleURISpecTree, SimpleURIDepSpec>(make_shared_ptr(new SimpleURIDepSpec(_v))));
-}
-
-std::string
-SimpleURIKey::pretty_print(const SimpleURISpecTree::ItemFormatter & f) const
-{
-    return f.format(_v, format::Plain());
-}
-
-std::string
-SimpleURIKey::pretty_print_flat(const SimpleURISpecTree::ItemFormatter & f) const
-{
-    return f.format(_v, format::Plain());
-}
-
 PackageIDSequenceKey::PackageIDSequenceKey(const Environment * const e,
         const std::string & r, const std::string & h, const MetadataKeyType t) :
     MetadataCollectionKey<PackageIDSequence>(r, h, t),
@@ -102,31 +78,54 @@
     return _v->shared_from_this();
 }
 
+namespace paludis
+{
+    template <>
+    struct Implementation<DepKey>
+    {
+        const Environment * const env;
+        const std::string v;
+
+        mutable Mutex mutex;
+        mutable tr1::shared_ptr<const DependencySpecTree::ConstItem> c;
+
+        Implementation(const Environment * const e, const std::string & vv) :
+            env(e),
+            v(vv)
+        {
+        }
+    };
+}
+
 DepKey::DepKey(const Environment * const e, const std::string & r, const std::string & h, const std::string & v,
         const MetadataKeyType t) :
     MetadataSpecTreeKey<DependencySpecTree>(r, h, t),
-    _env(e),
-    _v(v)
+    PrivateImplementationPattern<DepKey>(new Implementation<DepKey>(e, v)),
+    _imp(PrivateImplementationPattern<DepKey>::_imp)
 {
 }
 
+DepKey::~DepKey()
+{
+}
+
 const tr1::shared_ptr<const DependencySpecTree::ConstItem>
 DepKey::value() const
 {
-    Lock l(_m);
-    if (_c)
-        return _c;
+    Lock l(_imp->mutex);
+    if (_imp->c)
+        return _imp->c;
 
     Context context("When parsing CRAN dependency string:");
-    _c = parse_depends(_v);
-    return _c;
+    _imp->c = parse_depends(_imp->v);
+    return _imp->c;
 }
 
 std::string
 DepKey::pretty_print(const DependencySpecTree::ItemFormatter & f) const
 {
     StringifyFormatter ff(f);
-    DepSpecPrettyPrinter p(_env, ff, 12, true);
+    DepSpecPrettyPrinter p(_imp->env, ff, 12, true);
     value()->accept(p);
     return stringify(p);
 }
@@ -135,7 +134,7 @@
 DepKey::pretty_print_flat(const DependencySpecTree::ItemFormatter & f) const
 {
     StringifyFormatter ff(f);
-    DepSpecPrettyPrinter p(_env, ff, 0, false);
+    DepSpecPrettyPrinter p(_imp->env, ff, 0, false);
     value()->accept(p);
     return stringify(p);
 }

Modified: trunk/paludis/repositories/cran/keys.hh
===================================================================
--- trunk/paludis/repositories/cran/keys.hh	2007-12-14 13:14:24 UTC (rev 4073)
+++ trunk/paludis/repositories/cran/keys.hh	2007-12-14 18:15:21 UTC (rev 4074)
@@ -31,25 +31,6 @@
     {
         class CRANPackageID;
 
-        class SimpleURIKey :
-            public MetadataSpecTreeKey<SimpleURISpecTree>
-        {
-            private:
-                const std::string _v;
-
-            public:
-                SimpleURIKey(const std::string &, const std::string &, const std::string &, const MetadataKeyType);
-
-                virtual const tr1::shared_ptr<const SimpleURISpecTree::ConstItem> value() const
-                    PALUDIS_ATTRIBUTE((warn_unused_result));
-
-                virtual std::string pretty_print(const SimpleURISpecTree::ItemFormatter &) const
-                    PALUDIS_ATTRIBUTE((warn_unused_result));
-
-                virtual std::string pretty_print_flat(const SimpleURISpecTree::ItemFormatter &) const
-                    PALUDIS_ATTRIBUTE((warn_unused_result));
-        };
-
         class PackageIDSequenceKey :
             public MetadataCollectionKey<PackageIDSequence>
         {
@@ -84,18 +65,18 @@
         };
 
         class DepKey :
-            public MetadataSpecTreeKey<DependencySpecTree>
+            public MetadataSpecTreeKey<DependencySpecTree>,
+            private PrivateImplementationPattern<DepKey>
         {
             private:
-                const Environment * const _env;
-                mutable Mutex _m;
-                mutable tr1::shared_ptr<DependencySpecTree::ConstItem> _c;
-                const std::string _v;
+                PrivateImplementationPattern<DepKey>::ImpPtr & _imp;
 
             public:
                 DepKey(const Environment * const,
                         const std::string &, const std::string &, const std::string &, const MetadataKeyType);
 
+                ~DepKey();
+
                 virtual const tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const
                     PALUDIS_ATTRIBUTE((warn_unused_result));
 



More information about the paludis-commits mailing list