aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-16 08:23:00 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-16 08:23:00 +0000
commitdc95c2f26ea490fce48575cd19b995d2b34297cf (patch)
treeecf718069b33a1ca5b0ba586ba3bd7f7bdfc09e4 /python
parent7385570bea9b9d1954edf7a824fa61bd42c371e8 (diff)
downloadpaludis-dc95c2f26ea490fce48575cd19b995d2b34297cf.tar.gz
paludis-dc95c2f26ea490fce48575cd19b995d2b34297cf.tar.xz
Replace RepositoryInfo with emtadata keys. Change how we handle ambiguous _imp. Introduce common Literal metadata key classes to reduce duplicated code. Fixes: ticket:438. Fixes: ticket:416
Diffstat (limited to 'python')
-rwxr-xr-xpython/mask_TEST.py6
-rw-r--r--python/metadata_key.cc6
-rw-r--r--python/repository.cc79
-rwxr-xr-xpython/repository_TEST.py24
4 files changed, 8 insertions, 107 deletions
diff --git a/python/mask_TEST.py b/python/mask_TEST.py
index 1a079bfff..fdc65752b 100755
--- a/python/mask_TEST.py
+++ b/python/mask_TEST.py
@@ -68,11 +68,7 @@ class TestCase_01_Masks(unittest.TestCase):
self.assertEquals(m.key(), "R")
self.assertEquals(m.description(), "repository")
- for section in self.db.fetch_repository("testrepo").info(False).sections:
- for k, v in section.kvs:
- if k == "location":
- location = v
- package_mask_path = os.path.join(location, "profiles/package.mask")
+ package_mask_path = os.path.join(os.getcwd(), "mask_TEST_dir/testrepo/profiles/package.mask")
self.assertEquals(m.mask_key().value().mask_file, package_mask_path)
self.assert_(isinstance(m.mask_key().value().comment, StringIterable))
diff --git a/python/metadata_key.cc b/python/metadata_key.cc
index b5e866d2d..59a786978 100644
--- a/python/metadata_key.cc
+++ b/python/metadata_key.cc
@@ -99,6 +99,11 @@ class MetadataKeySptrToPythonVisitor :
obj = bp::object(tr1::static_pointer_cast<const MetadataSetKey<Set<std::string> > >(_m_ptr));
}
+ void visit(const MetadataSetKey<FSEntrySequence> & k)
+ {
+ obj = bp::object(tr1::static_pointer_cast<const MetadataSetKey<FSEntrySequence> >(_m_ptr));
+ }
+
void visit(const MetadataSpecTreeKey<LicenseSpecTree> & k)
{
obj = bp::object(tr1::static_pointer_cast<const MetadataSpecTreeKey<LicenseSpecTree> >(_m_ptr));
@@ -918,6 +923,7 @@ void expose_metadata_key()
class_set_key<UseFlagNameSet>("UseFlagNameIterable");
class_set_key<IUseFlagSet>("IUseFlagIterable");
class_set_key<Set<std::string> >("StringIterable");
+ class_set_key<FSEntrySequence>("FSEntryIterable");
/**
* MetadataSpecTreeKeys
diff --git a/python/repository.cc b/python/repository.cc
index adcfbe9cf..f6f98e474 100644
--- a/python/repository.cc
+++ b/python/repository.cc
@@ -21,7 +21,6 @@
#include <python/iterable.hh>
#include <paludis/repository.hh>
-#include <paludis/repository_info.hh>
#include <paludis/repositories/e/e_repository.hh>
#include <paludis/repositories/fake/fake_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
@@ -40,20 +39,6 @@ struct RepositoryWrapper :
Repository,
bp::wrapper<Repository>
{
- tr1::shared_ptr<const RepositoryInfo>
- info(bool verbose) const
- {
- if (bp::override info = this->get_override("info"))
- return info(verbose);
- return Repository::info(verbose);
- }
-
- tr1::shared_ptr<const RepositoryInfo>
- default_info(bool verbose) const
- {
- return Repository::info(verbose);
- }
-
static RepositorySetsInterface *
get_sets_interface(const Repository & self)
{
@@ -179,44 +164,6 @@ void expose_repository()
);
/**
- * RepositoryInfoSection
- */
- bp::to_python_converter<std::pair<const std::string, std::string>,
- pair_to_tuple<const std::string, std::string> >();
- register_shared_ptrs_to_python<RepositoryInfoSection>();
- bp::class_<RepositoryInfoSection, boost::noncopyable>
- (
- "RepositoryInfoSection",
- "A section of information about a Repository.",
- bp::init<const std::string &>()
- )
- .add_property("heading", &RepositoryInfoSection::heading,
- "[ro] string\n"
- "Heading."
- )
-
- .add_property("kvs", bp::range(&RepositoryInfoSection::begin_kvs, &RepositoryInfoSection::end_kvs),
- "[ro] Iterable of tuples\n"
- "Key-value pairs."
- )
- ;
-
- /**
- * RepositoryInfo
- */
- register_shared_ptrs_to_python<RepositoryInfo>();
- bp::class_<RepositoryInfo, boost::noncopyable>
- (
- "RepositoryInfo",
- "Information about a Repository, for the end user.",
- bp::no_init
- )
- .add_property("sections", bp::range(&RepositoryInfo::begin_sections, &RepositoryInfo::end_sections),
- "[ro] Iterable of RepositoryInfoSection."
- )
- ;
-
- /**
* Repository
*/
register_shared_ptrs_to_python<Repository>(rsp_const);
@@ -226,22 +173,12 @@ void expose_repository()
"A Repository provides a representation of a physical repository to a PackageDatabase.",
bp::no_init
)
- .def("info", &Repository::info, &RepositoryWrapper::default_info,
- "info() -> RepositoryInfo\n"
- "Fetch information about the repository."
- )
- .add_property("name", bp::make_function(&Repository::name,
- bp::return_value_policy<bp::copy_const_reference>()),
+ .add_property("name", &Repository::name,
"[ro] RepositoryName\n"
"Our name."
)
- .add_property("format", &Repository::format,
- "[ro] string\n"
- "Our format."
- )
-
.def("has_category_named", &Repository::has_category_named,
"has_category_named(CategoryNamePart) -> bool\n"
"Do we have a category with the given name?"
@@ -382,20 +319,6 @@ void expose_repository()
;
/**
- * RepositoryInstalledInterface
- */
- bp::class_<RepositoryInstalledInterface, boost::noncopyable>
- (
- "RepositoryInstalledInterface",
- "Interface for handling actions for installed repositories.",
- bp::no_init
- )
- .def("root", bp::pure_virtual(&RepositoryInstalledInterface::root),
- "What is our filesystem root?"
- )
- ;
-
- /**
* RepositorySetsInterface
*/
bp::class_<RepositorySetsInterface, boost::noncopyable>
diff --git a/python/repository_TEST.py b/python/repository_TEST.py
index e6144a675..ed4d68ce9 100755
--- a/python/repository_TEST.py
+++ b/python/repository_TEST.py
@@ -52,10 +52,6 @@ class TestCase_01_Repository(unittest.TestCase):
self.assertEquals(str(repo.name), "testrepo")
self.assertEquals(str(irepo.name), "installed")
- def test_04_format(self):
- self.assertEquals(str(repo.format), "ebuild")
- self.assertEquals(str(irepo.format), "vdb")
-
def test_05_has_category_named(self):
self.assert_(repo.has_category_named("foo"))
self.assert_(not repo.has_category_named("bar"))
@@ -83,26 +79,6 @@ class TestCase_01_Repository(unittest.TestCase):
self.assertEquals(i, 0)
self.assertEquals(str(qpn), "foo/bar")
- def test_11_repository_info(self):
- self.assert_(isinstance(repo.info(True), RepositoryInfo))
- self.assert_(isinstance(repo.info(False), RepositoryInfo))
-
- for (i, section) in enumerate(repo.info(False).sections):
- self.assert_(isinstance(section, RepositoryInfoSection))
- if i == 0:
- self.assertEquals(section.heading, "Configuration information")
- for (k, v) in section.kvs:
- if k == "format":
- self.assertEquals(v, "ebuild")
-
- for (i, section) in enumerate(irepo.info(False).sections):
- self.assert_(isinstance(section, RepositoryInfoSection))
- if i == 0:
- self.assertEquals(section.heading, "Configuration information")
- for (k, v) in section.kvs:
- if k == "format":
- self.assertEquals(v, "vdb")
-
class TestCase_02_RepositoryInterfaces(unittest.TestCase):
def setUp(self):
global e, nce, db, repo, irepo