yawning_titan.db.query#

The query module provides a Yawning-Titan extension to tinydb.queries.Query.

Classes

class yawning_titan.db.query.YawningTitanQuery[source]#

The YawningTitanQuery class extends tinydb.queries.Query.

Extended to provide common pre-defined test functions that call tinydb.queries.Query.test(), rather than forcing the user to build a function/lambda function each time and pass it to test.

__init__()[source]#
len_eq(i)[source]#

Tests the length of a field. This could be the length of a string or an array field.

Fields whose length matches i are returned in the search.

Example:

>>> from yawning_titan.networks.network_db import NetworkDB
>>> from yawning_titan.db.query import YawningTitanQuery
>>> db = NetworkDB()
>>> db.search(YawningTitanQuery.matrix.len_eq(18)))
Parameters:

i – The target length of a field as an int.

Returns:

True if the field length matches i, otherwise False.

Raises:

TypeError – When the field len_eq() is called on does not have a len() function.

len_lt(i)[source]#

Tests the length of a field. This could be the length of a string or an array field.

Fields whose length is less than i are returned in the search.

Example:

>>> from yawning_titan.networks.network_db import NetworkDB
>>> from yawning_titan.db.query import YawningTitanQuery
>>> db = NetworkDB()
>>> db.search(YawningTitanQuery.matrix.len_lt(18)))
Parameters:

i – The target length of a field as an int.

Returns:

True if the field length is less than i, otherwise False.

Raises:

TypeError – When the field len_lt() is called on does not have a len() function.

len_le(i)[source]#

Tests the length of a field. This could be the length of a string or an array field.

Fields whose length is less than or equal to i are returned in the search.

Example:

>>> from yawning_titan.networks.network_db import NetworkDB
>>> from yawning_titan.db.query import YawningTitanQuery
>>> db = NetworkDB()
>>> db.search(YawningTitanQuery.matrix.len_le(18)))
Parameters:

i – The target length of a field as an int.

Returns:

True if the field length is less than or equal to i, otherwise False.

Raises:

TypeError – When the field len_lt() is called on does not have a len() function.

len_gt(i)[source]#

Tests the length of a field. This could be the length of a string or an array field.

Fields whose length is greater than i are returned in the search.

Example:

>>> from yawning_titan.networks.network_db import NetworkDB
>>> from yawning_titan.db.query import YawningTitanQuery
>>> db = NetworkDB()
>>> db.search(YawningTitanQuery.matrix.len_gt(18)))
Parameters:

i – The target length of a field as an int.

Returns:

True if the field length is greater than i, otherwise False.

Raises:

TypeError – When the field len_lt() is called on does not have a len() function.

len_ge(i)[source]#

Tests the length of a field. This could be the length of a string or an array field.

Fields whose length is greater than or equal to i are returned in the search.

Example:

>>> from yawning_titan.networks.network_db import NetworkDB
>>> from yawning_titan.db.query import YawningTitanQuery
>>> db = NetworkDB()
>>> db.search(YawningTitanQuery.matrix.len_ge(18)))
Parameters:

i – The target length of a field as an int.

Returns:

True if it does exist, otherwise False. if the field length is greater than or equal to i, otherwise False.

Raises:

TypeError – When the field len_lt() is called on does not have a len() function.

len_bt(i, j)[source]#

Tests the length of a field. This could be the length of a string or an array field.

Fields whose length is greater than or equal to i are returned in the search.

Example:

>>> from yawning_titan.networks.network_db import NetworkDB
>>> from yawning_titan.db.query import YawningTitanQuery
>>> db = NetworkDB()
>>> db.search(YawningTitanQuery.matrix.len_bt(1,18)))
Parameters:
  • i – The minimum length of a field as an int.

  • j – The maximum length of a field as an int.

Returns:

True if it does exist, otherwise False. if the field length is greater than or equal to i and less than or equal to j, otherwise False.

Raises:

TypeError – When the field len_bt() is called on does not have a len() function.

bt(i, j)[source]#

Tests the value of a field. This could be the value of a string or an array field.

Fields whose value is greater than or equal to i are returned in the search.

Example:

>>> from yawning_titan.networks.network_db import NetworkDB
>>> from yawning_titan.db.query import YawningTitanQuery
>>> db = NetworkDB()
>>> db.search(YawningTitanQuery.matrix.len_bt(1,18)))
Parameters:
  • i – The minimum value of a field as an int.

  • j – The maximum value of a field as an int.

Returns:

True if it does exist, otherwise False. if the field value is greater than or equal to i and less than or equal to j, otherwise False.

Raises:

TypeError – When the field len_bt() is called on does not have a len() function.