File: debug.py

package info (click to toggle)
frescobaldi 3.0.0~git20161001.0.eec60717%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 19,792 kB
  • ctags: 5,843
  • sloc: python: 37,853; sh: 180; makefile: 69
file content (72 lines) | stat: -rw-r--r-- 1,485 bytes parent folder | download | duplicates (2)
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
66
67
68
69
70
71
72
# 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 print_function

import sys

from . import toplevel
toplevel.install()

import main
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))


# avoid builtins._ being overwritten
sys.displayhook = app.displayhook

# instantiate app and create a mainwindow, etc
app.instantiate()
main.main()
app.appStarted()

# be friendly and import Qt stuff
from PyQt5.QtCore import *
from PyQt5.QtGui import *