1
# -*- coding: utf-8 -*-
2
'''Python Utilities: Parse Checker, PEP8 Checker, Pyflakes Checker, Snippets'''
4
# Copyright (c) 2013 by Pablo Martín <goinnn@gmail.com>
6
# This software is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU Lesser General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This software is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Lesser General Public License for more details.
16
# You should have received a copy of the GNU Lesser General Public License
17
# along with this software. If not, see <http://www.gnu.org/licenses/>.
19
# This plugin originally was in this repository:
20
# <https://github.com/goinnn/Kate-plugins/tree/master/kate_plugins/pyte_plugins/>
21
# The original author of the pep8 and pyflakes checker is Alejandro Blanco <alejandro.b.e@gmail.com>
26
from PyQt4.QtGui import QWidget
28
from libkatepate.compat import text_type
30
from python_snippets import *
31
from python_checkers.parse_checker import *
33
from python_settings import (KATE_CONFIG,
34
_PEP8_CHECK_WHEN_SAVE,
36
_PYFLAKES_CHECK_WHEN_SAVE,
37
_PARSECODE_CHECK_WHEN_SAVE,
39
DEFAULT_CHECK_PEP8_WHEN_SAVE,
40
DEFAULT_IGNORE_PEP8_ERRORS,
41
DEFAULT_CHECK_PYFLAKES_WHEN_SAVE,
42
DEFAULT_PARSECODE_CHECK_WHEN_SAVE,
46
_CONFIG_UI = 'python_utils.ui'
49
class ConfigWidget(QWidget):
50
"""Configuration widget for this plugin."""
52
def __init__(self, parent=None, name=None):
53
super(ConfigWidget, self).__init__(parent)
54
# Set up the user interface from Designer.
55
uic.loadUi(os.path.join(os.path.dirname(__file__), _CONFIG_UI), self)
59
kate.configuration[_PEP8_CHECK_WHEN_SAVE] = self.checkPEP8WhenSave.isChecked()
60
kate.configuration[_IGNORE_PEP8_ERRORS] = self.ignorePEP8Errors.text()
61
kate.configuration[_PYFLAKES_CHECK_WHEN_SAVE] = self.checkPyFlakesWhenSave.isChecked()
62
kate.configuration[_PARSECODE_CHECK_WHEN_SAVE] = self.checkParseCode.isChecked()
63
kate.configuration[_IPDB_SNIPPET] = self.ipdbSnippet.text()
64
kate.configuration.save()
68
if _PEP8_CHECK_WHEN_SAVE in kate.configuration:
69
self.checkPEP8WhenSave.setChecked(kate.configuration[_PEP8_CHECK_WHEN_SAVE])
70
if _IGNORE_PEP8_ERRORS in kate.configuration:
71
self.ignorePEP8Errors.setText(kate.configuration[_IGNORE_PEP8_ERRORS])
72
if _PYFLAKES_CHECK_WHEN_SAVE in kate.configuration:
73
self.checkPyFlakesWhenSave.setChecked(kate.configuration[_PYFLAKES_CHECK_WHEN_SAVE])
74
if _PARSECODE_CHECK_WHEN_SAVE in kate.configuration:
75
self.checkParseCode.setChecked(kate.configuration[_PARSECODE_CHECK_WHEN_SAVE])
76
if _IPDB_SNIPPET in kate.configuration:
77
self.ipdbSnippet.setText(kate.configuration[_IPDB_SNIPPET])
80
self.checkPEP8WhenSave.setChecked(DEFAULT_CHECK_PEP8_WHEN_SAVE)
81
self.ignorePEP8Errors.setText(DEFAULT_IGNORE_PEP8_ERRORS)
82
self.checkPyFlakesWhenSave.setChecked(DEFAULT_CHECK_PYFLAKES_WHEN_SAVE)
83
self.checkParseCode.setChecked(DEFAULT_PARSECODE_CHECK_WHEN_SAVE)
84
self.ipdbSnippet.setText(DEFAULT_IPDB_SNIPPET)
87
class ConfigPage(kate.Kate.PluginConfigPage, QWidget):
88
"""Kate configuration page for this plugin."""
89
def __init__(self, parent=None, name=None):
90
super(ConfigPage, self).__init__(parent, name)
91
self.widget = ConfigWidget(parent)
93
lo.addWidget(self.widget)
102
self.widget.defaults()
106
@kate.configPage(**KATE_CONFIG)
107
def configPage(parent=None, name=None):
108
return ConfigPage(parent, name)
111
# kate: space-indent on; indent-width 4;