Core: Floor and ceil in datastorage (#2448)
This commit is contained in:
parent
d892622ab1
commit
530e792c3c
|
@ -10,6 +10,7 @@ import hashlib
|
|||
import inspect
|
||||
import itertools
|
||||
import logging
|
||||
import math
|
||||
import operator
|
||||
import pickle
|
||||
import random
|
||||
|
@ -67,21 +68,25 @@ def update_dict(dictionary, entries):
|
|||
|
||||
# functions callable on storable data on the server by clients
|
||||
modify_functions = {
|
||||
"add": operator.add, # add together two objects, using python's "+" operator (works on strings and lists as append)
|
||||
"mul": operator.mul,
|
||||
"mod": operator.mod,
|
||||
"max": max,
|
||||
"min": min,
|
||||
# generic:
|
||||
"replace": lambda old, new: new,
|
||||
"default": lambda old, new: old,
|
||||
# numeric:
|
||||
"add": operator.add, # add together two objects, using python's "+" operator (works on strings and lists as append)
|
||||
"mul": operator.mul,
|
||||
"pow": operator.pow,
|
||||
"mod": operator.mod,
|
||||
"floor": lambda value, _: math.floor(value),
|
||||
"ceil": lambda value, _: math.ceil(value),
|
||||
"max": max,
|
||||
"min": min,
|
||||
# bitwise:
|
||||
"xor": operator.xor,
|
||||
"or": operator.or_,
|
||||
"and": operator.and_,
|
||||
"left_shift": operator.lshift,
|
||||
"right_shift": operator.rshift,
|
||||
# lists/dicts
|
||||
# lists/dicts:
|
||||
"remove": remove_from_list,
|
||||
"pop": pop_from_container,
|
||||
"update": update_dict,
|
||||
|
|
|
@ -415,6 +415,8 @@ The following operations can be applied to a datastorage key
|
|||
| mul | Multiplies the current value of the key by `value`. |
|
||||
| pow | Multiplies the current value of the key to the power of `value`. |
|
||||
| mod | Sets the current value of the key to the remainder after division by `value`. |
|
||||
| floor | Floors the current value (`value` is ignored). |
|
||||
| ceil | Ceils the current value (`value` is ignored). |
|
||||
| max | Sets the current value of the key to `value` if `value` is bigger. |
|
||||
| min | Sets the current value of the key to `value` if `value` is lower. |
|
||||
| and | Applies a bitwise AND to the current value of the key with `value`. |
|
||||
|
|
Loading…
Reference in New Issue