File: debug.py

package info (click to toggle)
frescobaldi 2.0.13%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 15,076 kB
  • ctags: 6,345
  • sloc: python: 37,620; makefile: 47; sh: 3
file content (65 lines) | stat: -rw-r--r-- 1,343 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#! python
# This module helps with debugging Frescobaldi.
#
# Start a Python shell
# Enter: from frescobaldi_app.debug import *
# This runs Frescobaldi, installs some nice __repr__() methods, connects some
# signals to debug-print functions, and imports the most important modules such
# as app.

from __future__ import unicode_literals

import sys

try:
    from . import main
    del main
except (ImportError, ValueError):
    pass # this was a reload()

from PyQt4.QtCore import *
from PyQt4.QtGui import *

import app
import document
    


def doc_repr(self):
    index = app.documents.index(self)
    return '<Document #{0} "{1}">'.format(index, self.url().toString())
document.Document.__repr__ = doc_repr
    
@app.documentCreated.connect
def f(doc): 
    print "created:", doc

@app.documentLoaded.connect
def f(doc):
    print "loaded:", doc

@app.documentClosed.connect
def f(doc):
    print "closed:", doc

@app.jobStarted.connect
def f(doc, job):
    print 'job started:', doc
    print job.command

@app.jobFinished.connect
def f(doc, job, success):
    print 'job finished', doc
    print 'success:', success


# more to add...
    
    
# delete unneeded stuff
del f, doc_repr

def modules():
    """Print the list of loaded modules."""
    print '\n'.join(v.__name__ for k, v in sorted(sys.modules.items()) if v is not None)