Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

octets.py 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #
  2. # This file is part of pyasn1 software.
  3. #
  4. # Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
  5. # License: https://pyasn1.readthedocs.io/en/latest/license.html
  6. #
  7. from sys import version_info
  8. if version_info[0] <= 2:
  9. int2oct = chr
  10. # noinspection PyPep8
  11. ints2octs = lambda s: ''.join([int2oct(x) for x in s])
  12. null = ''
  13. oct2int = ord
  14. # TODO: refactor to return a sequence of ints
  15. # noinspection PyPep8
  16. octs2ints = lambda s: [oct2int(x) for x in s]
  17. # noinspection PyPep8
  18. str2octs = lambda x: x
  19. # noinspection PyPep8
  20. octs2str = lambda x: x
  21. # noinspection PyPep8
  22. isOctetsType = lambda s: isinstance(s, str)
  23. # noinspection PyPep8
  24. isStringType = lambda s: isinstance(s, (str, unicode))
  25. # noinspection PyPep8
  26. ensureString = str
  27. else:
  28. ints2octs = bytes
  29. # noinspection PyPep8
  30. int2oct = lambda x: ints2octs((x,))
  31. null = ints2octs()
  32. # noinspection PyPep8
  33. oct2int = lambda x: x
  34. # noinspection PyPep8
  35. octs2ints = lambda x: x
  36. # noinspection PyPep8
  37. str2octs = lambda x: x.encode('iso-8859-1')
  38. # noinspection PyPep8
  39. octs2str = lambda x: x.decode('iso-8859-1')
  40. # noinspection PyPep8
  41. isOctetsType = lambda s: isinstance(s, bytes)
  42. # noinspection PyPep8
  43. isStringType = lambda s: isinstance(s, str)
  44. # noinspection PyPep8
  45. ensureString = bytes