diff --git a/.gitignore b/.gitignore index 86d2aff..7f4809e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,13 @@ *.pyc *.pyo *~ +*.rej +*.orig /.pc/ /build/ /debian/ /dist/ /MANIFEST -/modules/*BA.py -/modules/kodos_rc.py +*BA.py +kodos_rc.py /translations/*.qm -/translations/*.ts diff --git a/CHANGELOG.txt b/CHANGELOG.txt index faf4839..e5ecb14 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,13 @@ Kodos ChangeLog +2.5.2 +===== + *) First Python3 version , still using PyQt4, python3-PyQt4 is now required + +2.5.1 +===== + *) Migrated to PyQt4 completed using teythoon repo + 2.4.9 ===== *) Fixed help window (corrects problem related to tooltip api changes) diff --git a/MANIFEST.in b/MANIFEST.in index dfa0425..8372b26 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -8,8 +8,8 @@ include screenshots/*.png include MANIFEST.in include LICENSE.txt include README.txt -include modules/*.ui -include modules/*.py +include kodos/*.ui +include kodos/*.py include windows/build.bat include windows/installer.iss include CHANGELOG.txt diff --git a/Makefile b/Makefile index d03d8b0..a6f9d90 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ -all: modules/kodos_rc.py - $(MAKE) -C modules +all: kodos/kodos_rc.py + $(MAKE) -C kodos pylupdate4 kodos.pro $(MAKE) -C translations clean: - $(RM) -fv modules/kodos_rc.py - $(MAKE) clean -C modules + $(RM) -fv kodos/kodos_rc.py + $(MAKE) clean -C kodos -modules/kodos_rc.py: kodos.qrc - pyrcc4 -o $@ $< +kodos/kodos_rc.py: kodos.qrc + pyrcc4 -py3 -o $@ $< diff --git a/PKG-INFO b/PKG-INFO index c235842..f6a2b42 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,12 +1,10 @@ Metadata-Version: 1.0 Name: kodos -Version: 2.4.9 +Version: 2.5.2 Summary: Kodos is a visual regular expression editor -Home-page: http://kodos.sourceforge.net +Home-page: https://github.com/sergiomb2/kodos Author: Phil Schwartz Author-email: phil_schwartz@users.sourceforge.net License: GPL -Description: - Kodos is a visual regular expression editor and debugger. - +Description: Kodos is a visual regular expression editor and debugger. Platform: UNKNOWN diff --git a/bin/kodos b/bin/kodos new file mode 100755 index 0000000..9ddbf20 --- /dev/null +++ b/bin/kodos @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# kodos.py: -*- Python -*- DESCRIPTIVE TEXT. + +import sys +import os +import logging +import optparse + +try: + from PyQt4 import QtGui + from PyQt4 import QtCore +except: + sys.exit("""Could not locate the PyQt module. Please make sure that +you have installed PyQt for the version of Python that you are running.""") + +from kodos.main import Kodos +from kodos.util import findFile + +parser = optparse.OptionParser() +parser.add_option('-f', '--filename', dest='filename', + help='Load filename on startup', metavar='FILE') +parser.add_option('-d', '--debug', dest='debug', action='store_true', + help='Set log level to debug') +parser.add_option('-k', dest='kodos_dir', type='string', + default=os.path.join(sys.prefix, "kodos"), + help='Set path containing Kodos images & help subdirs', + metavar='DIR') +parser.add_option('-l', '--locale', dest='locale', type='string', + default='en', + help='2-letter locale', metavar='LEVEL') +options, args = parser.parse_args() + +if options.debug: + logging.basicConfig(level=logging.DEBUG) +else: + logging.basicConfig(level=logging.WARNING) +log = logging.getLogger('kodos') + +os.environ['KODOS_DIR'] = options.kodos_dir + +qApp = QtGui.QApplication(sys.argv) +qApp.setOrganizationName("kodos") +qApp.setApplicationName("kodos") +qApp.setOrganizationDomain("kodos.sourceforge.net") + +if options.locale != 'en': + localefile = "kodos_%s.qm" % (options.locale or QtCore.QTextCodec.locale()) + localepath = findFile(os.path.join("translations", localefile)) + log.debug('locale changed to: %s, file: %s, path: %s' % (locale, + localefile, + localepath)) + + translator = QtCore.QTranslator(qApp) + translator.load(localepath) + qApp.installTranslator(translator) + +kodos = Kodos(qApp, options.filename) +kodos.show() +sys.exit(qApp.exec_()) diff --git a/help/prefs.html b/help/prefs.html index 06baaf2..793bfc3 100644 --- a/help/prefs.html +++ b/help/prefs.html @@ -77,12 +77,8 @@

Kodos - Help

Preferences

-Set your Web Browser path. You can use the ... button to use a file dialog to help locate your browser. The web browser is necessary to access external links within the Python Regex documentation.

- The Editor Font allows you to select a desirable font for use within the Kodos editor

-The Email Server is required for sending bug reports to the author. You can submit a bug report under the main Help menu

- You can control the number of Recent Files that are displayed at the bottom of the File menu. The default value is 5. To display more or less recent files, set this value accordingly. The recent file list is maintained independtly of this value such that applying a lower value and then a higher value will not purge entries. That is, if you have 10 files and then set this value to 3 and later set this value to 10, the 10 files will be immediately available for selection .

diff --git a/kodos.desktop b/kodos.desktop index 0a067fb..a135f39 100644 --- a/kodos.desktop +++ b/kodos.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Encoding=UTF-8 Name=Kodos -GenericName=Visual RegEx Editor +GenericName=The Python Regular Expression Debugger Comment=Kodos is a Visual regular expression editor Exec=kodos Icon=kodos_icon.png diff --git a/kodos.pro b/kodos.pro index db176a6..2607647 100644 --- a/kodos.pro +++ b/kodos.pro @@ -1,30 +1,28 @@ SOURCES = kodos - modules/about.py - modules/debug.py - modules/help.py - modules/__init__.py - modules/parseRegexLib.py - modules/prefs.py - modules/recent_files.py - modules/reference.py - modules/regexLibrary.py - modules/reportBug.py - modules/status_bar.py - modules/tooltip.py - modules/urlDialog.py - modules/util.py - modules/version.py + kodos/about.py + kodos/debug.py + kodos/help.py + kodos/__init__.py + kodos/parseRegexLib.py + kodos/prefs.py + kodos/recent_files.py + kodos/reference.py + kodos/regexLibrary.py + kodos/reportBug.py + kodos/status_bar.py + kodos/tooltip.py + kodos/urlDialog.py + kodos/util.py + kodos/version.py TRANSLATIONS = translations/kodos_en.ts \ - translations/kodos_de.ts \ translations/kodos_pl.ts -FORMS = modules/aboutBA.ui \ - modules/helpBA.ui \ - modules/kodosBA.ui \ - modules/newUserDialogBA.ui \ - modules/prefsBA.ui \ - modules/referenceBA.ui \ - modules/regexLibraryBA.ui \ - modules/reportBugBA.ui \ - modules/urlDialogBA.ui +FORMS = kodos/aboutBA.ui \ + kodos/helpBA.ui \ + kodos/kodosBA.ui \ + kodos/newUserDialogBA.ui \ + kodos/prefsBA.ui \ + kodos/referenceBA.ui \ + kodos/regexLibraryBA.ui \ + kodos/urlDialogBA.ui diff --git a/modules/Makefile b/kodos/Makefile similarity index 74% rename from modules/Makefile rename to kodos/Makefile index 0a7f167..d285670 100644 --- a/modules/Makefile +++ b/kodos/Makefile @@ -7,4 +7,4 @@ clean: $(RM) -vf *.pyc %.py: %.ui - pyuic4 --from-imports -o $*.py $< + pyuic4 --from-imports -w -o $*.py $< diff --git a/kodos/about.py b/kodos/about.py new file mode 100644 index 0000000..8864760 --- /dev/null +++ b/kodos/about.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# about.py: -*- Python -*- DESCRIPTIVE TEXT. + +from . import aboutBA +from . import version + +class About(aboutBA.AboutBA): + def __init__(self): + aboutBA.AboutBA.__init__(self) + self.versionLabel.setText(version.VERSION) + diff --git a/modules/aboutBA.ui b/kodos/aboutBA.ui similarity index 100% rename from modules/aboutBA.ui rename to kodos/aboutBA.ui diff --git a/modules/flags.py b/kodos/flags.py similarity index 69% rename from modules/flags.py rename to kodos/flags.py index 0b8f802..adaf0e4 100644 --- a/modules/flags.py +++ b/kodos/flags.py @@ -1,16 +1,8 @@ -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -#-----------------------------------------------------------------------------# -# Built-in modules - +# coding=utf-8 from __future__ import print_function, absolute_import, unicode_literals import re -#-----------------------------------------------------------------------------# - class reFlag(object): def __init__(self, flag_name, short_flag, checkbox): if not flag_name.startswith('re.'): @@ -21,15 +13,11 @@ def __init__(self, flag_name, short_flag, checkbox): self.shortFlag = short_flag self.checkBox = checkbox self.preEmbedState = None - return - def clear(self): self.preEmbedState = None self.checkBox.setEnabled(True) self.checkBox.setChecked(False) - return - def embed(self): """Set the state of the checkbox to show that it @@ -38,16 +26,12 @@ def embed(self): self.preEmbedState = self.checkBox.isChecked() self.checkBox.setChecked(True) self.checkBox.setDisabled(True) - return - def deembed(self): if self.preEmbedState != None: self.checkBox.setEnabled(True) self.checkBox.setChecked(self.preEmbedState) self.preEmbedState = None - return - class reFlagList(list): def allFlagsORed(self): @@ -57,10 +41,6 @@ def allFlagsORed(self): ret |= f.reFlag return ret - def clearAll(self): for f in self: f.clear() - return - -#-----------------------------------------------------------------------------# diff --git a/modules/help.py b/kodos/help.py old mode 100755 new mode 100644 similarity index 53% rename from modules/help.py rename to kodos/help.py index d31296c..990478d --- a/modules/help.py +++ b/kodos/help.py @@ -1,24 +1,13 @@ -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -#-----------------------------------------------------------------------------# -# Built-in modules +# -*- coding: utf-8 -*- +# help.py: -*- Python -*- DESCRIPTIVE TEXT. import os -#-----------------------------------------------------------------------------# -# Installed modules - -from PyQt4 import QtGui, QtCore - -#-----------------------------------------------------------------------------# -# Kodos modules +from PyQt4 import QtGui +from PyQt4 import QtCore from . import util -from .helpBA import Ui_HelpBA - -#-----------------------------------------------------------------------------# +from . import helpBA class textbrowser(QtGui.QTextBrowser): # reimplemented textbrowser that filters out external sources @@ -26,7 +15,6 @@ class textbrowser(QtGui.QTextBrowser): def __init__(self, parent=None, name=None): self.parent = parent QtGui.QTextBrowser.__init__(self) - return def setSource(self, src): @@ -36,57 +24,51 @@ def setSource(self, src): return QtGui.QTextBrowser.setSource(self, QtCore.QUrl(src)) - return -class Help(QtGui.QMainWindow, Ui_HelpBA): - def __init__(self, filename, parent=None, f=QtCore.Qt.WindowFlags()): - QtGui.QMainWindow.__init__(self, parent, f) - self.setupUi(self) + + +class Help(helpBA.HelpBA): + def __init__(self, parent, filename): + helpBA.HelpBA.__init__(self, parent) self.setGeometry(100, 50, 800, 600) + self.textBrowser = textbrowser(self) absPath = self.getHelpFile(filename) + self.setCentralWidget(self.textBrowser) self.textBrowser.setSource(absPath) + self.fwdAvailable = 0 self.show() - return def exitSlot(self): self.close() - return - def backSlot(self): self.textBrowser.backward() - return - def forwardSlot(self): self.textBrowser.forward() - return - def homeSlot(self): self.textBrowser.home() - return + def setForwardAvailable(self, bool): self.fwdAvailable = bool - return def forwardHandler(self): if self.fwdAvailable: self.textBrowser.forward() - return - def getHelpFile(self, filename): f = util.findFile(os.path.join("help", filename)) return f -#-----------------------------------------------------------------------------# + + diff --git a/modules/helpBA.ui b/kodos/helpBA.ui similarity index 100% rename from modules/helpBA.ui rename to kodos/helpBA.ui diff --git a/modules/kodosBA.ui b/kodos/kodosBA.ui similarity index 99% rename from modules/kodosBA.ui rename to kodos/kodosBA.ui index a600de2..14139b3 100644 --- a/modules/kodosBA.ui +++ b/kodos/kodosBA.ui @@ -406,7 +406,6 @@ database. New in Python version 2.0. - @@ -1285,22 +1284,6 @@ database. New in Python version 2.0. - - helpCheckForUpdateAction - activated() - KodosBA - check_for_update() - - - -1 - -1 - - - 20 - 20 - - - replaceTextEdit textChanged() diff --git a/kodos b/kodos/main.py old mode 100755 new mode 100644 similarity index 59% rename from kodos rename to kodos/main.py index 05eb857..d1756ba --- a/kodos +++ b/kodos/main.py @@ -1,59 +1,26 @@ -#!/usr/bin/env python -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -#-----------------------------------------------------------------------------# -# Built-in modules +# -*- coding: utf-8 -*- import os -import sys import re -import string import types -import getopt -import urllib import signal -try: - # Python 2.x: try to use cPickle if available - import cPickle as pickle -except ImportError: - # Python 3.x: pickle imports cPickle internally - import pickle - -#-----------------------------------------------------------------------------# -# Installed modules - -try: - from PyQt4 import QtGui, QtCore -except: - sys.exit("""Could not locate the PyQt module. Please make sure that -you have installed PyQt for the version of Python that you are running.""") - -#-----------------------------------------------------------------------------# -# Kodos modules - -# make sure that this script can find kodos specific modules -from distutils.sysconfig import get_python_lib -sys.path.append(os.path.join(get_python_lib(), "kodos")) - -from modules.kodosBA import Ui_KodosBA -from modules.util import (findFile, launch_browser, kodos_toolbar_logo, - saveWindowSettings, restoreWindowSettings) -from modules.about import About -from modules.help import Help -from modules.status_bar import Status_Bar -from modules.reference import Reference -from modules.prefs import Preferences -from modules.reportBug import reportBugWindow -from modules.version import VERSION -from modules.recent_files import RecentFiles -from modules.urlDialog import URLDialog -from modules.regexLibrary import RegexLibrary -from modules.newUserDialog import NewUserDialog -from modules.flags import reFlag, reFlagList - -#-----------------------------------------------------------------------------# +import pickle +import logging + +from PyQt4 import Qt, QtCore + +from . import kodosBA +from . import util +from . import about +from . import help +from . import status_bar +from . import reference +from . import prefs +from . import recent_files +from . import urlDialog +from . import regexLibrary +from . import newUserDialogBA +from .flags import reFlag, reFlagList # match status MATCH_NA = 0 @@ -62,9 +29,6 @@ MATCH_PAUSED = 3 MATCH_EXAMINED = 4 -TRUE = 1 -FALSE = 0 - TIMEOUT = 3 # regex to find special flags which must begin at beginning of line @@ -79,8 +43,8 @@ GEO = "kodos_geometry" # colors for normal & examination mode -QCOLOR_WHITE = QtGui.QColor(QtCore.Qt.white) # normal -QCOLOR_YELLOW = QtGui.QColor(255,255,127) # examine +QCOLOR_WHITE = QtCore.Qt.white # normal +QCOLOR_YELLOW = Qt.QColor(255,255,127) # examine try: signal.SIGALRM @@ -95,12 +59,12 @@ # ############################################################################## -class Kodos(QtGui.QMainWindow, Ui_KodosBA): - def __init__(self, filename, debug, parent=None, f=QtCore.Qt.WindowFlags()): - QtGui.QMainWindow.__init__(self, parent, f) - self.setupUi(self) +class Kodos(kodosBA.KodosBA): + def __init__(self, qApp, filename): + kodosBA.KodosBA.__init__(self) - self.debug = debug + self.log = logging.getLogger('kodos.main') + self.qApp = qApp self.regex = "" self.matchstring = "" self.replace = "" @@ -126,93 +90,81 @@ def __init__(self, filename, debug, parent=None, f=QtCore.Qt.WindowFlags()): self.MSG_FAIL = self.tr("Pattern does not match") - self.statusPixmapsDict = { - MATCH_NA: QtGui.QPixmap(":images/yellow.png"), - MATCH_OK: QtGui.QPixmap(":images/green.png"), - MATCH_FAIL: QtGui.QPixmap(":images/red.png"), - MATCH_PAUSED: QtGui.QPixmap(":images/pause.png"), - } + self.statusPixmapsDict = { MATCH_NA: Qt.QPixmap(":images/yellow.png"), + MATCH_OK: Qt.QPixmap(":images/green.png"), + MATCH_FAIL: Qt.QPixmap(":images/red.png"), + MATCH_PAUSED: Qt.QPixmap(":images/pause.png"), + } self.updateStatus(self.MSG_NA, MATCH_NA) self.reFlags = reFlagList([ - reFlag("re.IGNORECASE", "i", self.ignorecaseCheckBox), - reFlag("re.MULTILINE", "m", self.multilineCheckBox), - reFlag("re.DOTALL", "s", self.dotallCheckBox), - reFlag("re.VERBOSE", "x", self.verboseCheckBox), - reFlag("re.LOCALE", "L", self.localeCheckBox), - reFlag("re.UNICODE", "u", self.unicodeCheckBox), - ]) + reFlag("re.IGNORECASE", "i", self.ignorecaseCheckBox), + reFlag("re.MULTILINE", "m", self.multilineCheckBox), + reFlag("re.DOTALL", "s", self.dotallCheckBox), + reFlag("re.VERBOSE", "x", self.verboseCheckBox), + reFlag("re.LOCALE", "L", self.localeCheckBox), + reFlag("re.UNICODE", "u", self.unicodeCheckBox), + ]) self.reFlags.clearAll() - restoreWindowSettings(self, GEO) + util.restoreWindowSettings(self, GEO) self.show() - self.prefs = Preferences(autoload=1, parent=self) - self.recent_files = RecentFiles( - self, - self.prefs.recentFilesSpinBox.value(), - self.debug - ) + self.prefs = prefs.Preferences(self, 1) + self.recent_files = recent_files.RecentFiles(self, + self.prefs.recentFilesSpinBox.value()) if filename and self.openFile(filename): - QtGui.QApplication.processEvents() + self.qApp.processEvents() self.fileMenu.triggered.connect(self.fileMenuHandler) - kodos_toolbar_logo(self.toolBar) + util.kodos_toolbar_logo(self.toolBar) if self.replace: self.show_replace_widgets() else: self.hide_replace_widgets() self.checkIfNewUser() - return def checkIfNewUser(self): - s = QtCore.QSettings() - if s.value('New User', "true").toPyObject() != "false": - self.newuserdialog = NewUserDialog() + s = Qt.QSettings() + if s.value('New User', "true") != "false": + self.newuserdialog = newUserDialogBA.NewUserDialog() self.newuserdialog.show() s.setValue('New User', "false") - return def createStatusBar(self): - self.status_bar = Status_Bar(self, FALSE, "") - return + self.status_bar = status_bar.Status_Bar(self, False, "") - def updateStatus(self, status_string, status_value, duration=0, replace=FALSE, tooltip=''): + def updateStatus(self, status_string, status_value, duration=0, replace=False, tooltip=''): pixmap = self.statusPixmapsDict.get(status_value) self.status_bar.set_message(status_string, duration, replace, tooltip, pixmap) - return def fileMenuHandler(self, menuid): if self.recent_files.isRecentFile(menuid): - fn = str(menuid.text()) - if self.openFile(fn): - self.recent_files.add(fn) - return + filename = menuid.text() + if self.openFile(filename): + self.recent_files.add(filename) def prefsSaved(self): - if self.debug: print("prefsSaved slot") + self.log.debug("prefsSaved slot") self.recent_files.setNumShown(self.prefs.recentFilesSpinBox.value()) - return def kodos_edited_slot(self): # invoked whenever the user has edited something self.editstate = STATE_EDITED - return def checkbox_slot(self): self.process_regex() - return def set_flags(self, flags): @@ -220,7 +172,6 @@ def set_flags(self, flags): # this is used when loading a saved file for f in self.reFlags: f.checkBox.setChecked(flags & f.reFlag) - return def get_flags_string(self): @@ -250,7 +201,7 @@ def get_embedded_flags_string(self): def pause(self): self.is_paused = not self.is_paused - if self.debug: print("is_paused: {0}".format(self.is_paused)) + self.log.debug("is_paused: %s" % self.is_paused) if self.is_paused: self.update_results(self.MSG_PAUSED, MATCH_PAUSED) @@ -259,12 +210,11 @@ def pause(self): else: self.process_regex() self.matchNumberSpinBox.setEnabled(1) - return def examine(self): self.is_examined = not self.is_examined - if self.debug: print("is_examined: {0}".format(self.is_examined)) + self.log.debug("is_examined: %s" % self.is_examined) if self.is_examined: color = QCOLOR_YELLOW @@ -280,7 +230,7 @@ def examine(self): try: m = re.search(regex, self.matchstring, self.reFlags.allFlagsORed()) if m: - if self.debug: print("examined regex: {0}".format(regex)) + self.log.debug("examined regex: %s" % regex) self.__refresh_regex_widget(color, regex) return except: @@ -294,11 +244,10 @@ def examine(self): self.stringMultiLineEdit.setReadOnly(0) self.replaceTextEdit.setReadOnly(0) self.__refresh_regex_widget(color, regex) - return def __refresh_regex_widget(self, base_qcolor, regex): - pal = QtGui.QPalette() + pal = Qt.QPalette() pal.setColor(pal.Base, base_qcolor) self.regexMultiLineEdit.setPalette(pal) @@ -306,74 +255,57 @@ def __refresh_regex_widget(self, base_qcolor, regex): self.regexMultiLineEdit.clear() self.regexMultiLineEdit.blockSignals(0) self.regexMultiLineEdit.setPlainText(regex) - return def match_num_slot(self, num): self.match_num = num self.process_regex() - return def replace_num_slot(self, num): self.replace_num = num self.process_regex() - return def regex_changed_slot(self): - self.regex = unicode(self.regexMultiLineEdit.toPlainText()) + self.regex = self.regexMultiLineEdit.toPlainText() self.process_regex() - return def string_changed_slot(self): - self.matchstring = unicode(self.stringMultiLineEdit.toPlainText()) + self.matchstring = self.stringMultiLineEdit.toPlainText() self.process_regex() - return - def helpContents(self, x = None): pass #FIXME - return - - def helpIndex(self, x = None): pass #FIXME - return - def hide_replace_widgets(self): self.spacerLabel.hide() self.replaceLabel.hide() self.replaceNumberSpinBox.hide() self.replaceTextBrowser.clear() - self.replaceTextBrowser.setDisabled(TRUE) - return - + self.replaceTextBrowser.setDisabled(True) def show_replace_widgets(self): self.spacerLabel.show() self.replaceLabel.show() self.replaceNumberSpinBox.show() - self.replaceNumberSpinBox.setEnabled(TRUE) - self.replaceTextBrowser.setEnabled(TRUE) - return - + self.replaceNumberSpinBox.setEnabled(True) + self.replaceTextBrowser.setEnabled(True) def replace_changed_slot(self): - self.replace = unicode(self.replaceTextEdit.toPlainText()) + self.replace = self.replaceTextEdit.toPlainText() self.process_regex() if not self.replace: self.hide_replace_widgets() else: self.show_replace_widgets() - return def update_results(self, msg, val): self.updateStatus(msg, val) - return def populate_group_table(self, tuples): @@ -385,10 +317,9 @@ def populate_group_table(self, tuples): self.groupTable.setRowCount(rows) row = 0 for t in tuples: - self.groupTable.setItem(row, 0, QtGui.QTableWidgetItem(t[1])) - self.groupTable.setItem(row, 1, QtGui.QTableWidgetItem(t[2])) + self.groupTable.setItem(row, 0, Qt.QTableWidgetItem(t[1])) + self.groupTable.setItem(row, 1, Qt.QTableWidgetItem(t[2])) row += 1 - return def populate_code_textbrowser(self): @@ -424,34 +355,29 @@ def populate_code_textbrowser(self): named_grps = 0 for grp in self.group_tuples: i += 1 - code += "group_{0} = match_obj.group({0})\n".format(i) + code += "group_%d = match_obj.group(%d)\n" % (i, i) if grp[1]: named_grps = 1 if named_grps: code += "\n# Retrieve group(s) by name\n" for grp in self.group_tuples: if grp[1]: - code += "{0} = match_obj.group('{0}')\n".format(grp[1]) + code += "%s = match_obj.group('%s')\n" % (grp[1], grp[1]) code += "\n" if self.replace: code += "# Replace string\n" - code += "newstr = compile_obj.subn('{0}', {1})\n".format( - self.replace, self.replace_num - ) + code += "newstr = compile_obj.subn('%s', %d)\n" % (self.replace, + self.replace_num) self.codeTextBrowser.setPlainText(code) - return def colorize_strings(self, strings, widget, cursorOffset=0): widget.clear() - colors = ( - QtGui.QBrush(QtGui.QColor(QtCore.Qt.black)), - QtGui.QBrush(QtGui.QColor(QtCore.Qt.blue)), - ) + colors = (Qt.QBrush(Qt.QColor(QtCore.Qt.black)), Qt.QBrush(Qt.QColor(QtCore.Qt.blue)) ) cur = widget.textCursor() format = cur.charFormat() @@ -467,7 +393,6 @@ def colorize_strings(self, strings, widget, cursorOffset=0): cur.setPosition(pos) widget.setTextCursor(cur) widget.centerCursor() - return def populate_match_textbrowser(self, startpos, endpos): @@ -485,7 +410,6 @@ def populate_match_textbrowser(self, startpos, endpos): strings = [pre, match, post] self.colorize_strings(strings, self.matchTextBrowser, 1) - return def populate_replace_textbrowser(self, spans, nummatches, compile_obj): @@ -496,7 +420,7 @@ def populate_replace_textbrowser(self, spans, nummatches, compile_obj): if num == 0: num = nummatches text = self.matchstring - replace_text = unicode(self.replaceTextEdit.toPlainText()) + replace_text = self.replaceTextEdit.toPlainText() if RX_BACKREF.search(replace_text): # if the replace string contains a backref we just use the # python regex methods for the substitution @@ -525,7 +449,6 @@ def populate_replace_textbrowser(self, spans, nummatches, compile_obj): break self.colorize_strings(strings, self.replaceTextBrowser) - return def populate_matchAll_textbrowser(self, spans): @@ -549,7 +472,6 @@ def populate_matchAll_textbrowser(self, spans): strings.append(text[span[1]:]) self.colorize_strings(strings, self.matchAllTextBrowser) - return def clear_results(self): @@ -560,11 +482,10 @@ def clear_results(self): self.codeTextBrowser.clear() self.matchTextBrowser.clear() - self.matchNumberSpinBox.setEnabled(FALSE) - self.replaceNumberSpinBox.setEnabled(FALSE) + self.matchNumberSpinBox.setEnabled(False) + self.replaceNumberSpinBox.setEnabled(False) self.replaceTextBrowser.clear() self.matchAllTextBrowser.clear() - return def process_regex(self): @@ -591,17 +512,17 @@ def timeout(signum, frame): if allmatches and len(allmatches): self.matchNumberSpinBox.setMaximum(len(allmatches)) - self.matchNumberSpinBox.setEnabled(TRUE) + self.matchNumberSpinBox.setEnabled(True) self.replaceNumberSpinBox.setMaximum(len(allmatches)) - self.replaceNumberSpinBox.setEnabled(TRUE) + self.replaceNumberSpinBox.setEnabled(True) else: - self.matchNumberSpinBox.setEnabled(FALSE) - self.replaceNumberSpinBox.setEnabled(FALSE) + self.matchNumberSpinBox.setEnabled(False) + self.replaceNumberSpinBox.setEnabled(False) match_obj = compile_obj.search(self.matchstring) except Exception as e: - self.update_results(unicode(e), MATCH_FAIL) + self.update_results(str(e), MATCH_FAIL) return if HAS_ALARM: @@ -630,19 +551,18 @@ def timeout(signum, frame): if match_obj.groups(): group_nums = {} if compile_obj.groupindex: - keys = compile_obj.groupindex.keys() + keys = list(compile_obj.groupindex.keys()) for key in keys: group_nums[compile_obj.groupindex[key]] = key - if self.debug: - print("group_nums: {0}".format(group_nums)) - print("grp index: {0}".format(compile_obj.groupindex)) - print("groups: {0}".format(match_obj.groups())) - print("span: {0}".format(match_obj.span())) + self.log.debug("group_nums: %s" % group_nums) + self.log.debug("grp index: %s" % compile_obj.groupindex) + self.log.debug("groups: %s" % (match_obj.groups(), )) + self.log.debug("span: %s" % (match_obj.span(), )) # create group_tuple in the form: (group #, group name, group matches) g = allmatches[match_index] - if type(g) == types.TupleType: + if type(g) == tuple: for i in range(len(g)): group_tuple = (i+1, group_nums.get(i+1, ""), g[i]) self.group_tuples.append(group_tuple) @@ -654,24 +574,20 @@ def timeout(signum, frame): # clear the group table self.populate_group_table([]) - str_pattern_matches = unicode(self.tr("Pattern matches")) - str_found = unicode(self.tr("found")) - str_match = unicode(self.tr("match")) - str_matches = unicode(self.tr("matches")) + str_pattern_matches = self.tr("Pattern matches") + str_found = self.tr("found") + str_match = self.tr("match") + str_matches = self.tr("matches") if len(allmatches) == 1: - status = "{0} ({1} 1 {2})".format( - str_pattern_matches, - str_found, - str_match, - ) + status = "%s (%s 1 %s)" % (str_pattern_matches, + str_found, + str_match) else: - status = "{0} ({1} {2} {3})".format( - str_pattern_matches, - str_found, - len(allmatches), - str_matches, - ) + status = "%s (%s %d %s)" % (str_pattern_matches, + str_found, + len(allmatches), + str_matches) self.update_results(status, MATCH_OK) self.populate_code_textbrowser() @@ -680,7 +596,6 @@ def timeout(signum, frame): if self.replace: self.populate_replace_textbrowser(spans, len(allmatches), compile_obj) self.populate_matchAll_textbrowser(spans) - return def findAllSpans(self, compile_obj): @@ -709,7 +624,7 @@ def closeEvent(self, ev): ev.ignore() return - saveWindowSettings(self, GEO) + util.saveWindowSettings(self, GEO) try: self.regexlibwin.close() @@ -721,7 +636,6 @@ def closeEvent(self, ev): except: pass ev.accept() - return def fileNew(self): @@ -734,68 +648,54 @@ def fileNew(self): self.replaceTextEdit.setPlainText("") self.set_flags(0) self.editstate = STATE_UNEDITED - return def importURL(self): - self.urldialog = URLDialog(url=self.url, parent=self) + self.urldialog = urlDialog.URLDialog(self, self.url) self.urldialog.urlImported.connect(self.urlImported) - return def urlImported(self, html, url): self.url = url self.stringMultiLineEdit.setPlainText(html) - return def importFile(self): - fn = QtGui.QFileDialog.getOpenFileName( - self, - self.tr("Import File"), - self.filename, - self.tr("All (*)") - ) - - if fn.isEmpty(): - self.updateStatus( - self.tr("A file was not selected for import"), - -1, - 5, - TRUE - ) - return None + filename = Qt.QFileDialog.getOpenFileName(self, + self.tr("Import File"), + self.filename, + self.tr("All (*)")) - filename = str(fn) + if filename == "" : + self.updateStatus(self.tr("A file was not selected for import"), + -1, + 5, + True) + return None try: fp = open(filename, "r") except: msg = self.tr("Could not open file for reading: ") + filename - self.updateStatus(msg, -1, 5, TRUE) + self.updateStatus(msg, -1, 5, True) return None data = fp.read() fp.close() self.stringMultiLineEdit.setPlainText(data) - return def fileOpen(self): filename = self.filename if filename == None: filename = "" - fn = QtGui.QFileDialog.getOpenFileName( - self, - self.tr("Open Kodos File"), - filename, - self.tr("Kodos file (*.kds);;All (*)") - ) - if not fn.isEmpty(): - filename = str(fn) + filename = Qt.QFileDialog.getOpenFileName(self, + self.tr("Open Kodos File"), + filename, + self.tr("Kodos file (*.kds);;All (*)")) + if filename != "": if self.openFile(filename): self.recent_files.add(filename) - return def openFile(self, filename): @@ -805,10 +705,10 @@ def openFile(self, filename): self.filename = None try: - fp = open(filename, "r") + fp = open(filename, "rb") except: msg = self.tr("Could not open file for reading: ") + filename - self.updateStatus(msg, -1, 5, TRUE) + self.updateStatus(msg, -1, 5, True) return None try: @@ -817,12 +717,10 @@ def openFile(self, filename): self.matchstring = u.load() flags = u.load() except Exception as e: #FIXME: don't catch everything - if self.debug: - print(unicode(e)) - msg = unicode( - self.tr("Error reading from file: {filename}") - ).format(filename=filename) - self.updateStatus(msg, -1, 5, TRUE) + self.log.error('Error unpickling data from file: %s' % e) + msg = "%s %s" % (str(self.tr("Error reading from file:")), + filename) + self.updateStatus(msg, -1, 5, True) return 0 self.matchNumberSpinBox.setValue(1) @@ -841,10 +739,8 @@ def openFile(self, filename): self.replaceTextEdit.setPlainText(replace) self.filename = filename - msg = unicode(self.tr("{filename} loaded successfully")).format( - filename=filename - ) - self.updateStatus(msg, -1, 5, TRUE) + msg = "%s %s" % (filename, str(self.tr("loaded successfully"))) + self.updateStatus(msg, -1, 5, True) self.editstate = STATE_UNEDITED return 1 @@ -853,25 +749,22 @@ def fileSaveAs(self): filename = self.filename if filename == None: filename = "" - filedialog = QtGui.QFileDialog( - self, - self.tr("Save Kodos File"), - filename, - "Kodos file (*.kds);;All (*)" - ) - filedialog.setAcceptMode(QtGui.QFileDialog.AcceptSave) + filedialog = Qt.QFileDialog(self, + self.tr("Save Kodos File"), + filename, + "Kodos file (*.kds);;All (*)") + filedialog.setAcceptMode(Qt.QFileDialog.AcceptSave) filedialog.setDefaultSuffix("kds") ok = filedialog.exec_() - if ok == QtGui.QDialog.Rejected: - self.updateStatus(self.tr("No file selected to save"), -1, 5, TRUE) + if ok == Qt.QDialog.Rejected: + self.updateStatus(self.tr("No file selected to save"), -1, 5, True) return - filename = os.path.normcase(unicode(filedialog.selectedFiles().first())) + filename = os.path.normcase(str(filedialog.selectedFiles()[0])) self.filename = filename self.fileSave() - return def fileSave(self): @@ -880,12 +773,11 @@ def fileSave(self): return try: - fp = open(self.filename, "w") + fp = open(self.filename, "wb") except: - msg = unicode(self.tr( - "Could not open file for writing: {filename}" - )).format(filename=self.filename) - self.updateStatus(msg, -1, 5, TRUE) + msg = "%s: %s" % (str(self.tr("Could not open file for writing:")), + self.filename) + self.updateStatus(msg, -1, 5, True) return None self.editstate = STATE_UNEDITED @@ -896,17 +788,14 @@ def fileSave(self): p.dump(self.replace) fp.close() - msg = unicode(self.tr("{filename} successfully saved")).format( - filename=unicode(self.filename) - ) - self.updateStatus(msg, -1, 5, TRUE) + msg = "%s %s" % (str(self.filename), + str(self.tr("successfully saved"))) + self.updateStatus(msg, -1, 5, True) self.recent_files.add(self.filename) - return def paste_symbol(self, symbol): self.regexMultiLineEdit.insertPlainText(symbol) - return def process_embedded_flags(self, regex): @@ -925,26 +814,23 @@ def process_embedded_flags(self, regex): f.embed() else: f.deembed() - return def checkEditState(self): if self.editstate == STATE_EDITED: message = self.tr("You have made changes. Would you like to save them before continuing?") - prompt = QtGui.QMessageBox.warning( - None, - self.tr("Save changes?"), - message, - QtGui.QMessageBox.Save | - QtGui.QMessageBox.Cancel | - QtGui.QMessageBox.Discard - ) + prompt = Qt.QMessageBox.warning(None, + self.tr("Save changes?"), + message, + Qt.QMessageBox.Save | + Qt.QMessageBox.Cancel | + Qt.QMessageBox.Discard) - if prompt == QtGui.QMessageBox.Cancel: + if prompt == Qt.QMessageBox.Cancel: return False - if prompt == QtGui.QMessageBox.Save: + if prompt == Qt.QMessageBox.Save: self.fileSave() if not self.filename: self.checkEditState() @@ -967,7 +853,6 @@ def pasteFromRegexLib(self, d): except KeyError: pass self.editstate = STATE_UNEDITED - return def revert_file_slot(self): @@ -975,15 +860,14 @@ def revert_file_slot(self): self.updateStatus(self.tr("There is no filename to revert"), -1, 5, - TRUE) + True) return self.openFile(self.filename) - return def getWidget(self): - widget = QtGui.QApplication.focusWidget() + widget = self.qApp.focusWidget() if (widget == self.regexMultiLineEdit or widget == self.stringMultiLineEdit or widget == self.replaceTextEdit or @@ -997,56 +881,42 @@ def widgetMethod(self, methodstr, anywidget=0): # execute the methodstr of widget only if widget # is one of the editable widgets OR if the method # may be applied to any widget. - widget = QtGui.QApplication.focusWidget() + widget = self.qApp.focusWidget() if anywidget or ( widget == self.regexMultiLineEdit or widget == self.stringMultiLineEdit or widget == self.replaceTextEdit or widget == self.codeTextBrowser): try: - eval("widget.{0}".format(methodstr)) + eval("widget.%s" % methodstr) except: pass - return def editUndo(self): self.widgetMethod("undo()") - return - def editRedo(self): self.widgetMethod("redo()") - return - def editCopy(self): self.widgetMethod("copy()", 1) - return - def editCut(self): self.widgetMethod("cut()") - return - def editPaste(self): self.widgetMethod("paste()") - return def preferences(self): self.prefs.showPrefsDialog() self.prefs.prefsSaved.connect(self.prefsSaved) - return - def setfont(self, font): self.regexMultiLineEdit.setFont(font) self.stringMultiLineEdit.setFont(font) self.replaceTextEdit.setFont(font) - return - def setMatchFont(self, font): self.groupTable.setFont(font) @@ -1054,7 +924,6 @@ def setMatchFont(self, font): self.matchAllTextBrowser.setFont(font) self.replaceTextBrowser.setFont(font) self.codeTextBrowser.setFont(font) - return def getfont(self): @@ -1066,185 +935,47 @@ def getMatchFont(self): def helpHelp(self): - self.helpWindow = Help(filename="kodos.html", parent=self) - return + self.helpWindow = help.Help(self, "kodos.html") def helpPythonRegex(self): - self.helpWindow = Help(filename=os.path.join("python", "module-re.html"), parent=self) - return + self.helpWindow = help.Help(self, os.path.join("python", "module-re.html")) def helpRegexLib(self): f = os.path.join("help", "regex-lib.xml") - self.regexlibwin = RegexLibrary(filename=f, parent=self) + self.regexlibwin = regexLibrary.RegexLibrary(f) self.regexlibwin.pasteRegexLib.connect(self.pasteFromRegexLib) self.regexlibwin.show() - return def helpAbout(self): - self.aboutWindow = About() + self.aboutWindow = about.About() self.aboutWindow.show() - return def kodos_website(self): - self.launch_browser_wrapper("http://kodos.sourceforge.net") - return - - - def check_for_update(self): - url = "http://sourceforge.net/project/showfiles.php?group_id=43860" - try: - fp = urllib.urlopen(url) - except: - self.status_bar.set_message(self.tr("Failed to open url"), - 5, - TRUE) - return - - lines = fp.readlines() - html = string.join(lines) - - rawstr = r"""kodos-(?P.*?)\.\w{3,4}\<""" - match_obj = re.search(rawstr, html) - if match_obj: - latest_version = match_obj.group('version') - if latest_version == VERSION: - QtGui.QMessageBox.information( - None, - self.tr("No Update is Available"), - unicode(self.tr( - "You are currently using the latest version of Kodos ({version})" - )).format(version=VERSION) - ) - else: - message = "{0}\n\n{1}\n{2}\n\n{3}\n".format( - unicode(self.tr("There is a newer version of Kodos available.")), - unicode(self.tr("You are using version: {version}." - )).format(version=VERSION), - unicode(self.tr("The latest version is: {version}." - )).format(version=latest_version), - unicode(self.tr("Press OK to launch browser")), - ) - - self.launch_browser_wrapper(url, - self.tr("Kodos Update Available"), - message) - else: - message = "{0}\n\n{1}".format( - unicode(self.tr("Unable to get version info from Sourceforge.")), - unicode(self.tr("Press OK to launch browser")), - ) - self.launch_browser_wrapper(url, - self.tr("Unknown version available"), - message) - return + self.launch_browser_wrapper('https://github.com/luksan/kodos', + message=self.tr('Launch web browser to go to the kodos project page?')) def launch_browser_wrapper(self, url, caption=None, message=None): - if launch_browser(url, caption, message): + if util.launch_browser(url, caption, message): self.status_bar.set_message(self.tr("Launching web browser"), 3, - TRUE) + True) else: self.status_bar.set_message(self.tr("Cancelled web browser launch"), 3, - TRUE) - return + True) def reference_guide(self): - self.ref_win = Reference(self) + self.ref_win = reference.Reference(self) self.ref_win.pasteSymbol.connect(self.paste_symbol) self.ref_win.show() - return def report_bug(self): - self.bug_report_win = reportBugWindow(self) - return - - -############################################################################## -# -# -############################################################################## - -def usage(): - print("kodos.py [-f filename | --file=filename ] [ -d debug | --debug=debug ] [ -k kodos_dir ]") - print('') - print(" -f filename | --filename=filename : Load filename on startup") - print(" -d debug | --debug=debug : Set debug to this debug level") - print(" -k kodos_dir : Path containing Kodos images & help subdirs") - print(" -l locale | --locale=locale : 2-letter locale (eg. en)") - print('') - return - - -def main(): - filename = None - debug = 0 - kodos_dir = os.path.join(sys.prefix, "kodos") - locale = None - - args = sys.argv[1:] - try: - (opts, getopts) = getopt.getopt(args, 'd:f:k:l:?h', - ["file=", "debug=", - "help", "locale="]) - except: - print("\nInvalid command line option detected.") - usage() - return 2 - - for opt, arg in opts: - if opt in ('-h', '-?', '--help'): - usage() - return 0 - if opt == '-k': - kodos_dir = arg - if opt in ('-d', '--debug'): - try: - debug = int(arg) - except: - print("debug value must be an integer") - usage() - return 2 - if opt in ('-f', '--file'): - filename = arg - if opt in ('-l', '--locale'): - locale = arg - - os.environ['KODOS_DIR'] = kodos_dir - - qApp = QtGui.QApplication(sys.argv) - qApp.setOrganizationName("kodos") - qApp.setApplicationName("kodos") - qApp.setOrganizationDomain("kodos.sourceforge.net") - - if locale not in (None, 'en'): - localefile = "kodos_{0}.qm".format(locale or QtCore.QTextCodec.locale()) - localepath = findFile(os.path.join("translations", localefile)) - if debug: - print("locale changed to: {0}".format(locale)) - print(localefile) - print(localepath) - - translator = QtCore.QTranslator(qApp) - translator.load(localepath) - - qApp.installTranslator(translator) - - kodos = Kodos(filename, debug) - - kodos.show() - - return qApp.exec_() - - -if __name__ == '__main__': - sys.exit(main()) - -#-----------------------------------------------------------------------------# + self.launch_browser_wrapper('https://github.com/luksan/kodos/issues', + message=self.tr("Launch web browser to report a bug in kodos?")) diff --git a/modules/newUserDialogBA.ui b/kodos/newUserDialogBA.ui similarity index 100% rename from modules/newUserDialogBA.ui rename to kodos/newUserDialogBA.ui diff --git a/modules/parseRegexLib.py b/kodos/parseRegexLib.py similarity index 63% rename from modules/parseRegexLib.py rename to kodos/parseRegexLib.py index 4f55955..83af6ab 100644 --- a/modules/parseRegexLib.py +++ b/kodos/parseRegexLib.py @@ -1,19 +1,7 @@ -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -#-----------------------------------------------------------------------------# -# Built-in modules - import re import os +from . import util -#-----------------------------------------------------------------------------# -# Kodos modules - -from .util import findFile - -#-----------------------------------------------------------------------------# rx_entry = re.compile(r"(?P.*?)", re.DOTALL) @@ -37,20 +25,18 @@ class ParseRegexLib: def __init__(self, filename): if filename: - path = findFile(os.path.join("help", "regex-lib.xml")) + path = util.findFile(os.path.join("help", "regex-lib.xml")) data = open(path).read() self.data = data else: self.data = "" - return - def parse(self, data=""): if not data: data = self.data dicts = [] allmatches = rx_entry.findall(data) - rx_keys = RX_DICT.keys() + rx_keys = list(RX_DICT.keys()) for match in allmatches: d = {} for key in rx_keys: @@ -64,13 +50,12 @@ def parse(self, data=""): return dicts - if __name__ == '__main__': - path = findFile(os.path.join("help", "regex-lib.xml")) + path = util.findFile(os.path.join("help", "regex-lib.xml")) x = ParseRegexLib(path) dicts = x.parse() print(dicts) -#-----------------------------------------------------------------------------# + diff --git a/kodos/prefs.py b/kodos/prefs.py new file mode 100644 index 0000000..60a481c --- /dev/null +++ b/kodos/prefs.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- +# prefs.py: -*- Python -*- DESCRIPTIVE TEXT. + +import logging + +from PyQt4.QtCore import pyqtSignal, QSettings +from PyQt4.QtGui import QDialog, QFontDialog +from . import prefsBA +from . import help + +class Preferences(prefsBA.PrefsBA): + + prefsSaved = pyqtSignal() + + def __init__(self, parent, autoload=0): + self.log = logging.getLogger('kodos.prefs') + self.parent = parent + prefsBA.PrefsBA.__init__(self, parent) + + self.settings = QSettings() + + if autoload: + self.load() + + def load(self): + for preference in self.settings.childKeys(): + try: + setting = self.settings.value(preference) + if preference == 'Font': + self.parent.setfont(setting.toPyObject()) + if preference == 'Match Font': + self.parent.setMatchFont(setting.toPyObject()) + if preference == 'Recent Files Count': + self.recentFilesSpinBox.setValue(int(setting.toPyObject())) + except Exception as e: + self.log.error('Loading of configuration key %s failed: %s' % + (preference, e)) + self.settings.remove(preference) + + + def save(self): + self.settings.setValue('Font', self.parent.getfont()) + self.settings.setValue('Match Font', self.parent.getMatchFont()) + self.settings.setValue('Recent Files Count', self.recentFilesSpinBox.text()) + + self.settings.sync() + self.prefsSaved.emit() + + def setFontButtonText(self, button, font): + #self.fontButton.setText("%s %s" % (str(font.family()),font.pointSize() )) + button.setText("%s %s" % (str(font.family()),font.pointSize() )) + + def showPrefsDialog(self): + f = self.parent.getfont() + self.fontButton.setFont(f) + self.setFontButtonText(self.fontButton, f) + + f = self.parent.getMatchFont() + self.fontButtonMatch.setFont(f) + self.setFontButtonText(self.fontButtonMatch, f) + + self.show() + + def font_slot(self): + (font, ok) = QFontDialog.getFont(self.fontButton.font()) + if ok: + self.fontButton.setFont(font) + self.setFontButtonText(self.fontButton, font) + + def match_font_slot(self): + (font, ok) = QFontDialog.getFont(self.fontButtonMatch.font()) + if ok: + self.fontButtonMatch.setFont(font) + self.setFontButtonText(self.fontButtonMatch, font) + + def apply_slot(self): + self.parent.setfont(self.fontButton.font()) + self.parent.setMatchFont(self.fontButtonMatch.font()) + self.save() + + def accept(self): + self.apply_slot() + QDialog.accept(self) + + def help_slot(self): + self.helpWindow = help.Help(self, "prefs.html") + diff --git a/modules/prefsBA.ui b/kodos/prefsBA.ui similarity index 84% rename from modules/prefsBA.ui rename to kodos/prefsBA.ui index c5c8586..d2f2290 100644 --- a/modules/prefsBA.ui +++ b/kodos/prefsBA.ui @@ -7,7 +7,7 @@ 0 0 540 - 268 + 145 @@ -22,7 +22,7 @@ 11 6 519 - 246 + 131 @@ -44,13 +44,6 @@ - - - - - - - @@ -61,18 +54,22 @@ - + - - + + + + + + - - + + 0 @@ -80,30 +77,30 @@ - Email Server: + Recent Files: false - - + + - + 0 0 - - Recent Files: + + 25 - - false + + 5 - + Qt::Horizontal @@ -119,40 +116,8 @@ - - - - - 0 - 0 - - - - 25 - - - 5 - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 40 - - - - @@ -228,8 +193,6 @@ fontButton - emailServerEdit - recentFilesSpinBox buttonHelp buttonApply buttonOk diff --git a/modules/recent_files.py b/kodos/recent_files.py similarity index 51% rename from modules/recent_files.py rename to kodos/recent_files.py index 83cb3a7..42a136d 100644 --- a/modules/recent_files.py +++ b/kodos/recent_files.py @@ -1,58 +1,49 @@ -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: +# -*- coding: utf-8 -*- -#-----------------------------------------------------------------------------# -# Installed modules +import logging -from PyQt4 import QtGui, QtCore - -#-----------------------------------------------------------------------------# +from PyQt4.QtGui import QIcon, QPixmap +from PyQt4.QtCore import QSettings MAX_SIZE = 50 # max number of files to retain class RecentFiles: - def __init__(self, parent, numShown=5, debug=None): + def __init__(self, parent, numShown=5): + self.log = logging.getLogger('kodos.recent_files') self.parent = parent self.numShown = int(numShown) - self.debug = debug self.__recent_files = [] self.__indecies = [] self.load() - return - def load(self): - settings = QtCore.QSettings() - # PyQt-BUG: beginReadArray() should return array size but returns always 0 - # as a workaround we loop until a value is "None". - settings.beginReadArray("RecentFiles") + settings = QSettings() + cnt = settings.beginReadArray("RecentFiles") + # PyQt bug: cnt is always 0, workaround with "None" test below i = -1 while True: i += 1 settings.setArrayIndex(i) try: - s = settings.value("Filename").toPyObject() + s = settings.value("Filename") if s == None: break self.__recent_files.append(str(s)) except Exception as e: - print("Loading of recent file entry {0} failed.".format(i)) - if self.debug: print(e) + self.log.error('Loading of recent file entry %i failed: %s' % + (i, e)) settings.remove("Filename") settings.endArray() - if self.debug: print("recent_files: {0}".format(self.__recent_files)) + self.log.debug("recent_files: %s" % self.__recent_files) self.addToMenu() - return - def save(self): # truncate list if necessary self.__recent_files = self.__recent_files[:MAX_SIZE] - s = QtCore.QSettings() + s = QSettings() s.beginWriteArray("RecentFiles") cnt = 0 for f in self.__recent_files: @@ -60,8 +51,6 @@ def save(self): s.setValue("Filename", f) cnt += 1 s.sync() - return - def add(self, filename): try: @@ -72,7 +61,6 @@ def add(self, filename): self.__recent_files.insert(0, filename) self.save() self.addToMenu() - return def clearMenu(self): @@ -82,7 +70,6 @@ def clearMenu(self): # clear list of menu entry indecies self.__indecies = [] - return def addToMenu(self, clear=1): @@ -93,11 +80,10 @@ def addToMenu(self, clear=1): for i in range(num): filename = self.__recent_files[i] idx = self.parent.fileMenu.addAction( - QtGui.QIcon(QtGui.QPixmap(":images/document-open-recent.png")), + QIcon(QPixmap(":images/document-open-recent.png")), filename) self.__indecies.insert(0, idx) - return def setNumShown(self, numShown): @@ -108,30 +94,8 @@ def setNumShown(self, numShown): self.clearMenu() self.numShown = ns self.addToMenu(0) - return def isRecentFile(self, menuid): return menuid in self.__indecies - -""" - def move(self, filename, menuid): - # fix me.... - menu = self.parent.fileMenu - idx = menu.indexOf(self.__indecies[0]) - menu.removeItem(menuid) - # FIXME there is no QIconSet - menu.insertItem(QIconSet(QtGui.QPixmap(":images/document-open-recent.png")), - filename, - -1, - idx) - try: - self.__recent_files.remove(filename) - except: - pass - self.__indecies.insert(0, filename) - return -""" - -#-----------------------------------------------------------------------------# diff --git a/kodos/reference.py b/kodos/reference.py new file mode 100644 index 0000000..927ce41 --- /dev/null +++ b/kodos/reference.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +# reference.py: -*- Python -*- DESCRIPTIVE TEXT. + +from PyQt4.QtCore import pyqtSignal +from . import referenceBA +from .util import kodos_toolbar_logo, restoreWindowSettings, saveWindowSettings + +GEO = "regex-ref_geometry" + +class Reference(referenceBA.ReferenceBA): + + pasteSymbol = pyqtSignal(str) + + def __init__(self, parent): + referenceBA.ReferenceBA.__init__(self, None) + self.parent = parent + + restoreWindowSettings(self, GEO) + kodos_toolbar_logo(self.toolBar) + + + def closeEvent(self, ev): + saveWindowSettings(self, GEO) + ev.accept() + + + def editPaste(self): + list_view_item = self.referenceListView.currentItem() + if list_view_item == None: + return + + symbol = str(list_view_item.text(0)) + self.pasteSymbol.emit(symbol) + + + def help_slot(self): + self.parent.helpHelp() + + def help_python_slot(self): + self.parent.helpPythonRegex() diff --git a/modules/referenceBA.ui b/kodos/referenceBA.ui similarity index 99% rename from modules/referenceBA.ui rename to kodos/referenceBA.ui index be51648..b1c67e7 100644 --- a/modules/referenceBA.ui +++ b/kodos/referenceBA.ui @@ -357,7 +357,7 @@ &Help - + @@ -612,7 +612,7 @@ helpAboutAction - + :/images/help.png:/images/help.png @@ -624,7 +624,7 @@ Help - helpHelpAction + helpAction @@ -677,10 +677,10 @@ - helpHelpAction + helpAction activated() ReferenceBA - help_help_slot() + help_slot() -1 diff --git a/kodos/regexLibrary.py b/kodos/regexLibrary.py new file mode 100644 index 0000000..abce53b --- /dev/null +++ b/kodos/regexLibrary.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +from PyQt4.QtCore import pyqtSignal +from . import regexLibraryBA +from . import parseRegexLib +from .util import restoreWindowSettings, saveWindowSettings, kodos_toolbar_logo + +GEO = "regex-lib_geometry" + +class RegexLibrary(regexLibraryBA.RegexLibraryBA): + + pasteRegexLib = pyqtSignal(dict) + + def __init__(self, filename): + regexLibraryBA.RegexLibraryBA.__init__(self, None) + self.filename = filename + self.selected = None + + self.parseXML() + + self.populateListBox() + kodos_toolbar_logo(self.toolBar) + + restoreWindowSettings(self, GEO) + + def closeEvent(self, ev): + saveWindowSettings(self, GEO) + ev.accept() + + + def parseXML(self): + parser = parseRegexLib.ParseRegexLib(self.filename) + self.xml_dicts = parser.parse() + + + def populateListBox(self): + for d in self.xml_dicts: + self.descriptionListBox.addItem(d.get('desc', "")) + + + def descSelectedSlot(self, qlistboxitem): + if qlistboxitem == None: return + + itemnum = self.descriptionListBox.currentRow() + self.populateSelected(self.xml_dicts[itemnum]) + + + def populateSelected(self, xml_dict): + self.regexTextBrowser.setPlainText(xml_dict.get('regex', "")) + self.contribEdit.setText(xml_dict.get("contrib", "")) + self.noteTextBrowser.setPlainText(xml_dict.get('note', "")) + self.selected = xml_dict + + + def editPaste(self): + if self.selected: + self.pasteRegexLib.emit(self.selected) + + + + + diff --git a/modules/regexLibraryBA.ui b/kodos/regexLibraryBA.ui similarity index 93% rename from modules/regexLibraryBA.ui rename to kodos/regexLibraryBA.ui index e603017..ecd6673 100644 --- a/modules/regexLibraryBA.ui +++ b/kodos/regexLibraryBA.ui @@ -224,12 +224,6 @@ - - helpHelpAction - activated() - RegexLibraryBA - help_help_slot() - descSelectedSlot() diff --git a/modules/status_bar.py b/kodos/status_bar.py similarity index 53% rename from modules/status_bar.py rename to kodos/status_bar.py index 0e8298f..d1abeaa 100644 --- a/modules/status_bar.py +++ b/kodos/status_bar.py @@ -1,52 +1,41 @@ -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: +# -*- coding: utf-8 -*- +# status_bar.py: -*- Python -*- DESCRIPTIVE TEXT. -#-----------------------------------------------------------------------------# -# Installed modules - -from PyQt4 import QtGui, QtCore - -#-----------------------------------------------------------------------------# -# Kodos modules - -from .tooltip import Tooltip -from .util import TRUE, FALSE - -#-----------------------------------------------------------------------------# +from . import tooltip +from PyQt4.QtCore import QTimer +from PyQt4.QtGui import QPixmap, QLabel, QProgressBar class Status_Bar: - def __init__(self, parent, progress_bar=FALSE, message=''): + def __init__(self, parent, progress_bar=False, message=''): self.parent = parent self.statusBar = parent.statusBar() - self.__statusTimer = QtCore.QTimer(self.parent) + self.__statusTimer = QTimer(self.parent) self.__statusTimer.timeout.connect(self.reset_message) - self.__statusLabel = QtGui.QLabel("msg", self.statusBar) - self.tooltip = Tooltip('') + self.__statusLabel = QLabel("msg", self.statusBar) + self.tooltip = tooltip.Tooltip('') self.tooltip.addWidget(self.__statusLabel) self.last_status_message = '' - pixmap = QtGui.QPixmap(":images/yellow.png") + pixmap = QPixmap(":images/yellow.png") - self.pixmapLabel = QtGui.QLabel("image", self.statusBar) + self.pixmapLabel = QLabel("image", self.statusBar) self.pixmapLabel.setPixmap(pixmap) self.statusBar.addWidget(self.pixmapLabel) self.statusBar.addWidget(self.__statusLabel) if progress_bar: - self.progressBar = QtGui.QProgressBar(self.statusBar) - self.statusBar.addWidget(self.progressBar, 1, TRUE) + self.progressBar = QProgressBar(self.statusBar) + self.statusBar.addWidget(self.progressBar, 1, True) if message: self.set_message(message) - return - def set_message(self, message='', duration=0, replace=FALSE, tooltip='', pixmap=''): + def set_message(self, message='', duration=0, replace=False, tooltip='', pixmap=''): """sets the status bar message label to message. if duration is > 0 than the message is displayed for duration seconds. @@ -56,7 +45,7 @@ def set_message(self, message='', duration=0, replace=FALSE, tooltip='', pixmap= """ self.__statusTimer.stop() - self.last_status_message = unicode(self.__statusLabel.text()) + self.last_status_message = str(self.__statusLabel.text()) self.replace_status_message = replace self.__statusLabel.setText(message) @@ -72,7 +61,7 @@ def set_message(self, message='', duration=0, replace=FALSE, tooltip='', pixmap= if pixmap: self.pixmapLabel.setPixmap(pixmap) - return + def reset_message(self): @@ -81,10 +70,8 @@ def reset_message(self): self.__statusLabel.setText(self.last_status_message) else: self.__statusLabel.setText('') - return + def geometry(self): return self.statusBar.geometry() - -#-----------------------------------------------------------------------------# diff --git a/modules/tooltip.py b/kodos/tooltip.py similarity index 50% rename from modules/tooltip.py rename to kodos/tooltip.py index 51e646b..539051f 100644 --- a/modules/tooltip.py +++ b/kodos/tooltip.py @@ -1,73 +1,49 @@ -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: +# -*- coding: utf-8 -*- +# tooltip.py: -*- Python -*- DESCRIPTIVE TEXT. -#-----------------------------------------------------------------------------# -# Installed modules +from PyQt4 import Qt, QtCore -from PyQt4 import QtGui, QtCore - -#-----------------------------------------------------------------------------# -# Kodos modules - -from .util import FALSE - -#-----------------------------------------------------------------------------# - -class Tooltip(QtGui.QLabel): +class Tooltip(Qt.QLabel): def __init__(self, text, bgcolor="#ffd700",fgcolor="#000000",delay=1000): self.delay = delay - QtGui.QLabel.__init__( - self, - None, - QtCore.Qt.WindowStaysOnTopHint | - QtCore.Qt.FramelessWindowHint | - QtCore.Qt.Tool - ) + Qt.QLabel.__init__(self, None, QtCore.Qt.WindowStaysOnTopHint + | QtCore.Qt.FramelessWindowHint + | QtCore.Qt.Tool) self.setMargin(1) self.setIndent(0) - self.setFrameStyle(QtGui.QFrame.Plain | QtGui.QFrame.Box) + self.setFrameStyle(Qt.QFrame.Plain | Qt.QFrame.Box) self.setLineWidth(1) self.setText(text) self.adjustSize() # set the pallete... - pal = QtGui.QPalette() - pal.setColor(QtGui.QPalette.Active, QtGui.QPalette.Window, - QtGui.QColor(bgcolor)) - pal.setColor(QtGui.QPalette.Active, QtGui.QPalette.WindowText, - QtGui.QColor(fgcolor)) - pal.setColor(QtGui.QPalette.Inactive, QtGui.QPalette.Window, - QtGui.QColor(bgcolor)) - pal.setColor(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, - QtGui.QColor(fgcolor)) + pal = Qt.QPalette() + pal.setColor(Qt.QPalette.Active, Qt.QPalette.Window, Qt.QColor(bgcolor)) + pal.setColor(Qt.QPalette.Active, Qt.QPalette.WindowText, Qt.QColor(fgcolor)) + pal.setColor(Qt.QPalette.Inactive, Qt.QPalette.Window, Qt.QColor(bgcolor)) + pal.setColor(Qt.QPalette.Inactive, Qt.QPalette.WindowText, Qt.QColor(fgcolor)) self.setPalette(pal) self.enter_timer_id = None self.leave_timer_id = None - return def set_tooltip(self, text): self.text = text self.setText(text) - return def clear_tooltip(self): self.text = '' self.setText('') - return def addWidget(self, widget): widget.installEventFilter(self) - return def removeWidget(self, widget): widget.removeEventFilter(self) - return def killCustomTimers( self ): @@ -77,7 +53,6 @@ def killCustomTimers( self ): if self.leave_timer_id: self.killTimer( self.leave_timer_id ) self.leave_timer_id = None - return def timerEvent( self, ev ): @@ -86,20 +61,19 @@ def timerEvent( self, ev ): elif ev.timerId() == self.leave_timer_id: self.tooltip_close() self.killCustomTimers() - return def eventFilter(self, obj, ev): type = ev.type() - if type == QtCore.QEvent.Enter: + if type == Qt.QEvent.Enter: self.killCustomTimers() self.enter_timer_id = self.startTimer(self.delay) self.event_widget = obj - elif type == QtCore.QEvent.Leave: + elif type == Qt.QEvent.Leave: self.killCustomTimers() self.leave_timer_id = self.startTimer(self.delay) self.event_widget = None - return FALSE ## Always return unhandled for this kind of filter!!! + return False ## Always return unhandled for this kind of filter!!! def tooltip_open(self): @@ -108,17 +82,13 @@ def tooltip_open(self): try: pos = self.event_widget.mapToGlobal( - QtCore.QPoint(0, self.event_widget.height())) + Qt.QPoint(0, self.event_widget.height())) self.move(pos.x(), pos.y()) self.show() self.setFixedSize( self.sizeHint() ) except: pass - return def tooltip_close(self): self.hide() - return - -#-----------------------------------------------------------------------------# diff --git a/kodos/urlDialog.py b/kodos/urlDialog.py new file mode 100644 index 0000000..1a2969d --- /dev/null +++ b/kodos/urlDialog.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- + +from PyQt4.QtCore import pyqtSignal +from PyQt4.QtGui import QMessageBox +from . import urlDialogBA +from . import help +import urllib.request + + +class URLDialog(urlDialogBA.URLDialogBA): + + urlImported = pyqtSignal(str, str) + + def __init__(self, parent, url=None): + urlDialogBA.URLDialogBA.__init__(self, parent) + if url: + self.URLTextEdit.setPlainText(url) + + self.show() + + def help_slot(self): + self.helpWindow = help.Help(self, "importURL.html") + + def ok_slot(self): + url = self.URLTextEdit.toPlainText() + try: + fp = urllib.request.urlopen(url) + charset = fp.info().get_content_charset() or "utf-8" + html = fp.read().decode(charset) + except Exception as e: + QMessageBox.information(None, "Failed to open URL", + "Could not open the specified URL. Please check to ensure that you have entered the correct URL.\n\n%s" % str(e)) + return + + + self.urlImported.emit(html, url) + + urlDialogBA.URLDialogBA.accept(self) diff --git a/modules/urlDialogBA.ui b/kodos/urlDialogBA.ui similarity index 100% rename from modules/urlDialogBA.ui rename to kodos/urlDialogBA.ui diff --git a/kodos/util.py b/kodos/util.py new file mode 100644 index 0000000..957d3bd --- /dev/null +++ b/kodos/util.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +# util.py: -*- Python -*- DESCRIPTIVE TEXT. + +import os +import sys +import logging +import webbrowser + +from PyQt4 import Qt + +log = logging.getLogger('kodos.util') + +def getAppPath(): + "Convenience function so that we can find the necessary images" + fullpath = os.path.abspath(os.path.join(sys.argv[0], '..')) + path = os.path.dirname(fullpath) + return path + + +def getPixmap(fileStr, fileType="PNG", dir="images"): + """Return a Qt.QPixmap instance for the file fileStr relative + to the binary location and residing in it's 'images' subdirectory""" + + image = getAppPath() + os.sep + dir + os.sep + fileStr + pixmap = Qt.QPixmap(image, fileType) + pixmap.setMask(pixmap.createHeuristicMask(1)) + + return pixmap + +def kodos_toolbar_logo(toolbar): + # hack to move logo to right + blanklabel = Qt.QLabel() + blanklabel.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Preferred) + + logolabel = Qt.QLabel("kodos_logo") + logolabel.setPixmap(Qt.QPixmap(":/images/kodos_icon.png")) + + toolbar.addWidget(blanklabel) + toolbar.addWidget(logolabel) + + return logolabel + +def saveWindowSettings(window, filename): + settings = Qt.QSettings() + settings.setValue(window.objectName(), window.saveGeometry()) + +def restoreWindowSettings(window, filename): + settings = Qt.QSettings() + #window.restoreGeometry(settings.value(window.objectName()).toByteArray()) + +def findFile(filename): + dirs = [getAppPath(), + os.path.join("/", "usr", "share", "kodos"), + os.path.join("/", "usr", "local", "kodos")] + + for d in dirs: + path = os.path.join(d, filename) + if os.access(path, os.R_OK): return path + + return None + +def launch_browser(url, caption=None, message=None): + if not caption: caption = "Info" + if not message: message = "Launch web browser?" + + button = Qt.QMessageBox.information(None, caption, message, Qt.QMessageBox.Ok | Qt.QMessageBox.Cancel) + if button == Qt.QMessageBox.Cancel: + return False + try: + webbrowser.open(url) + except webbrowser.Error as e: + log.error("Couldn't open URL %r: %s" % (url, e)) + return False + return True diff --git a/kodos/version.py b/kodos/version.py new file mode 100644 index 0000000..da47dcb --- /dev/null +++ b/kodos/version.py @@ -0,0 +1 @@ +VERSION="2.5.2" diff --git a/modules/__init__.py b/modules/__init__.py deleted file mode 100644 index 4e8bb24..0000000 --- a/modules/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# __init__.py: -*- Python -*- DESCRIPTIVE TEXT. -__all__ = [] diff --git a/modules/about.py b/modules/about.py deleted file mode 100644 index 1edc1c5..0000000 --- a/modules/about.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -#-----------------------------------------------------------------------------# -# Installed modules - -from PyQt4 import QtGui, QtCore - -#-----------------------------------------------------------------------------# -# Kodos modules - -from .aboutBA import Ui_AboutBA -from . import version - -#-----------------------------------------------------------------------------# - -class About(QtGui.QDialog, Ui_AboutBA): - def __init__(self, parent=None, f=QtCore.Qt.WindowFlags()): - QtGui.QDialog.__init__(self, parent, f) - self.setupUi(self) - - self.versionLabel.setText(version.VERSION) - return - -#-----------------------------------------------------------------------------# diff --git a/modules/debug.py b/modules/debug.py deleted file mode 100755 index 0b3cbb4..0000000 --- a/modules/debug.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -#-----------------------------------------------------------------------------# -# DEBUGGING CONSTANTS - -# debugging constants ... set debug to one of these -# if adding new debug levels make sure the new ones are -# a unique power of 2 (1, 2, 4, 8, 16...). Also, the new -# ones should be added to DEBUG_ALL -DEBUG_NONE = 0 -DEBUG_AUTO_COMPLETE = 1 -DEBUG_ANIMATE = 2 -DEBUG_CONNECT = 4 -DEBUG_SESSION = 8 -DEBUG_PIXMAP = 16 -DEBUG_HISTORY = 32 -DEBUG_SSTM = 64 -DEBUG_MISC = 128 -DEBUG_CMDLINE_ARGS = 256 -DEBUG_PRINT = 512 -DEBUG_PREFS = 1024 -DEBUG_PS_TPL = 2048 - -# convenience constant -DEBUG_ALL = ( - DEBUG_AUTO_COMPLETE | DEBUG_ANIMATE | - DEBUG_CONNECT | DEBUG_SESSION | - DEBUG_PIXMAP | DEBUG_HISTORY | - DEBUG_SSTM | DEBUG_MISC | DEBUG_CMDLINE_ARGS | - DEBUG_PRINT | DEBUG_PREFS | DEBUG_PS_TPL - ) - -# use a bitwise or (|) to use multiple debug levels -# debug = DEBUG_AUTO_COMPLETE | DEBUG_SESSION -debug = DEBUG_NONE - -#-----------------------------------------------------------------------------# diff --git a/modules/newUserDialog.py b/modules/newUserDialog.py deleted file mode 100644 index 227c158..0000000 --- a/modules/newUserDialog.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -#-----------------------------------------------------------------------------# -# Built-in modules - -from __future__ import absolute_import, print_function, unicode_literals - -#-----------------------------------------------------------------------------# -# Installed modules - -from PyQt4 import QtGui, QtCore - -#-----------------------------------------------------------------------------# -# Kodos modules - -from .newUserDialogBA import Ui_NewUserDialog - -#-----------------------------------------------------------------------------# - -class NewUserDialog(QtGui.QDialog, Ui_NewUserDialog): - def __init__(self, parent=None, f=QtCore.Qt.WindowFlags()): - QtGui.QDialog.__init__(self, parent, f) - - self.setupUi(self) - -#-----------------------------------------------------------------------------# diff --git a/modules/prefs.py b/modules/prefs.py deleted file mode 100644 index cc62aeb..0000000 --- a/modules/prefs.py +++ /dev/null @@ -1,114 +0,0 @@ -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -#-----------------------------------------------------------------------------# -# Installed modules - -from PyQt4 import QtGui, QtCore - -#-----------------------------------------------------------------------------# -# Kodos modules - -from .prefsBA import Ui_PrefsBA -from .help import Help - -#-----------------------------------------------------------------------------# - -class Preferences(QtGui.QDialog, Ui_PrefsBA): - - prefsSaved = QtCore.pyqtSignal() - - def __init__(self, autoload=0, parent=None, f=QtCore.Qt.WindowFlags()): - QtGui.QDialog.__init__(self, parent, f) - self.setupUi(self) - - self.parent = parent - self.settings = QtCore.QSettings() - if autoload: - self.load() - return - - - def load(self): - for preference in self.settings.childKeys(): - try: - setting = self.settings.value(preference) - if preference == 'Font': - self.parent.setfont(setting.toPyObject()) - if preference == 'Match Font': - self.parent.setMatchFont(setting.toPyObject()) - if preference == 'Email Server': - self.emailServerEdit.setText(setting.toPyObject()) - if preference == 'Recent Files Count': - self.recentFilesSpinBox.setValue(int(setting.toPyObject())) - except Exception: - print("Loading of configuration key {0} failed.".format(preference)) - self.settings.remove(preference) - return - - - def save(self): - self.settings.setValue('Font', self.parent.getfont()) - self.settings.setValue('Match Font', self.parent.getMatchFont()) - self.settings.setValue('Email Server', self.emailServerEdit.text()) - self.settings.setValue('Recent Files Count', self.recentFilesSpinBox.text()) - - self.settings.sync() - self.prefsSaved.emit() - return - - - def setFontButtonText(self, button, font): - #self.fontButton.setText("{0} {1}".format(str(font.family()), font.pointSize())) - button.setText("{0} {1}".format(str(font.family()), font.pointSize())) - return - - - def showPrefsDialog(self): - f = self.parent.getfont() - self.fontButton.setFont(f) - self.setFontButtonText(self.fontButton, f) - - f = self.parent.getMatchFont() - self.fontButtonMatch.setFont(f) - self.setFontButtonText(self.fontButtonMatch, f) - - self.show() - return - - - def font_slot(self): - (font, ok) = QtGui.QFontDialog.getFont(self.fontButton.font()) - if ok: - self.fontButton.setFont(font) - self.setFontButtonText(self.fontButton, font) - return - - - def match_font_slot(self): - (font, ok) = QtGui.QFontDialog.getFont(self.fontButtonMatch.font()) - if ok: - self.fontButtonMatch.setFont(font) - self.setFontButtonText(self.fontButtonMatch, font) - return - - - def apply_slot(self): - self.parent.setfont(self.fontButton.font()) - self.parent.setMatchFont(self.fontButtonMatch.font()) - self.save() - return - - - def accept(self): - self.apply_slot() - QtGui.QDialog.accept(self) - return - - - def help_slot(self): - self.helpWindow = Help(filename="prefs.html", parent=self) - return - -#-----------------------------------------------------------------------------# diff --git a/modules/reference.py b/modules/reference.py deleted file mode 100644 index 9ee2e63..0000000 --- a/modules/reference.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -#-----------------------------------------------------------------------------# -# Installed modules - -from PyQt4 import QtGui, QtCore - -#-----------------------------------------------------------------------------# -# Kodos modules - -from .referenceBA import Ui_ReferenceBA -from .util import kodos_toolbar_logo, restoreWindowSettings, saveWindowSettings - -#-----------------------------------------------------------------------------# - -GEO = "regex-ref_geometry" - -class Reference(QtGui.QMainWindow, Ui_ReferenceBA): - - pasteSymbol = QtCore.pyqtSignal(str) - - def __init__(self, parent=None, f=QtCore.Qt.WindowFlags()): - QtGui.QMainWindow.__init__(self, parent, f) - self.setupUi(self) - - self.parent = parent - restoreWindowSettings(self, GEO) - kodos_toolbar_logo(self.toolBar) - return - - - def closeEvent(self, ev): - saveWindowSettings(self, GEO) - ev.accept() - return - - - def editPaste(self): - list_view_item = self.referenceListView.currentItem() - if list_view_item == None: - return - - symbol = str(list_view_item.text(0)) - self.pasteSymbol.emit(symbol) - return - - - def help_help_slot(self): - self.parent.helpHelp() - return - - - def help_python_slot(self): - self.parent.helpPythonRegex() - return - -#-----------------------------------------------------------------------------# diff --git a/modules/regexLibrary.py b/modules/regexLibrary.py deleted file mode 100644 index 0ab0a2a..0000000 --- a/modules/regexLibrary.py +++ /dev/null @@ -1,82 +0,0 @@ -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -#-----------------------------------------------------------------------------# -# Installed modules - -from PyQt4 import QtGui, QtCore - -#-----------------------------------------------------------------------------# -# Kodos modules - -from .regexLibraryBA import Ui_RegexLibraryBA -from .parseRegexLib import ParseRegexLib -from .util import restoreWindowSettings, saveWindowSettings, kodos_toolbar_logo - -#-----------------------------------------------------------------------------# - -GEO = "regex-lib_geometry" - -class RegexLibrary(QtGui.QMainWindow, Ui_RegexLibraryBA): - - pasteRegexLib = QtCore.pyqtSignal(dict) - - def __init__(self, filename, parent=None, f=QtCore.Qt.WindowFlags()): - QtGui.QMainWindow.__init__(self, parent, f) - self.setupUi(self) - - self.filename = filename - self.parent = parent - self.selected = None - self.parseXML() - self.populateListBox() - kodos_toolbar_logo(self.toolBar) - restoreWindowSettings(self, GEO) - return - - - def closeEvent(self, ev): - saveWindowSettings(self, GEO) - ev.accept() - return - - - def parseXML(self): - parser = ParseRegexLib(self.filename) - self.xml_dicts = parser.parse() - return - - - def populateListBox(self): - for d in self.xml_dicts: - self.descriptionListBox.addItem(d.get('desc', "")) - return - - - def descSelectedSlot(self, qlistboxitem): - if qlistboxitem == None: return - - itemnum = self.descriptionListBox.currentRow() - self.populateSelected(self.xml_dicts[itemnum]) - return - - - def populateSelected(self, xml_dict): - self.regexTextBrowser.setPlainText(xml_dict.get('regex', "")) - self.contribEdit.setText(xml_dict.get("contrib", "")) - self.noteTextBrowser.setPlainText(xml_dict.get('note', "")) - self.selected = xml_dict - return - - - def editPaste(self): - if self.selected: - self.pasteRegexLib.emit(self.selected) - return - - def help_help_slot(self): - self.parent.helpHelp() - return - -#-----------------------------------------------------------------------------# diff --git a/modules/reportBug.py b/modules/reportBug.py deleted file mode 100644 index 9333bc4..0000000 --- a/modules/reportBug.py +++ /dev/null @@ -1,133 +0,0 @@ -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -#-----------------------------------------------------------------------------# -# Built-in modules - -import sys -import string -import smtplib - -#-----------------------------------------------------------------------------# -# Installed modules - -from PyQt4 import QtGui, QtCore - -#-----------------------------------------------------------------------------# -# Kodos modules - -from .reportBugBA import Ui_reportBugBA -from .util import kodos_toolbar_logo -from .version import VERSION - -#-----------------------------------------------------------------------------# - -AUTHOR_ADDR = "phil_schwartz@users.sourceforge.net" - -class reportBug(QtGui.QWidget, Ui_reportBugBA): - def __init__(self, parent=None, f=QtCore.Qt.WindowFlags()): - QtGui.QWidget.__init__(self, parent, f) - self.setupUi(self) - - self.parent = parent - self.kodos_main = parent.kodos_main - self.populate() - return - - - def populate(self): - self.OSEdit.setText(sys.platform) - pyvers = string.replace(sys.version, "\n", " - ") - self.pythonVersionEdit.setText(pyvers) - self.PyQtVersionEdit.setText(QtCore.QT_VERSION_STR) - self.regexMultiLineEdit.setPlainText(self.kodos_main.regexMultiLineEdit.toPlainText()) - self.stringMultiLineEdit.setPlainText(self.kodos_main.stringMultiLineEdit.toPlainText()) - return - - - def cancel_slot(self): - self.parent.close() - return - - - def submit_slot(self): - addr = str(self.emailAddressEdit.text()) - if not addr: - msg = self.tr( - "An email address is necessary so that the author " - "can contact you. Your email address will not " - "be used for any other purposes.") - - QtGui.QMessageBox.information( - None, - self.tr("You must supply a valid email address"), - msg - ) - return - - msg = "Subject: Kodos bug report\n\n" - msg += "Kodos Version: {0}\n".format(VERSION) - msg += "Operating System: {0}\n".format(unicode(self.OSEdit.text())) - msg += "Python Version: {0}\n".format(unicode(self.pythonVersionEdit.text())) - msg += "PyQt Version: {0}\n".format(unicode(self.PyQtVersionEdit.text())) - msg += "\n" + "=" * 70 + "\n" - msg += "Regex:\n{0}\n".format(unicode(self.regexMultiLineEdit.text())) - msg += "=" * 70 + "\n" - msg += "String:\n{0}\n".format(unicode(self.stringMultiLineEdit.text())) - msg += "=" * 70 + "\n" - msg += "Comments:\n{0}\n".format(unicode(self.commentsMultiLineEdit.text())) - email_server = unicode(self.kodos_main.prefs.emailServerEdit.text()) or "localhost" - try: - server = smtplib.SMTP(email_server) - server.sendmail(addr, AUTHOR_ADDR, msg) - server.quit() - QtGui.QMessageBox.information( - None, - self.tr("Bug report sent"), - self.tr("Your bug report has been sent.") - ) - self.parent.close() - except Exception as e: - QtGui.QMessageBox.information( - None, - self.tr("An exception occurred sending bug report"), - str(e) - ) - return - - -class reportBugWindow(QtGui.QMainWindow): - def __init__(self, kodos_main): - self.kodos_main = kodos_main - QtGui.QMainWindow.__init__(self, kodos_main) - - self.setGeometry(100, 50, 800, 600) - self.setWindowTitle(self.tr("Report a Bug")) - self.setWindowIcon(QtGui.QIcon(QtGui.QPixmap(":images/kodos_icon.png"))) - - self.bug_report = reportBug(parent=self) - self.setCentralWidget(self.bug_report) - - - self.createMenu() - self.createToolBar() - - self.show() - return - - - def createMenu(self): - self.menubar = self.menuBar() - self.filemenu = self.menubar.addMenu(self.tr("&File")) - self.filemenu.addAction(self.tr("&Close"), self, QtCore.SLOT("close()")) - return - - - def createToolBar(self): - toolbar = QtGui.QToolBar() - self.addToolBar(toolbar) - self.logolabel = kodos_toolbar_logo(toolbar) - return - -#-----------------------------------------------------------------------------# diff --git a/modules/reportBugBA.ui b/modules/reportBugBA.ui deleted file mode 100644 index 74b2eec..0000000 --- a/modules/reportBugBA.ui +++ /dev/null @@ -1,290 +0,0 @@ - - - reportBugBA - - - - 0 - 0 - 750 - 653 - - - - Form1 - - - - 11 - - - 6 - - - - - 6 - - - 0 - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 20 - 20 - - - - - - - - Submit Bug Report - - - - - - - Cancel - - - - - - - - - Kodos State Information - - - - 11 - - - 6 - - - - - 6 - - - 0 - - - - - Regular Expression: - - - false - - - - - - - Match String: - - - false - - - - - - - - - 6 - - - 0 - - - - - true - - - - - - - true - - - - - - - - - - - - System Information - - - - 11 - - - 6 - - - - - Operating System: - - - false - - - - - - - PyQt Version: - - - false - - - - - - - Python Version: - - - false - - - - - - - - - - - - - - - - - - - Comments - - - - 11 - - - 6 - - - - - 0 - - - 6 - - - - - Comments: - - - false - - - - - - - - - - - 0 - 0 - - - - Email address: - - - false - - - - - - - - - - - - - - - qPixmapFromMimeSource - - OSEdit - pythonVersionEdit - PyQtVersionEdit - emailAddressEdit - submitButton - cancelButton - - - - - submitButton - clicked() - reportBugBA - submit_slot() - - - 20 - 20 - - - 20 - 20 - - - - - cancelButton - clicked() - reportBugBA - cancel_slot() - - - 20 - 20 - - - 20 - 20 - - - - - diff --git a/modules/urlDialog.py b/modules/urlDialog.py deleted file mode 100644 index e3c99ab..0000000 --- a/modules/urlDialog.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -#-----------------------------------------------------------------------------# -# Built-in modules - -import urllib - -#-----------------------------------------------------------------------------# -# Installed modules - -from PyQt4 import QtGui, QtCore - -#-----------------------------------------------------------------------------# -# Kodos modules - -from .urlDialogBA import Ui_URLDialogBA -from . import help - -#-----------------------------------------------------------------------------# - -class URLDialog(QtGui.QDialog, Ui_URLDialogBA): - - urlImported = QtCore.pyqtSignal(str, str) - - def __init__(self, url=None, parent=None, f=QtCore.Qt.WindowFlags()): - QtGui.QDialog.__init__(self, parent, f) - self.setupUi(self) - - if url: - self.URLTextEdit.setPlainText(url) - self.show() - return - - - def help_slot(self): - self.helpWindow = help.Help(self, "importURL.html") - return - - - def ok_slot(self): - url = str(self.URLTextEdit.toPlainText()) - try: - fp = urllib.urlopen(url) - lines = fp.readlines() - except Exception as e: - QtGui.QMessageBox.information( - None, - "Failed to open URL", - "Could not open the specified URL. Please check to ensure \ - that you have entered the correct URL.\n\n{0}".format(str(e)) - ) - return - - - html = ''.join(lines) - - self.urlImported.emit(html, url) - - self.accept() - return - -#-----------------------------------------------------------------------------# diff --git a/modules/util.py b/modules/util.py deleted file mode 100644 index 4485238..0000000 --- a/modules/util.py +++ /dev/null @@ -1,111 +0,0 @@ -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -#-----------------------------------------------------------------------------# -# Built-in modules - -import os -import sys -import webbrowser - -#-----------------------------------------------------------------------------# -# Installed modules - -from PyQt4 import QtGui, QtCore - -#-----------------------------------------------------------------------------# -# Kodos modules - -from .debug import debug, DEBUG_PIXMAP - -#-----------------------------------------------------------------------------# - -# QT constants that should be defined -FALSE = 0 -TRUE = 1 - -global debug - -def getAppPath(): - "Convenience function so that we can find the necessary images" - fullpath = os.path.abspath(sys.argv[0]) - path = os.path.dirname(fullpath) - return path - - -def getPixmap(fileStr, fileType="PNG", dir="images"): - """Return a QPixmap instance for the file fileStr relative - to the binary location and residing in it's 'images' subdirectory""" - - image = getAppPath() + os.sep + dir + os.sep + fileStr - - if debug & DEBUG_PIXMAP: print("image: {0}".format(image)) - - pixmap = QtGui.QPixmap(image, fileType) - pixmap.setMask(pixmap.createHeuristicMask(1)) - - return pixmap - - -def kodos_toolbar_logo(toolbar): - # hack to move logo to right - blanklabel = QtGui.QLabel() - blanklabel.setSizePolicy(QtGui.QSizePolicy.Expanding, - QtGui.QSizePolicy.Preferred) - - logolabel = QtGui.QLabel("kodos_logo") - logolabel.setPixmap(QtGui.QPixmap(":/images/kodos_icon.png")) - - toolbar.addWidget(blanklabel) - toolbar.addWidget(logolabel) - - return logolabel - - -def saveWindowSettings(window, filename): - settings = QtCore.QSettings() - settings.setValue(window.objectName(), window.saveGeometry()) - return - - -def restoreWindowSettings(window, filename): - settings = QtCore.QSettings() - window.restoreGeometry(settings.value(window.objectName()).toByteArray()) - return - - -def findFile(filename): - dirs = [getAppPath(), - os.path.join("/", "usr", "share", "kodos"), - os.path.join("/", "usr", "local", "kodos")] - - for d in dirs: - path = os.path.join(d, filename) - if os.access(path, os.R_OK): return path - - return None - - -def launch_browser(url, caption=None, message=None): - if not caption: caption = "Info" - if not message: message = "Launch web browser?" - - button = QtGui.QMessageBox.information( - None, - caption, - message, - QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel - ) - if button == QtGui.QMessageBox.Cancel: - return False - try: - webbrowser.open(url) - except webbrowser.Error as e: - if debug: - print(e) - print("Couldn't open URL: {0}".format(url)) - return False - return True - -#-----------------------------------------------------------------------------# diff --git a/modules/version.py b/modules/version.py deleted file mode 100644 index c2b2315..0000000 --- a/modules/version.py +++ /dev/null @@ -1 +0,0 @@ -VERSION="2.4.9" diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt index b2a870d..87c540c 100644 --- a/packaging/CMakeLists.txt +++ b/packaging/CMakeLists.txt @@ -23,7 +23,7 @@ endif() set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Johannes Maier ") install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../dist/kodos DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/kodos.desktop DESTINATION /usr/share/applications) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../kodos.desktop DESTINATION /usr/share/applications) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../images/kodos_icon.png DESTINATION /usr/share/pixmaps) diff --git a/packaging/kodos.desktop b/packaging/kodos.desktop deleted file mode 100644 index e2ea4be..0000000 --- a/packaging/kodos.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Name=kodos -Comment[en]=The regex debugger -Exec=kodos -Icon=/usr/share/pixmaps/kodos_icon.png -Terminal=false -Type=Application -Categories=Application;Science;Engineering;Math; -StartupNotify=false \ No newline at end of file diff --git a/packaging/kodos.spec b/packaging/kodos.spec new file mode 100644 index 0000000..70e0b02 --- /dev/null +++ b/packaging/kodos.spec @@ -0,0 +1,119 @@ +Name: kodos +Version: 2.5.2 +Release: 1%{?dist} +Summary: Visual regular expression editor + +Group: Development/Tools +# No version specified. +License: GPL+ +URL: http://kodos.sourceforge.net/ +Source0: https://github.com/sergiomb2/kodos/archive/v%{version}/%{name}-%{version}.tar.gz + +BuildArch: noarch +BuildRequires: python3-devel +BuildRequires: desktop-file-utils +BuildRequires: python3-PyQt4-devel + +Requires: python3-PyQt4 + + +%description +Kodos is a visual regular expression editor and debugger written in Python. + + +%prep +%setup -q + + +%build +%py3_build + + +%install +%py3_install + +rm -f %{buildroot}%{python3_sitelib}/kodos/py2exe* +mkdir -p -m 0755 %{buildroot}%{_datadir}/pixmaps +install -m 0644 images/kodos_icon.png %{buildroot}%{_datadir}/pixmaps/ +desktop-file-install --dir %{buildroot}%{_datadir}/applications \ + kodos.desktop + + +%files +%doc CHANGELOG.txt +%license LICENSE.txt +%{_bindir}/* +%{_datadir}/kodos +%{python3_sitelib}/* +%{_datadir}/applications/* +%{_datadir}/pixmaps/* + + +%changelog +* Fri Dec 25 2020 Sérgio Basto - 2.5.2-1 +- Update to 2.5.2 (pyhton3 version) + +* Fri Dec 25 2020 Sérgio Basto - 2.5.1-1 +- Update to 2.5.1 (teythoon branch) + +* Sun Jun 24 2018 Sérgio Basto - 2.5.0-1 +- Unofficial Kodos 2.5.0 but with pyqt4 + +* Tue Jul 19 2016 Fedora Release Engineering - 2.4.9-19 +- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages + +* Thu Feb 04 2016 Fedora Release Engineering - 2.4.9-18 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Wed Jun 17 2015 Fedora Release Engineering - 2.4.9-17 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Sun Jun 08 2014 Fedora Release Engineering - 2.4.9-16 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Sat Aug 03 2013 Fedora Release Engineering - 2.4.9-15 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Wed Mar 6 2013 Toshio Kuratomi - 2.4.9-14 +- Remove vendor prefix from desktop files in F19+ https://fedorahosted.org/fesco/ticket/1077 + +* Thu Feb 14 2013 Fedora Release Engineering - 2.4.9-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Thu Jul 19 2012 Fedora Release Engineering - 2.4.9-12 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Fri Jan 13 2012 Fedora Release Engineering - 2.4.9-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Mon Feb 07 2011 Fedora Release Engineering - 2.4.9-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Wed Jul 21 2010 David Malcolm - 2.4.9-9 +- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild + +* Fri Jul 24 2009 Fedora Release Engineering - 2.4.9-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Wed Feb 25 2009 Fedora Release Engineering - 2.4.9-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Sat Nov 29 2008 Ignacio Vazquez-Abrams - 2.4.9-6 +- Rebuild for Python 2.6 + +* Tue Aug 5 2008 Tom "spot" Callaway - 2.4.9-5 +- fix license tag + +* Sat Jun 16 2007 Konstantin Ryabitsev - 2.4.9-4 +- Remove leftover useless Requires. + +* Sun Jun 10 2007 Konstantin Ryabitsev - 2.4.9-3 +- Don't add X-Fedora to desktop-file-install +- Don't run update-desktop-database, since there's no MimeType to worry about + +* Sun Mar 11 2007 Konstantin Ryabitsev - 2.4.9-2 +- BR desktop-file-utils +- Set permissions correctly to appease rpmlint + +* Mon Jan 29 2007 Konstantin Ryabitsev - 2.4.9-1 +- Initial packaging for Extras. diff --git a/py2exe-setup.py b/py2exe-setup.py index 1d78eb1..8f8c3af 100644 --- a/py2exe-setup.py +++ b/py2exe-setup.py @@ -1,27 +1,16 @@ #!/usr/bin/env python -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -#-----------------------------------------------------------------------------# -# Built-in modules - +# -*- coding: utf-8 -*- +from modules.version import VERSION +from distutils.core import setup +#from distutils.sysconfig import get_python_lib import os +import os.path import sys from glob import glob -from distutils.core import setup - -#-----------------------------------------------------------------------------# -# Installed modules - -import py2exe - -#-----------------------------------------------------------------------------# -# Kodos modules - -from modules.version import VERSION - -#-----------------------------------------------------------------------------# +try: + import py2exe +except: + pass args = sys.argv[1:] @@ -44,7 +33,7 @@ MODULES_DIR = os.path.join(libpath, "modules") TRANSLATIONS_DIR = os.path.join(libpath, "translations") -#-----------------------------------------------------------------------------# +######################################################################### setup(name="kodos", version=VERSION, @@ -73,4 +62,3 @@ """ ) -#-----------------------------------------------------------------------------# diff --git a/scripts/bapro2qtpro.py b/scripts/bapro2qtpro.py index dec91d7..0491450 100755 --- a/scripts/bapro2qtpro.py +++ b/scripts/bapro2qtpro.py @@ -1,16 +1,5 @@ -#!/usr/bin/env python -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -#-----------------------------------------------------------------------------# -# Built-in modules - -import os -import sys -import re - -#-----------------------------------------------------------------------------# +#!/bin/env python +import os, sys, re # regular expressions from Kodos (http://kodos.sourceforge.net) rx_folder = re.compile(r'''\ @@ -26,7 +15,6 @@ def __init__(self, infile, outfile): modules = self.getModules(infile) translations = self.getTranslations(outfile) self.saveQtFile(outfile, modules, translations) - return def getTranslations(self, outfile): @@ -99,18 +87,17 @@ def saveQtFile(self, outfile, modules, translations): fp.write("SOURCES = "); for module in modules: - fp.write("{0} ".format(module)) + fp.write("%s " % module) fp.write("\n") - fp.write("TRANSLATIONS = {0}\n".format(translations)) - return + fp.write("TRANSLATIONS = %s\n" % translations) -#-----------------------------------------------------------------------------# +################################################################################## def usage(): - print("Usage: {0} ba.pro qt.pro".format(sys.argv[0])) - return + print "Usage: ", sys.argv[0], " ba.pro qt.pro" + sys.exit(1) def convert(): try: @@ -118,19 +105,15 @@ def convert(): outfile = sys.argv[2] if infile == outfile: - print("ba.pro and qt.pro must refer to different filenames\n") + print "ba.pro and qt.pro must refer to different filenames\n" usage() - return 2 except: usage() - return 1 - Convert(infile, outfile) - return 0 + c = Convert(infile, outfile) -#-----------------------------------------------------------------------------# +################################################################################## if __name__ == '__main__': - sys.exit(convert()) + convert() -#-----------------------------------------------------------------------------# diff --git a/scripts/pyuicfix.py b/scripts/pyuicfix.py index 9326cd6..605bb61 100755 --- a/scripts/pyuicfix.py +++ b/scripts/pyuicfix.py @@ -1,21 +1,9 @@ -#!/usr/bin/env python -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -""" -this should be invoked by a pyuic wrapper -it looks for the arg after the -o cmd line flag -which is used as the source AND destination file. -""" - -#-----------------------------------------------------------------------------# -# Built-in modules - -import sys -import re - -#-----------------------------------------------------------------------------# +#!/bin/env python +# +# this should be invoked by a pyuic wrapper +# it looks for the arg after the -o cmd line flag +# which is used as the source AND destination file. +import sys, os, re filename = None args = sys.argv[1:] @@ -27,7 +15,7 @@ break if not filename: - print("Error: could not extract filename from: {0}".format(args)) + print "Error: could not extract filename from:", args sys.exit(0) fp = open(filename, "r") @@ -35,6 +23,7 @@ fp.close() + # regex from Kodos (of course!) rx = re.compile(r"""self\.clearWState\(Qt\.WState_Polished\)""") repl = """try: @@ -45,6 +34,7 @@ pycode = rx.sub(repl, pycode) + rx = re.compile(r"""\.setAccel\((?P.*)""") pos = 0 while 1: @@ -59,8 +49,10 @@ pycode[m.end():] + + + fp = open(filename, "w") fp.write(pycode) fp.close() -#-----------------------------------------------------------------------------# diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 630e5fe..0000000 --- a/setup.cfg +++ /dev/null @@ -1,10 +0,0 @@ -[bdist_rpm] -build_requires=PyQt4 -vendor = Kodos - Sourceforge -packager = Phil Schwartz -distribution-name = Red Hat Linux -requires = python >= 2.4 -requires = PyQt >= 4.0 -build-requires = python-devel -doc_files = README.txt LICENSE.txt - diff --git a/setup.py b/setup.py index dd83955..822db89 100644 --- a/setup.py +++ b/setup.py @@ -1,23 +1,12 @@ #!/usr/bin/env python -# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; truncate-lines: 0 -*- -# vi: set fileencoding=utf-8 filetype=python expandtab tabstop=4 shiftwidth=4 softtabstop=4 cindent: -# :mode=python:indentSize=4:tabSize=4:noTabs=true: - -#-----------------------------------------------------------------------------# -# Built-in modules - +# -*- coding: utf-8 -*- +from kodos.version import VERSION +from distutils.core import setup +from distutils.command.build_py import build_py as _build_py import os import sys from glob import glob -from distutils.core import setup -from distutils.command.install import install as DistutilsInstall - -#-----------------------------------------------------------------------------# -# Kodos modules - -from modules.version import VERSION - -#-----------------------------------------------------------------------------# +import subprocess args = sys.argv[1:] @@ -25,8 +14,7 @@ # libpath = '.\\' libpath = r"lib\site-packages\kodos" else: - #libpath = "/usr/local/kodos" # 2.4.0 and prior - libpath = "/usr/share/kodos" # as of 2.4.1 + libpath = "/usr/share/kodos" for arg in args: if arg == "--formats=wininst": @@ -37,15 +25,12 @@ HELP_PY_DIR = os.path.join(libpath, "help", "python") IMAGES_DIR = os.path.join(libpath, "images") SCREENSHOTS_DIR = os.path.join(libpath, "screenshots") -MODULES_DIR = os.path.join(libpath, "modules") TRANSLATIONS_DIR = os.path.join(libpath, "translations") -class MyInstall(DistutilsInstall): +class build_py(_build_py): def run(self): - os.system('make') - DistutilsInstall.run(self) - -#-----------------------------------------------------------------------------# + subprocess.check_call(['make']) + _build_py.run(self) setup(name="kodos", version=VERSION, @@ -53,22 +38,17 @@ def run(self): author="Phil Schwartz", author_email="phil_schwartz@users.sourceforge.net", url="http://kodos.sourceforge.net", - scripts=['kodos'], - ##package_dir={'': 'modules'}, - packages=['modules', "."], + scripts=['bin/kodos'], + packages=['kodos'], data_files=[(HELP_DIR, glob(os.path.join("help", "*.*ml"))), (HELP_PY_DIR, glob(os.path.join("help", "python", "*.html"))), (IMAGES_DIR, glob(os.path.join("images", "*.png"))), (SCREENSHOTS_DIR, glob(os.path.join("screenshots", "*.png"))), (TRANSLATIONS_DIR, glob(os.path.join("translations", "*"))), - (MODULES_DIR, glob("modules/*.ui")) ], license="GPL", - extra_path='kodos', long_description=""" Kodos is a visual regular expression editor and debugger. """, - cmdclass={'install':MyInstall}, + cmdclass={'build_py': build_py}, ) - -#-----------------------------------------------------------------------------# diff --git a/translations/Makefile b/translations/Makefile index 837efcf..e13ab4d 100644 --- a/translations/Makefile +++ b/translations/Makefile @@ -1,4 +1,4 @@ TSFILES := $(wildcard *.ts) all: $(TSFILES) - sed -i -e 's#\(filename="\)#\1../#g' $^ + #sed -i -e 's#\(filename="\)#\1../#g' $^ diff --git a/translations/kodos_en.ts b/translations/kodos_en.ts new file mode 100644 index 0000000..ac79649 --- /dev/null +++ b/translations/kodos_en.ts @@ -0,0 +1,1338 @@ + + + AboutBA + + About Kodos + + + + &OK + + + + About... + + + + 0.8 + + + + Kodos + +Developed by: Phil Schwartz + +phil_schwartz@users.sourceforge.net + + + + Version: + + + + + Kodos + + Enter a regular expression and a string to match against + + + + Kodos regex processing is paused. Click the pause icon to unpause + + + + Pattern does not match + + + + Pattern matches + + + + found + + + + match + + + + matches + + + + &No, Just Exit Kodos + + + + A file was not selected for import + + + + Could not open file for reading: + + + + Open Kodos File + + + + loaded successfully + + + + Error reading from file: + + + + Save Kodos File + + + + No file selected to save + + + + The file + + + + already exists. + + + + Would you like to replace it? + + + + Replace file? + + + + &Replace + + + + &Cancel + + + + Could not open file for writing: + + + + successfully saved + + + + &No + + + + You have made changes + + + + Would you like to save them before continuing + + + + Save changes? + + + + &Yes, Save Changes + + + + There is no filename to revert + + + + Failed to open url + + + + No Update is Available + + + + You are currently using the latest version of Kodos + + + + There is a newer version of Kodos available. + + + + You are using version: + + + + The latest version is: + + + + Press OK to launch browser + + + + Kodos Update Available + + + + Unable to get version info from Sourceforge + + + + Unknown version available + + + + Launching web browser + + + + Cancelled web browser launch + + + + You have made changes. Would you like to save them before continuing + + + + + KodosBA + + Group # + + + + Group Name + + + + Match + + + + Kodos - The Python Regex Debugger + + + + Kodos + + + + Flags + + + + Ignore Case + + + + Perform case-insensitive matching; expressions like [A-Z] will match +lowercase letters, too. This is not affected by the current locale. + + + + Multi Line + + + + When specified, the pattern character "^" matches at the beginning of the +string and at the beginning of each line (immediately following each newline); +and the pattern character "$" matches at the end of the string and at the end +of each line (immediately preceding each newline). By default, "^" matches +only at the beginning of the string, and "$" only at the end of the string and +immediately before the newline (if any) at the end of the string. + + + + Dot All + + + + Make the "." special character match any character at all, including a +newline; without this flag, "." will match anything except a newline. + + + + Verbose + + + + This flag allows you to write regular expressions that look nicer. Whitespace +within the pattern is ignored, except when in a character class or preceded by +an unescaped backslash, and, when a line contains a "#" neither in a character +class or preceded by an unescaped backslash, all characters from the leftmost +such "#" through the end of the line are ignored. + + + + Locale + + + + Make \w, \W, \b, and \B dependent on the current locale. + + + + Unicode + + + + "Make \w, \W, \b, and \B dependent on the Unicode character properties +database. New in Python version 2.0. + + + + Regular Expression Pattern + + + + Group + + + + Match All + + + + Replace + + + + Sample Code + + + + Search String + + + + Replace String + + + + Match Number + + + + Replace Number + + + + New + + + + &New + + + + Ctrl+N + + + + Open + + + + &Open... + + + + Ctrl+O + + + + Save + + + + &Save + + + + Ctrl+S + + + + Save As + + + + Save &As... + + + + Exit + + + + E&xit + + + + Undo + + + + &Undo + + + + Ctrl+Z + + + + Redo + + + + &Redo + + + + Ctrl+Y + + + + Cut + + + + &Cut + + + + Ctrl+X + + + + Copy + + + + C&opy + + + + Ctrl+C + + + + Paste + + + + &Paste + + + + Ctrl+V + + + + Examine Regex for Match + + + + E&xamine Regex + + + + Contents + + + + &Contents... + + + + Index + + + + &Index... + + + + About + + + + &About + + + + Action + + + + Pause Processing + + + + Ctrl+P + + + + Preferences + + + + Help + + + + Ctrl+/ + + + + Python Regex Help + + + + &Python Regex Help + + + + Regex Reference Guide + + + + &Regex Reference Guide + + + + Ctrl+R + + + + Visit Kodos Website + + + + &Visit Kodos Website + + + + Check for Kodos Update + + + + &Check for Kodos Update + + + + Report a Bug + + + + Report a &Bug + + + + Import File + + + + Import &File + + + + Import URL + + + + Import &URL + + + + Regex Library + + + + Regex &Library + + + + Open the Regex Library + + + + Ctrl+L + + + + Revert Kodos File + + + + &Revert Kodos File + + + + Tools + + + + &File + + + + &Edit + + + + &Help + + + + + NewUserDialog + + Kodos new user information + + + + <h3>Welcome to Kodos.</h3> +<p></p> +It appears that this is your first time using +Kodos - The Python Regular Expression Debugger. +<p></p> +In order to help you familiarize yourself with Kodos, you may wish to explore +the Regex Library. Additionally, Kodos contains a Python Regex Reference Guide. +You can access these tools by clicking on the appropriate toolbar icon. + + + + <b>Regex Reference Guide</b> + + + + <b>Regex Library</b> + + + + &OK + + + + Alt+O + + + + + PrefsBA + + Preferences + + + + ... + + + + Recent Files: + + + + Web Browser: + + + + Email Server: + + + + Editor Font: + + + + &Help + + + + &Apply + + + + &OK + + + + &Cancel + + + + + ReferenceBA + + Symbol + + + + Definition + + + + Kodos - Regex Reference Guide + + + + . + + + + Matches any character + + + + * + + + + Matches 0 or more repetition of preceeding RE + + + + + + + + + Matches 1 or more repetition of preceeding RE + + + + ? + + + + Matches 0 or 1 repetition of preceeding RE + + + + ^ + + + + Matches start of string + + + + $ + + + + Matches the end of the string + + + + \A + + + + Matches only at the start of the string + + + + \B + + + + Matches the empty string, but only when it is not at the beginning or end of a word + + + + \b + + + + Matches the empty string, but only at the beginning or end of a word + + + + \d + + + + Matches any decimal digit + + + + \D + + + + Matches any non-digit character + + + + \z + + + + Matches only at the end of the string + + + + \W + + + + Matches any non-word + + + + \w + + + + Matches any word + + + + \S + + + + Matches any non-whitespace character + + + + \s + + + + Matches any whitespace character + + + + \\ + + + + Matches a literal backslash + + + + ?? + + + + Non-greedy ? + + + + *? + + + + Non-greedy * + + + + +? + + + + Non-greedy + + + + + () + + + + Capturing Parenthesis + + + + (?:) + + + + Non-capturing Parenthesis + + + + [] + + + + Character class + + + + {m,n} + + + + match from m to n repetitions of the preceding RE, attempting to match as many repetitions as possible. + + + + {m,n}? + + + + match from m to n repetitions of the preceding RE, attempting to match as few repetitions as possible. + + + + (?P<name>...) + + + + Similar to regular parentheses, but the substring matched by the group is accessible via the symbolic group name name. + + + + (?P=name) + + + + Matches whatever text was matched by the earlier group named name. + + + + \number + + + + Matches the contents of the group of the same number. Groups are numbered starting from 1. + + + + (?<=...) + + + + Matches if the current position in the string is preceded by a match for ... that ends at the current position. This is called a positive lookbehind assertion. + + + + (?<!...) + + + + Matches if the current position in the string is not preceded by a match for .... This is called a negative lookbehind assertion. + + + + (?=...) + + + + Matches if ... matches next, but doesn't consume any of the string. This is called a lookahead assertion. + + + + (?!...) + + + + Matches if ... doesn't match next. This is a negative lookahead assertion + + + + (?#...) + + + + A comment; the contents of the parentheses are simply ignored. + + + + New + + + + &New + + + + Ctrl+N + + + + Open + + + + &Open... + + + + Ctrl+O + + + + Save + + + + &Save + + + + Ctrl+S + + + + Save As + + + + Save &As... + + + + Print + + + + &Print... + + + + Ctrl+P + + + + Exit + + + + E&xit + + + + Undo + + + + &Undo + + + + Ctrl+Z + + + + Redo + + + + &Redo + + + + Ctrl+Y + + + + Cut + + + + &Cut + + + + Ctrl+X + + + + Copy + + + + C&opy + + + + Ctrl+C + + + + Paste + + + + &Paste + + + + Paste selection into Kodos + + + + Ctrl+V + + + + Find + + + + &Find... + + + + Ctrl+F + + + + Contents + + + + &Contents... + + + + Index + + + + &Index... + + + + About + + + + &About + + + + Help + + + + &Help + + + + Python Regex Help + + + + &Python Regex Help + + + + Tools + + + + &File + + + + &Edit + + + + + RegexLibraryBA + + Kodos - Regex Library + + + + Description + + + + Regex + + + + Contributed By: + + + + Notes + + + + Paste + + + + &Paste Example Into Kodos + + + + Paste This Example Into Kodos + + + + Ctrl+V + + + + Help + + + + &Help + + + + Ctrl+/ + + + + Exit + + + + &Exit + + + + Tools + + + + &File + + + + &Edit + + + + + URLDialogBA + + Import URL + + + + &Help + + + + F1 + + + + &OK + + + + &Cancel + + + + Enter URL to import + + + + http://kodos.sourceforge.net + + + + + reportBug + + An email address is necessary so that the author can contact you. Your email address will not be used for any other purposes. + + + + You must supply a valid email address + + + + Bug report sent + + + + Your bug report has been sent. + + + + An exception occurred sending bug report + + + + + reportBugBA + + Form1 + + + + Submit Bug Report + + + + Cancel + + + + Kodos State Information + + + + Regular Expression: + + + + Match String: + + + + System Information + + + + Operating System: + + + + PyQt Version: + + + + Python Version: + + + + Comments + + + + Comments: + + + + Email address: + + + + + reportBugWindow + + Report a Bug + + + + &Close + + + + &File + + + + diff --git a/translations/kodos_pl.ts b/translations/kodos_pl.ts new file mode 100644 index 0000000..43c31c2 --- /dev/null +++ b/translations/kodos_pl.ts @@ -0,0 +1,1359 @@ + + + AboutBA + + About Kodos + O programie Kodos + + + &OK + &OK + + + About... + O programie... + + + 0.8 + 0.8 + + + Kodos + +Developed by: Phil Schwartz + +phil_schwartz@users.sourceforge.net + Kodos + +Autor: Phil Schwartz + +phil_schwartz@users.sourceforge.net + + + Version: + Wersja: + + + + Kodos + + Enter a regular expression and a string to match against + Wpisz wyrażenie regularne i tekst do sprawdzenia + + + Kodos regex processing is paused. Click the pause icon to unpause + Przetwarzanie wyrażenia regularnego wstrzymane. Kliknij ponownie pauzę by wznowić. + + + Pattern does not match + Brak dopasowania + + + Pattern matches + Wzorzec pasuje + + + found + znaleziono + + + match + dopasowanie + + + matches + pasuje + + + &No, Just Exit Kodos + &Nie, zakończ program + + + A file was not selected for import + Nie wybrano pliku do importu + + + Could not open file for reading: + Pliku nie udało się otworzyć: + + + Open Kodos File + Otwórz plik Kodos + + + loaded successfully + załadowany + + + Error reading from file: + Błąd podczas odczytu pliku: + + + Save Kodos File + Zapisz plik Kodos + + + No file selected to save + Nie wybrano pliku do zapisu + + + The file + Plik + + + already exists. + już istnieje. + + + Would you like to replace it? + Zastąpić? + + + Replace file? + Czy zastąpić plik? + + + &Replace + Za&mień + + + &Cancel + &Anuluj + + + Could not open file for writing: + Nie można zapisać pliku: + + + successfully saved + zapisano + + + &No + &Nie + + + You have made changes + Zmieniono + + + Would you like to save them before continuing + Czy zapisać zmiany + + + Save changes? + Czy zapisać zmiany? + + + &Yes, Save Changes + Tak, zapi&sz + + + There is no filename to revert + Brak wcześniejszej nazwy pliku + + + Failed to open url + Nie udało się otworzyć URL + + + No Update is Available + Nie ma uaktualnień + + + You are currently using the latest version of Kodos + Używasz najnowszej wersji Kodos + + + There is a newer version of Kodos available. + Dostępna jest nowsza wersja Kodos. + + + You are using version: + Używasz wersji: + + + The latest version is: + Najnowsza wersja: + + + Press OK to launch browser + Naciśnij OK by uruchomić przeglądarkę + + + Kodos Update Available + Dostępne jest uaktualnienie Kodos + + + Unable to get version info from Sourceforge + Nie udało się pobrać wersji z SourceForge + + + Unknown version available + Dostępna wersja jest nieznana + + + Launching web browser + Uruchamianie przeglądarki + + + Cancelled web browser launch + Anulowano uruchomienie przeglądarki + + + You have made changes. Would you like to save them before continuing + Czy zachować wprowadzone zmiany + + + + KodosBA + + Group # + Grupa # + + + Group Name + Nazwa grupy + + + Match + Dopasowanie + + + Kodos - The Python Regex Debugger + Kodos - debugger wyrażeń regularnych dla Pythona + + + Kodos + Kodos + + + Flags + Flagi + + + Ignore Case + re.IGNORECASE + + + Perform case-insensitive matching; expressions like [A-Z] will match +lowercase letters, too. This is not affected by the current locale. + Wyszukiwanie bez rozróżniania wielkości liter; wyrażenia jak [A-Z] będą pasować +również do małych liter.Ustawienia regionalne nie mają wpływu na tę flagę. + + + Multi Line + re.MULTILINE + + + When specified, the pattern character "^" matches at the beginning of the +string and at the beginning of each line (immediately following each newline); +and the pattern character "$" matches at the end of the string and at the end +of each line (immediately preceding each newline). By default, "^" matches +only at the beginning of the string, and "$" only at the end of the string and +immediately before the newline (if any) at the end of the string. + Z tym ustawieniam, znak "^" dopasowuje początek tekstu i początek każdej +linii (po znaku nowego wiersza); z kolei znak "$" dopasowuje koniec tekstu i koniec +każdej linii (przed znakiem nowego wiersza). Domyślnie "^" dopasowuje tylko +początek tekstu, a "$" tylko koniec tekstu lub koniec wiersza, gdy tekst kończy się +znakiem nowego wiersza. + + + Dot All + re.DOTALL + + + Make the "." special character match any character at all, including a +newline; without this flag, "." will match anything except a newline. + Powoduje, że znak "." dopasowuje dowolny znak, włączając w to znak +nowego wiersza. Domyślnie znak "." nie dopasowuje znaku nowego wiersza. + + + Verbose + re.VERBOSE + + + This flag allows you to write regular expressions that look nicer. Whitespace +within the pattern is ignored, except when in a character class or preceded by +an unescaped backslash, and, when a line contains a "#" neither in a character +class or preceded by an unescaped backslash, all characters from the leftmost +such "#" through the end of the line are ignored. + Z tym ustawieniem wyrażenia regularne są bardziej czytelne. Białe znaki we wzorcu +są ignorowane wszędzie, poza klasami znaków i poza miejscami zabezpieczonymi +odwrócomym ukośnikiem. Gdy we wzorcu wystąpi znak "#" poza deklaracją klasy znaków +lub niezabezpieczony, wtedy wszystkie występujące po nim znaki są ignorowane. + + + Locale + re.LOCALE + + + Make \w, \W, \b, and \B dependent on the current locale. + Wzorce \w, \W, \b i \B zachowują się zgodnie z bieżącymi ustawieniami międzynarodowymi. + + + Unicode + re.UNICODE + + + "Make \w, \W, \b, and \B dependent on the Unicode character properties +database. New in Python version 2.0. + Wzorce \w, \W, \b i \B zachowują się zgodnie z właśiwościami znaków Unicode. +Nowość w Pythonie 2.0. + + + Regular Expression Pattern + Wyrażenie regularne + + + Group + Grupa + + + Match All + Wszystkie dopasowania + + + Replace + Zamiana + + + Sample Code + Przykładowy kod + + + Search String + Przeszukiwany tekst + + + Replace String + Zamieniany tekst + + + Match Number + Numer dopasowania + + + Replace Number + Numer zamiany + + + New + Nowy + + + &New + &Nowy + + + Ctrl+N + Ctrl+N + + + Open + Otwórz + + + &Open... + &Otwórz... + + + Ctrl+O + Ctrl+O + + + Save + Zapisz + + + &Save + Zapi&sz + + + Ctrl+S + Ctrl+S + + + Save As + Zapisza jako + + + Save &As... + Zapisz j&ako... + + + Exit + Koniec + + + E&xit + &Koniec + + + Undo + Cofnij + + + &Undo + &Cofnij + + + Ctrl+Z + Ctrl+Z + + + Redo + Ponów + + + &Redo + &Ponów + + + Ctrl+Y + Ctrl+Y + + + Cut + Wytnij + + + &Cut + W&ytnij + + + Ctrl+X + Ctrl+X + + + Copy + Kopiuj + + + C&opy + K&opiuj + + + Ctrl+C + Ctrl+C + + + Paste + Wklej + + + &Paste + &Wklej + + + Ctrl+V + Ctrl+V + + + Examine Regex for Match + Sprawdź wyrażenie regularne + + + E&xamine Regex + Sp&rawdź wyrażenie regularne + + + Contents + Zawartość + + + &Contents... + &Zawartość... + + + Index + Indeks + + + &Index... + &Indeks... + + + About + O programie + + + &About + &O programie + + + Action + Akcja + + + Pause Processing + Wstrzymaj + + + Ctrl+P + Ctrl+P + + + Preferences + Ustawienia + + + Help + Pomoc + + + Ctrl+/ + Ctrl+/ + + + Python Regex Help + Pomoc dla RE w Pythonie + + + &Python Regex Help + &Pomoc dla RE w Pythonie + + + Regex Reference Guide + Przewodnik po wyrażeniach regularnych + + + &Regex Reference Guide + P&rzewodnik po wyrażeniach regularnych + + + Ctrl+R + Ctrl+R + + + Visit Kodos Website + Odwiedź stronę domową Kodos + + + &Visit Kodos Website + Od&wiedź stronę Kodos + + + Check for Kodos Update + Sprawdź uaktualnienie Kodos + + + &Check for Kodos Update + &Sprawdź uaktualnienie Kodos + + + Report a Bug + Zgłoś błąd + + + Report a &Bug + Zgłoś &błąd + + + Import File + Importuj plik + + + Import &File + Importuj &plik + + + Import URL + Importuj URL + + + Import &URL + Importuj &URL + + + Regex Library + Biblioteka wyrażeń regularnych + + + Regex &Library + Bib&lioteka wyrażeń regularnych + + + Open the Regex Library + Otwórz bibliotekę wyrażeń regularnych + + + Ctrl+L + Ctrl+L + + + Revert Kodos File + Przywróć plik + + + &Revert Kodos File + P&rzywróć plik + + + Tools + Narzędzia + + + &File + &Plik + + + &Edit + &Edycja + + + &Help + P&omoc + + + + NewUserDialog + + Kodos new user information + Informacje o nowym uzytkowniku Kodos + + + <h3>Welcome to Kodos.</h3> +<p></p> +It appears that this is your first time using +Kodos - The Python Regular Expression Debugger. +<p></p> +In order to help you familiarize yourself with Kodos, you may wish to explore +the Regex Library. Additionally, Kodos contains a Python Regex Reference Guide. +You can access these tools by clicking on the appropriate toolbar icon. + <h3>Witaj w programie Kodos.</h3> +<p><p> +Wygląda na to, że po raz pierwszy uruchamiasz Kodos - +debugger wyrażeń regularnych Pythona. +<p></p> +Aby zapoznać się z programem Kodos, powinieneś przejrzeć bibliotekę wyrażeń +regularnych. Dodatkowo Kodos posiada przewodnik po wyrażeniach regularnych. +Aby uzyskać dostęp do tych narzędzi, kliknij odpowiednią ikonę na pasku narzędzi. + + + <b>Regex Reference Guide</b> + <b>Przewodnik po wyrażeniach regularnych</p> + + + <b>Regex Library</b> + <b>Biblioteka wyrażeń regularnych</b> + + + &OK + &OK + + + Alt+O + Alt+O + + + + PrefsBA + + Preferences + Ustawienia + + + ... + ... + + + Recent Files: + Ostatnio otwarte pliki: + + + Web Browser: + Przeglądarka WWW: + + + Email Server: + Serwer poczty: + + + Editor Font: + Czcionka edytora: + + + &Help + &Pomoc + + + &Apply + Za&twierdź + + + &OK + &OK + + + &Cancel + &Anuluj + + + + ReferenceBA + + Symbol + Symbol + + + Definition + Definicja + + + Kodos - Regex Reference Guide + Przewodnik po wyrażeniach regularnych + + + . + . + + + Matches any character + Dopasowuje dowolny znak + + + * + * + + + Matches 0 or more repetition of preceeding RE + Dopasowuje 0 lub więceń wystąpień poprzedzającego RE + + + + + + + + + Matches 1 or more repetition of preceeding RE + Dopasowuje 1 lub więceń wystąpień poprzedzającego RE + + + ? + ? + + + Matches 0 or 1 repetition of preceeding RE + Dopasowuje 0 lub 1 wystąpienie poprzedzającego RE + + + ^ + ^ + + + Matches start of string + Dopasowuje początek tekstu + + + $ + $ + + + Matches the end of the string + Dopasowuje koniec tekstu + + + \A + \A + + + Matches only at the start of the string + Dopasowuje wyłącznie na początku tekstu + + + \B + \B + + + Matches the empty string, but only when it is not at the beginning or end of a word + Dopasowuje pusty ciąg, ale tylko wtedy, gdy nie jest na początku lub na końcu słowa + + + \b + \b + + + Matches the empty string, but only at the beginning or end of a word + Dopasowuje pusty ciąg, ale tylko wtedy, gdy jest na początku lub na końcu słowa + + + \d + \d + + + Matches any decimal digit + Dopasowuje dowolną liczbę dziesiętną + + + \D + \D + + + Matches any non-digit character + Dopasowuje dowolny znak, nie będący liczbą + + + \z + \z + + + Matches only at the end of the string + Dopasowuje wyłącznie na końcu tekstu + + + \W + \W + + + Matches any non-word + Dopasowuje dowolny ciąg, nie będący słowem + + + \w + \w + + + Matches any word + Dopasowuje dowolne słowo + + + \S + \S + + + Matches any non-whitespace character + Dopasowuje dowolny znak poza białymi znakami + + + \s + \s + + + Matches any whitespace character + Dopasowuje dowolny biały znak + + + \\ + \\ + + + Matches a literal backslash + Dopasowuje odwrócony ukośnik + + + ?? + ?? + + + Non-greedy ? + + + + *? + + + + Non-greedy * + + + + +? + + + + Non-greedy + + + + + () + + + + Capturing Parenthesis + + + + (?:) + + + + Non-capturing Parenthesis + + + + [] + [] + + + Character class + Klasa znaków + + + {m,n} + {m,n} + + + match from m to n repetitions of the preceding RE, attempting to match as many repetitions as possible. + + + + {m,n}? + + + + match from m to n repetitions of the preceding RE, attempting to match as few repetitions as possible. + + + + (?P<name>...) + + + + Similar to regular parentheses, but the substring matched by the group is accessible via the symbolic group name name. + + + + (?P=name) + + + + Matches whatever text was matched by the earlier group named name. + + + + \number + \liczba + + + Matches the contents of the group of the same number. Groups are numbered starting from 1. + Dopasowuje zawartość grupy o wskazanym numerze. Grupy są numerowane od 1. + + + (?<=...) + + + + Matches if the current position in the string is preceded by a match for ... that ends at the current position. This is called a positive lookbehind assertion. + + + + (?<!...) + + + + Matches if the current position in the string is not preceded by a match for .... This is called a negative lookbehind assertion. + + + + (?=...) + + + + Matches if ... matches next, but doesn't consume any of the string. This is called a lookahead assertion. + + + + (?!...) + + + + Matches if ... doesn't match next. This is a negative lookahead assertion + + + + (?#...) + (?#...) + + + A comment; the contents of the parentheses are simply ignored. + Komentarz, zawartość w nawiasach jest ignorowana. + + + New + Nowy + + + &New + &Nowy + + + Ctrl+N + Ctrl+N + + + Open + Otwórz + + + &Open... + &Otwórz... + + + Ctrl+O + Ctrl+O + + + Save + Zapisz + + + &Save + Zapi&sz + + + Ctrl+S + Ctrl+S + + + Save As + Zapisz jako + + + Save &As... + Zapisz j&ako... + + + Print + Drukuj + + + &Print... + &Drukuj... + + + Ctrl+P + Ctrl+P + + + Exit + Koniec + + + E&xit + &Koniec + + + Undo + Cofnij + + + &Undo + &Cofnij + + + Ctrl+Z + Ztrl+Z + + + Redo + Ponów + + + &Redo + &Ponów + + + Ctrl+Y + Ctrl+Y + + + Cut + Wytnij + + + &Cut + &Wytnij + + + Ctrl+X + Ctrl+X + + + Copy + Kopiuj + + + C&opy + K&opiuj + + + Ctrl+C + Ctrl+C + + + Paste + Wklej + + + &Paste + W&klej + + + Paste selection into Kodos + Wklej wybór do Kodos + + + Ctrl+V + Ctrl+V + + + Find + Znajdź + + + &Find... + &Znajdź... + + + Ctrl+F + Ctrl+F + + + Contents + Zawartość + + + &Contents... + &Zawartość... + + + Index + Indeks + + + &Index... + &Indeks... + + + About + O programie + + + &About + &O programie + + + Help + Pomoc + + + &Help + P&omoc + + + Python Regex Help + Pomoc do wyrażeń regularnych w Pythonie + + + &Python Regex Help + &Pomoc do RE Pythona + + + Tools + Narzędzia + + + &File + &Plik + + + &Edit + &Edycja + + + + RegexLibraryBA + + Kodos - Regex Library + Kodos - Biblioteka wyrażeń regularnych + + + Description + Opis + + + Regex + Wyrażenie regularne + + + Contributed By: + Autor: + + + Notes + Uwagi + + + Paste + Wklej + + + &Paste Example Into Kodos + &Wklej przykład do Kodos + + + Paste This Example Into Kodos + Wklej ten przykład do Kodos + + + Ctrl+V + Ctrl+V + + + Help + Pomoc + + + &Help + &Pomoc + + + Ctrl+/ + Ctrl+/ + + + Exit + Zamknij + + + &Exit + Z&amknij + + + Tools + Narzędzia + + + &File + &Plik + + + &Edit + &Edycja + + + + URLDialogBA + + Import URL + Importuj URL + + + &Help + &Pomoc + + + F1 + F1 + + + &OK + &OK + + + &Cancel + &Anuluj + + + Enter URL to import + Wpisz URL do zaimportowania + + + http://kodos.sourceforge.net + http://kodos.sourceforge.net + + + + reportBug + + An email address is necessary so that the author can contact you. Your email address will not be used for any other purposes. + Adres poczty elektroniczne jest konieczny, by autor programu mógł się z Tobą skontaktować. Podany adres nie zostanie użyty w żadnym innym celu. + + + You must supply a valid email address + Musisz podać działający adres poczty elektronicznej + + + Bug report sent + Zgłoszenie błedu zostało wysłane + + + Your bug report has been sent. + Twoje zgłoszenie błędu zostało wysłane. + + + An exception occurred sending bug report + Podczas wysyłania wystąpił błąd + + + + reportBugBA + + Form1 + Form1 + + + Submit Bug Report + Wyślij zgłoszenie błędu + + + Cancel + Anuluj + + + Kodos State Information + Informacja o stanie Kodos + + + Regular Expression: + Wyrażenie regularne: + + + Match String: + Przeszukiwany tekst: + + + System Information + Informacja o systemie + + + Operating System: + System operacyjny: + + + PyQt Version: + Wersja PyQt: + + + Python Version: + Wersja Pythona: + + + Comments + Uwagi + + + Comments: + Uwagi: + + + Email address: + Adres email: + + + + reportBugWindow + + Report a Bug + Zgłoś błąd + + + &Close + &Zamknij + + + &File + &Plik + + +