__init__.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # -*- coding: utf_8 -*-
  2. """
  3. Charset-Normalizer
  4. ~~~~~~~~~~~~~~
  5. The Real First Universal Charset Detector.
  6. A library that helps you read text from an unknown charset encoding.
  7. Motivated by chardet, This package is trying to resolve the issue by taking a new approach.
  8. All IANA character set names for which the Python core library provides codecs are supported.
  9. Basic usage:
  10. >>> from charset_normalizer import from_bytes
  11. >>> results = from_bytes('Bсеки човек има право на образование. Oбразованието!'.encode('utf_8'))
  12. >>> best_guess = results.best()
  13. >>> str(best_guess)
  14. 'Bсеки човек има право на образование. Oбразованието!'
  15. Others methods and usages are available - see the full documentation
  16. at <https://github.com/Ousret/charset_normalizer>.
  17. :copyright: (c) 2021 by Ahmed TAHRI
  18. :license: MIT, see LICENSE for more details.
  19. """
  20. import logging
  21. from .api import from_bytes, from_fp, from_path, normalize
  22. from .legacy import (
  23. CharsetDetector,
  24. CharsetDoctor,
  25. CharsetNormalizerMatch,
  26. CharsetNormalizerMatches,
  27. detect,
  28. )
  29. from .models import CharsetMatch, CharsetMatches
  30. from .utils import set_logging_handler
  31. from .version import VERSION, __version__
  32. __all__ = (
  33. "from_fp",
  34. "from_path",
  35. "from_bytes",
  36. "normalize",
  37. "detect",
  38. "CharsetMatch",
  39. "CharsetMatches",
  40. "CharsetNormalizerMatch",
  41. "CharsetNormalizerMatches",
  42. "CharsetDetector",
  43. "CharsetDoctor",
  44. "__version__",
  45. "VERSION",
  46. "set_logging_handler",
  47. )
  48. # Attach a NullHandler to the top level logger by default
  49. # https://docs.python.org/3.3/howto/logging.html#configuring-logging-for-a-library
  50. logging.getLogger("charset_normalizer").addHandler(logging.NullHandler())