Exemple #1
0
def read_stdin(filename, **kwargs):
    delimiter = kwargs.get("delimiter", b"")
    show_sep = kwargs.get("show_sep", True)
    verbose = kwargs.get("verbose", False)
    debug = kwargs.get("debug", False)
    #
    dlm = [bytes([i]) for i in delimiter]
    dlm_end = len(dlm) - 1
    while True:
        dlm_pos = 0
        data = bytearray()
        while True:
            b = sys.stdin.buffer.read(1)
            if dlm[dlm_pos] == b:
                if dlm_pos == dlm_end:
                    data = data[:-dlm_end]
                    break
                else:
                    dlm_pos += 1
                    data += b
                continue
            #
            dlm_pos = 0
            data += b
        #
        if verbose:
            print(dis.dump_byte(data))
        if show_sep:
            print("----", str(datetime.now()))
        ret = dis.decoder(data)
        print(dis.dumps(ret, indent=4))
Exemple #2
0
def read_file(filename, verbose=False, debug=False):
    with open(filename) as fd:
        data = fd.buffer.read()
    #
    if verbose:
        print(dis.decoder.dump_byte(data))
    #
    ret3 = dis.decoder(data)
    print(dis.dumps(ret3, indent=4))
Exemple #3
0
 def test_x(self):
     for i in self.test_packet:
         ret = dis.decoder(i)
         #print(ret)
         print("===")
         print(dis.dumps(ret, indent=4))