MCPcopy Create free account
hub / github.com/ActiveState/code / write

Method write

recipes/Python/119404_Print_Hook/recipe-119404.py:44–66  ·  view source on GitHub ↗
(self,text)

Source from the content-addressed store, hash-verified

42
43 #override write of stdout
44 def write(self,text):
45 proceed = 1
46 lineNo = 0
47 addText = ''
48 if self.func != None:
49 proceed,lineNo,newText = self.func(text)
50 if proceed:
51 if text.split() == []:
52 self.origOut.write(text)
53 else:
54 #if goint to stdout then only add line no file etc
55 #for stderr it is already there
56 if self.out:
57 if lineNo:
58 try:
59 raise "Dummy"
60 except:
61 newText = 'line('+str(sys.exc_info()[2].tb_frame.f_back.f_lineno)+'):'+newText
62 codeObject = sys.exc_info()[2].tb_frame.f_back.f_code
63 fileName = codeObject.co_filename
64 funcName = codeObject.co_name
65 self.origOut.write('file '+fileName+','+'func '+funcName+':')
66 self.origOut.write(newText)
67
68
69 #pass all other methods to __stdout__ so that we don't have to override them

Callers 15

mySetLongFunction · 0.45
mySetStringFunction · 0.45
recipe-117243.pyFile · 0.45
create_fileFunction · 0.45
recipe-115419.pyFile · 0.45
bookEntryFunction · 0.45
saveFunction · 0.45
recipe-112546.pyFile · 0.45
__init__Method · 0.45
mainFunction · 0.45
_readMethod · 0.45
readlineMethod · 0.45

Calls 3

strFunction · 0.85
funcMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected