basic.py 654 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright Microsoft Open Technologies, Inc. This file was adapted from RxPY
  2. # (https://github.com/ReactiveX/RxPY). Licensed under the Apache 2.0 License.
  3. from datetime import datetime
  4. # Defaults
  5. def noop(*args, **kw):
  6. """No operation. Returns nothing"""
  7. pass
  8. def identity(x):
  9. """Returns argument x"""
  10. return x
  11. def default_now():
  12. return datetime.utcnow()
  13. def default_comparer(x, y):
  14. return x == y
  15. def default_sub_comparer(x, y):
  16. return x - y
  17. def default_key_serializer(x):
  18. return str(x)
  19. def default_error(err):
  20. if isinstance(err, BaseException):
  21. raise err
  22. else:
  23. raise Exception(err)