/usr/lib/python2.7/dist-packages/stomp/backward3.py is in python-stomp 4.1.19-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | """
Python3-specific versions of various functions used by stomp.py
"""
NULL = b'\x00'
def input_prompt(prompt):
"""
Get user input
:param str prompt: the prompt to display to the user
:rtype: str
"""
return input(prompt)
def decode(byte_data):
"""
Decode the byte data to a string if not None.
:param bytes byte_data: the data to decode
:rtype: str
"""
if byte_data is None:
return None
return byte_data.decode()
def encode(char_data):
"""
Encode the parameter as a byte string.
:param char_data: the data to encode
:rtype: bytes
"""
if type(char_data) is str:
return char_data.encode()
elif type(char_data) is bytes:
return char_data
else:
raise TypeError('message should be a string or bytes')
def pack(pieces=()):
"""
Join a sequence of strings together.
:param list pieces: list of strings
:rtype: bytes
"""
encoded_pieces = (encode(piece) for piece in pieces)
return b''.join(encoded_pieces)
def join(chars=()):
"""
Join a sequence of characters into a string.
:param bytes chars: list of chars
:rtype: str
"""
return b''.join(chars).decode()
|