Skip to content
Snippets Groups Projects

ENH: add new member function filter to Container class

Merged Henrik tom Wörden requested to merge f-filter-container into dev
Files
2
@@ -78,7 +78,7 @@ Examples
Finding parents and properties
--------
------------------------------
To find a specific parent or property of an Entity, its
ParentList or PropertyList can be filtered using names, ids, or
entities. A short example:
@@ -100,7+100,7 @@
properties = r.properties
# As r only has one property with id 101, this returns a list containing only p1_1
properties.filter(pid=101)
# Result: [p1_1]
# Filtering with name="Property 1" returns both p1_1 and p1_2, as they share their name
properties.filter(name="Property 1")
# Result: [p1_1, p1_2]
# If both name and pid are given, matching is based only on pid for all entities that have an id
properties.filter(pid="102", name="Other Property")
# Result: [p2_1, p2_2, p2_3]
@@ -126,7+126,7 @@
# Result: [p2_1]
The filter function of ParentList works analogously.
Finding entities in a Container
-------------------------------
In the same way as described above, Container can be filtered.
A short example:
.. code-block:: python3
import linkahead as db
# Setup a record with six properties
p1 = db.Property(id=101, name="Property 1")
p2 = db.Property(name="Property 2")
c = db.Container().extend([p1,p2])
c.filter(name="Property 1")
# Result: [p1]
Loading