No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

47 líneas
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. #
  3. # libcaca Colour ASCII-Art library
  4. # Python language bindings
  5. # Copyright (c) 2010 Alex Foulon <alxf@lavabit.com>
  6. # All Rights Reserved
  7. #
  8. # This library is free software. It comes without any warranty, to
  9. # the extent permitted by applicable law. You can redistribute it
  10. # and/or modify it under the terms of the Do What The Fuck You Want
  11. # To Public License, Version 2, as published by Sam Hocevar. See
  12. # http://sam.zoy.org/wtfpl/COPYING for more details.
  13. #
  14. """ Libcaca Python bindings """
  15. #standard modules
  16. import locale
  17. import sys
  18. import ctypes
  19. from ctypes.util import find_library
  20. if find_library('caca') is not None:
  21. _lib = ctypes.cdll.LoadLibrary(find_library('caca'))
  22. else:
  23. raise ImportError(
  24. "Can't find shared library, you need to install libcaca in your path !")
  25. #functions to handle string/bytes in python3+
  26. if sys.version_info[0:2] >= (3, 0):
  27. _PYTHON3 = True
  28. else:
  29. _PYTHON3 = False
  30. def _str_to_bytes(the_string):
  31. """ Translate string to bytes type for python 3.
  32. """
  33. return bytes(the_string, locale.getlocale()[1])
  34. def _bytes_to_str(the_bytes):
  35. """ Translate bytes to string type for python 3.
  36. """
  37. return the_bytes.decode(locale.getlocale()[1])
  38. from .common import *