__init__.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # -*- coding: utf-8 -*-
  2. from ._parser import parse, parser, parserinfo, ParserError
  3. from ._parser import DEFAULTPARSER, DEFAULTTZPARSER
  4. from ._parser import UnknownTimezoneWarning
  5. from ._parser import __doc__
  6. from .isoparser import isoparser, isoparse
  7. __all__ = ['parse', 'parser', 'parserinfo',
  8. 'isoparse', 'isoparser',
  9. 'ParserError',
  10. 'UnknownTimezoneWarning']
  11. ###
  12. # Deprecate portions of the private interface so that downstream code that
  13. # is improperly relying on it is given *some* notice.
  14. def __deprecated_private_func(f):
  15. from functools import wraps
  16. import warnings
  17. msg = ('{name} is a private function and may break without warning, '
  18. 'it will be moved and or renamed in future versions.')
  19. msg = msg.format(name=f.__name__)
  20. @wraps(f)
  21. def deprecated_func(*args, **kwargs):
  22. warnings.warn(msg, DeprecationWarning)
  23. return f(*args, **kwargs)
  24. return deprecated_func
  25. def __deprecate_private_class(c):
  26. import warnings
  27. msg = ('{name} is a private class and may break without warning, '
  28. 'it will be moved and or renamed in future versions.')
  29. msg = msg.format(name=c.__name__)
  30. class private_class(c):
  31. __doc__ = c.__doc__
  32. def __init__(self, *args, **kwargs):
  33. warnings.warn(msg, DeprecationWarning)
  34. super(private_class, self).__init__(*args, **kwargs)
  35. private_class.__name__ = c.__name__
  36. return private_class
  37. from ._parser import _timelex, _resultbase
  38. from ._parser import _tzparser, _parsetz
  39. _timelex = __deprecate_private_class(_timelex)
  40. _tzparser = __deprecate_private_class(_tzparser)
  41. _resultbase = __deprecate_private_class(_resultbase)
  42. _parsetz = __deprecated_private_func(_parsetz)