~ubuntu-branches/ubuntu/trusty/kate/trusty

« back to all changes in this revision

Viewing changes to addons/kate/pate/src/plugins/libkatepate/errors.py

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell, Rohan Garg, Jonathan Riddell, Philip Muškovac
  • Date: 2014-03-19 10:38:16 UTC
  • mfrom: (1.1.42)
  • Revision ID: package-import@ubuntu.com-20140319103816-f5b5t0m6hnwclzcn
Tags: 4:4.12.90-0ubuntu1
[ Rohan Garg ]
* Update install files

[ Jonathan Riddell ]
* New upstream beta release

[ Philip Muškovac ]
* Override license-problem-json-evil for js_lint.py as the file only
  references the evil file

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
# <https://github.com/goinnn/Kate-plugins/blob/master/kate_plugins/pyte_plugins/check_plugins/commons.py>
19
19
 
20
20
import kate
 
21
import kate.ui
 
22
 
21
23
import sys
22
24
 
23
 
from PyKDE4.kdecore import i18n
 
25
from PyKDE4.kdecore import i18n, i18nc
24
26
from PyKDE4.ktexteditor import KTextEditor
25
27
 
26
28
 
27
29
ENCODING_TRANSLATIONS = 'latin-1'
28
30
 
29
31
 
30
 
class PythonVersionException(Exception):
31
 
    pass
32
 
 
33
 
 
34
 
def needs_python_version(major, minor=None, micro=None, text=''):
35
 
    if major != sys.version_info.major:
36
 
        raise PythonVersionException(text)
37
 
    elif minor and minor != sys.version_info.minor:
38
 
        raise PythonVersionException(text)
39
 
    elif micro and micro != sys.version_info.micro:
40
 
        raise PythonVersionException(text)
41
 
 
42
 
 
43
 
def needs_packages(packages):
44
 
    msg = i18n("You need install the following packages:\n").encode(ENCODING_TRANSLATIONS)
45
 
    import_error = False
46
 
    for package, version in packages.items():
47
 
        try:
48
 
            __import__(package)
49
 
        except ImportError:
50
 
            import_error = True
51
 
            if '==' in version:
52
 
                package = version.split('==')[0]
53
 
                version = version.split('==')[1]
54
 
            msg += i18n("\t%1. Use easy_install (or pip install) %1==%2", package, version).encode(ENCODING_TRANSLATIONS)
55
 
    if import_error:
56
 
        raise ImportError(msg)
57
 
 
58
 
 
59
32
def clearMarksOfError(doc, mark_iface):
60
33
    for line in range(doc.lines()):
61
34
        if mark_iface.mark(line) == mark_iface.Error:
62
35
            mark_iface.removeMark(line, mark_iface.Error)
63
36
 
64
37
 
65
 
def hideOldPopUps():
66
 
    mainWindow = kate.mainWindow()
67
 
    popups = kate.gui.TimeoutPassivePopup.popups.get(mainWindow, []) or []
68
 
    for popup in popups:
69
 
        popup.timer.stop()
70
 
        popup.hide()
71
 
        popup.setFixedHeight(0)
72
 
        popup.adjustSize()
73
 
        popup.originalHeight = popup.height()
74
 
        popup.offsetBottom = 0
75
 
        popup.move(0, 0)
76
 
 
77
 
 
78
 
def showErrors(message, errors, key_mark, doc, time=10, icon='dialog-warning',
 
38
def showErrors(message, errors, key_mark, doc, icon='dialog-warning',
79
39
               key_line='line', key_column='column',
80
40
               max_errors=3, show_popup=True, move_cursor=False):
81
41
    mark_iface = doc.markInterface()
111
71
        message = '%s\n%s' % (message, '\n'.join(messages_show))
112
72
        if len(messages_show) < len(errors):
113
73
            message += i18n('\n\nAnd other errors')
114
 
        showError(message, time, icon, minTextWidth=300)
115
 
 
116
 
 
117
 
def showError(message="error", time=10, icon="dialog-warning", minTextWidth=300):
118
 
    kate.gui.popup(message, time, icon, minTextWidth=300)
119
 
 
120
 
 
121
 
def showOk(message="Ok", time=3, icon='dialog-ok'):
122
 
    kate.gui.popup(message, time, icon='dialog-ok', minTextWidth=200)
 
74
        showError(message, icon)
 
75
 
 
76
 
 
77
def showError(message="error", icon="dialog-warning"):
 
78
    kate.ui.popup(i18nc('@title:window', 'Error'), message, icon)
 
79
 
 
80
 
 
81
def showOk(message="Ok", icon='dialog-ok'):
 
82
    kate.ui.popup(i18nc('@title:window', 'Success'), message, icon)
123
83
 
124
84
 
125
85
def _compress_key(line, column):
202
162
        view.setCursorPosition(cursor)
203
163
    except KeyError:
204
164
        pass
205
 
 
206
 
# kate: indent-width 4;