Updated Finnish translation
[rhythmbox.git] / plugins / rb / __init__.py
blob08fe8dbbd2c4871c0d337e41b140ffdad828d5dc
1 import sys
3 # rb classes
4 from Loader import Loader
5 from Coroutine import Coroutine
7 #def _excepthandler (exc_class, exc_inst, trace):
8 # import sys
9 # # print out stuff ignoring our debug redirect
10 # sys.__excepthook__ (exc_class, exc_inst, trace)
13 class _rbdebugfile:
14 def __init__(self, fn):
15 self.fn = fn
17 def write(self, str):
18 if str == '\n':
19 return
20 import sys, os, rb
21 fr = sys._getframe(1)
23 co = fr.f_code
24 filename = co.co_filename
26 # strip off the cwd, for if running uninstalled
27 cwd = os.getcwd()
28 if cwd[-1] != os.sep:
29 cwd += os.sep
30 if filename[:len(cwd)] == cwd:
31 filename = filename[len(cwd):]
33 # add the class name to the method, if 'self' exists
34 methodname = co.co_name
35 if fr.f_locals.has_key('self'):
36 methodname = '%s.%s' % (fr.f_locals['self'].__class__.__name__, methodname)
38 rb._debug (methodname, filename, co.co_firstlineno + fr.f_lineno, True, str)
40 def close(self): pass
41 def flush(self): pass
42 def fileno(self): return self.fn
43 def isatty(self): return 0
44 def read(self, a): return ''
45 def readline(self): return ''
46 def readlines(self): return []
47 writelines = write
48 def seek(self, a): raise IOError, (29, 'Illegal seek')
49 def tell(self): raise IOError, (29, 'Illegal seek')
50 truncate = tell
52 sys.stdout = _rbdebugfile(sys.stdout.fileno())
53 #sys.excepthook = _excepthandler