"""
Name: print_text
Title: Print Text
Author: Cooper
Date: 12/05/2020

Desc: Handy module to allow printing of non-printable characters in a printable way

"""

class PrintText():
    @staticmethod
    def print_ascii(text):
        temp = PrintText.to_ascii(text)
        print(temp)

    @staticmethod
    def to_ascii(text):
        """ Little debug helper - assembles a printable string from binary input. """
        temp = ""
        for x in text:
            try:
                x_ = ord(x)
            except TypeError:
                x_ = x

            if x_ < 33 or x_ > 126:
                temp += ("<0x%02X>" % x_)
            else:
                try:
                    temp += x
                except TypeError:
                    pass

        return temp

if __name__ == "__main__":
    pass