[entropy.db] introduce retrieveContentIter()
This commit is contained in:
@@ -3413,6 +3413,35 @@ class EntropyRepository(EntropyRepositoryBase):
|
||||
|
||||
return fl
|
||||
|
||||
def retrieveContentIter(self, package_id, order_by = None):
|
||||
"""
|
||||
Reimplemented from EntropyRepositoryBase.
|
||||
"""
|
||||
class MyIter:
|
||||
|
||||
def __init__(self, _cur):
|
||||
self._cur = cur
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def next(self):
|
||||
return self._cur.next()
|
||||
|
||||
searchkeywords = (package_id,)
|
||||
order_by_string = ''
|
||||
if order_by is not None:
|
||||
if order_by not in ("package_id", "idpackage", "file", "type",):
|
||||
raise AttributeError("invalid order_by argument")
|
||||
if order_by == "package_id":
|
||||
order_by = "idpackage"
|
||||
order_by_string = ' order by %s' % (order_by,)
|
||||
|
||||
cur = self._cursor().execute("""
|
||||
SELECT file, type FROM content WHERE idpackage = (?) %s""" % (
|
||||
order_by_string,), searchkeywords)
|
||||
return MyIter(cur)
|
||||
|
||||
def retrieveContentSafety(self, package_id):
|
||||
"""
|
||||
Reimplemented from EntropyRepositoryBase.
|
||||
|
||||
@@ -2751,6 +2751,24 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore):
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def retrieveContentIter(self, package_id, order_by = None):
|
||||
"""
|
||||
Return an iterator that makes possible to retrieve the files
|
||||
contained in given package. Please note that the iterator returned
|
||||
will fail if the EntropyRepository object is closed (call to close()).
|
||||
The iterator may thus become invalid.
|
||||
|
||||
@param package_id: package indentifier
|
||||
@type package_id: int
|
||||
@keyword order_by: order by string, valid values are:
|
||||
"type" (if extended is True), "file" or "package_id"
|
||||
@type order_by: string
|
||||
@return: content metadata
|
||||
@rtype: iterator
|
||||
@raise AttributeError: if order_by value is invalid
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def retrieveContentSafety(self, package_id):
|
||||
"""
|
||||
Return supported content safety metadata for given package.
|
||||
|
||||
Reference in New Issue
Block a user