prompts.py 714 B

1234567891011121314151617181920212223242526
  1. # -*- coding: utf-8 -*-
  2. """Being removed
  3. """
  4. from IPython.utils import py3compat
  5. class LazyEvaluate(object):
  6. """This is used for formatting strings with values that need to be updated
  7. at that time, such as the current time or working directory."""
  8. def __init__(self, func, *args, **kwargs):
  9. self.func = func
  10. self.args = args
  11. self.kwargs = kwargs
  12. def __call__(self, **kwargs):
  13. self.kwargs.update(kwargs)
  14. return self.func(*self.args, **self.kwargs)
  15. def __str__(self):
  16. return str(self())
  17. def __unicode__(self):
  18. return py3compat.unicode_type(self())
  19. def __format__(self, format_spec):
  20. return format(self(), format_spec)