Coverage for /home/runner/work/viur-core/viur-core/viur/src/viur/core/bones/sortindex.py: 86%

7 statements  

« prev     ^ index     » next       coverage.py v7.6.3, created at 2024-10-16 22:16 +0000

1import typing as t 

2import time 

3from viur.core.bones.numeric import NumericBone 

4 

5 

6class SortIndexBone(NumericBone): 

7 """ 

8 The SortIndexBone class is specifically designed to handle sorting indexes for data elements, which are 

9 numeric values that determine the order of these elements. It inherits from the NumericBone. 

10 

11 :param int | float defaultValue: A default value for the bone, which is a function that returns 

12 the current time by default. This parameter accepts either an integer or a floating-point number. 

13 :param str descr: A short description of the bone, set to "SortIndex" by default. 

14 :param int precision: The precision of the numeric value, determining the number of decimal places allowed. 

15 The default value is 8. 

16 :param dict kwargs: Additional keyword arguments that can be passed to the parent NumericBone class. 

17 """ 

18 type = "numeric.sortindex" 

19 

20 def __init__( 

21 self, 

22 *, 

23 defaultValue: int | float = lambda *args, **kwargs: time.time(), 

24 descr: str = "SortIndex", 

25 precision: int = 8, 

26 **kwargs 

27 ): 

28 super().__init__( 

29 defaultValue=defaultValue, 

30 descr=descr, 

31 precision=precision, 

32 **kwargs 

33 )