summaryrefslogtreecommitdiffhomepage
path: root/host/proto/test/fio.py
blob: 0764619987b9f54b99a5d35c9118d52e5d49601a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class IO:
    def __init__ (self, fin = None, fout = None):
	if fin is None:
	    import sys, tty
	    self.fin = sys.stdin
	    self.fout = sys.stdout
	    tty.setcbreak (sys.stdin.fileno ())
	else:
	    self.fin = fin
	    self.fout = fout

    def read (self, *args):
	buf = self.fin.read (*args).replace ('\n', '\r')
	return buf

    def write (self, *args):
	return self.fout.write (*[i.replace ('\r', '\n') for i in args])

    def fileno (self):
	return self.fin.fileno ()