Some changes in relation with the new obitools3.apps module

This commit is contained in:
2016-03-28 15:05:59 +02:00
parent e583098a96
commit 2dfab3f378
2 changed files with 23 additions and 1 deletions

View File

@ -1,5 +1,6 @@
#cython: language_level=3 #cython: language_level=3
cdef bytes str2bytes(str string) cdef bytes str2bytes(str string)
cdef str bytes2str(bytes string) cdef str bytes2str(bytes string)

View File

@ -1,7 +1,28 @@
#cython: language_level=3 #cython: language_level=3
import sys
import io
cdef bytes str2bytes(str string): cdef bytes str2bytes(str string):
"""
Short cut to convert ascii encoded python string (str) to bytes
which can be easily converted to C-strings.
@param string: the python string to be converted.
@type string: str
@return a transcoded string
@rtype: bytes
"""
return string.encode('ascii') return string.encode('ascii')
cdef str bytes2str(bytes string): cdef str bytes2str(bytes string):
"""
Short cut to convert bytes (C-strings) to ascii encoded python string (str).
@param string: the binary (C-string) string to be converted.
@type string: bytes
@return an ascii transcoded string
@rtype: str
"""
return string.decode('ascii') return string.decode('ascii')