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..2d3486e 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
+kodos/kodos_rc.py: kodos.qrc
pyrcc4 -o $@ $<
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.pro b/kodos.pro
index 1e375b9..287437c 100644
--- a/kodos.pro
+++ b/kodos.pro
@@ -1,31 +1,31 @@
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_pl.ts \
translations/kodos_sv.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/resultsBA.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/reportBugBA.ui \
+ kodos/resultsBA.ui \
+ kodos/urlDialogBA.ui
diff --git a/modules/.gitignore b/kodos/.gitignore
similarity index 100%
rename from modules/.gitignore
rename to kodos/.gitignore
diff --git a/modules/Makefile b/kodos/Makefile
similarity index 100%
rename from modules/Makefile
rename to kodos/Makefile
diff --git a/modules/__init__.py b/kodos/__init__.py
similarity index 100%
rename from modules/__init__.py
rename to kodos/__init__.py
diff --git a/modules/about.py b/kodos/about.py
similarity index 100%
rename from modules/about.py
rename to kodos/about.py
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 100%
rename from modules/flags.py
rename to kodos/flags.py
diff --git a/modules/help.py b/kodos/help.py
similarity index 94%
rename from modules/help.py
rename to kodos/help.py
index b8b79c8..990478d 100755
--- a/modules/help.py
+++ b/kodos/help.py
@@ -7,7 +7,7 @@
from PyQt4 import QtCore
from . import util
-from helpBA import HelpBA
+from . import helpBA
class textbrowser(QtGui.QTextBrowser):
# reimplemented textbrowser that filters out external sources
@@ -28,9 +28,9 @@ def setSource(self, src):
-class Help(HelpBA):
+class Help(helpBA.HelpBA):
def __init__(self, parent, filename):
- HelpBA.__init__(self, parent)
+ helpBA.HelpBA.__init__(self, parent)
self.setGeometry(100, 50, 800, 600)
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 74%
rename from kodos
rename to kodos/main.py
index 8446047..180699c
--- a/kodos
+++ b/kodos/main.py
@@ -1,46 +1,26 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# kodos.py: -*- Python -*- DESCRIPTIVE TEXT.
-import sys
import os
-import string
import re
-import cPickle
import types
-import getopt
-import urllib
import signal
-
-try:
- from PyQt4.QtGui import *
- from PyQt4.QtCore import *
-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.""")
-
-### 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 *
-from modules.util import *
-from modules.about import *
-import modules.help as help
-from modules.status_bar import *
-from modules.reference import *
-from modules.prefs import *
-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.newUserDialogBA import NewUserDialog
-from modules.flags import reFlag, reFlagList
-
+import cPickle
+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
@@ -49,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
@@ -66,8 +43,8 @@
GEO = "kodos_geometry"
# colors for normal & examination mode
-QCOLOR_WHITE = QColor(Qt.white) # normal
-QCOLOR_YELLOW = QColor(255,255,127) # examine
+QCOLOR_WHITE = QtCore.Qt.white # normal
+QCOLOR_YELLOW = Qt.QColor(255,255,127) # examine
try:
signal.SIGALRM
@@ -82,11 +59,12 @@
#
##############################################################################
-class Kodos(KodosBA):
- def __init__(self, filename, debug):
- KodosBA.__init__(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 = ""
@@ -112,10 +90,10 @@ def __init__(self, filename, debug):
self.MSG_FAIL = self.tr("Pattern does not match")
- self.statusPixmapsDict = { MATCH_NA: QPixmap(":images/yellow.png"),
- MATCH_OK: QPixmap(":images/green.png"),
- MATCH_FAIL: QPixmap(":images/red.png"),
- MATCH_PAUSED: 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"),
}
@@ -131,21 +109,20 @@ def __init__(self, filename, debug):
])
self.reFlags.clearAll()
- restoreWindowSettings(self, GEO)
+ util.restoreWindowSettings(self, GEO)
self.show()
- self.prefs = Preferences(self, 1)
- 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):
- qApp.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()
@@ -153,18 +130,18 @@ def __init__(self, filename, debug):
def checkIfNewUser(self):
- s = QSettings()
+ s = Qt.QSettings()
if s.value('New User', "true").toPyObject() != "false":
- self.newuserdialog = NewUserDialog()
+ self.newuserdialog = newUserDialogBA.NewUserDialog()
self.newuserdialog.show()
s.setValue('New User', "false")
def createStatusBar(self):
- self.status_bar = Status_Bar(self, FALSE, "")
+ 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)
@@ -177,7 +154,7 @@ def fileMenuHandler(self, menuid):
self.recent_files.add(fn)
def prefsSaved(self):
- if self.debug: print "prefsSaved slot"
+ self.log.debug("prefsSaved slot")
self.recent_files.setNumShown(self.prefs.recentFilesSpinBox.value())
@@ -224,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:", self.is_paused
+ self.log.debug("is_paused: %s" % self.is_paused)
if self.is_paused:
self.update_results(self.MSG_PAUSED, MATCH_PAUSED)
@@ -237,7 +214,7 @@ def pause(self):
def examine(self):
self.is_examined = not self.is_examined
- if self.debug: print "is_examined:", self.is_examined
+ self.log.debug("is_examined: %s" % self.is_examined)
if self.is_examined:
color = QCOLOR_YELLOW
@@ -253,7 +230,7 @@ def examine(self):
try:
m = re.search(regex, self.matchstring, self.reFlags.allFlagsORed())
if m:
- if self.debug: print "examined regex:", regex
+ self.log.debug("examined regex: %s" % regex)
self.__refresh_regex_widget(color, regex)
return
except:
@@ -270,7 +247,7 @@ def examine(self):
def __refresh_regex_widget(self, base_qcolor, regex):
- pal = QPalette()
+ pal = Qt.QPalette()
pal.setColor(pal.Base, base_qcolor)
self.regexMultiLineEdit.setPalette(pal)
@@ -309,14 +286,14 @@ def hide_replace_widgets(self):
self.replaceLabel.hide()
self.replaceNumberSpinBox.hide()
self.replaceTextBrowser.clear()
- self.replaceTextBrowser.setDisabled(TRUE)
+ 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)
+ self.replaceNumberSpinBox.setEnabled(True)
+ self.replaceTextBrowser.setEnabled(True)
def replace_changed_slot(self):
self.replace = unicode(self.replaceTextEdit.toPlainText())
@@ -340,8 +317,8 @@ def populate_group_table(self, tuples):
self.groupTable.setRowCount(rows)
row = 0
for t in tuples:
- self.groupTable.setItem(row, 0, QTableWidgetItem(t[1]))
- self.groupTable.setItem(row, 1, QTableWidgetItem(t[2]))
+ self.groupTable.setItem(row, 0, Qt.QTableWidgetItem(t[1]))
+ self.groupTable.setItem(row, 1, Qt.QTableWidgetItem(t[2]))
row += 1
@@ -400,7 +377,7 @@ def populate_code_textbrowser(self):
def colorize_strings(self, strings, widget, cursorOffset=0):
widget.clear()
- colors = (QBrush(QColor(Qt.black)), QBrush(QColor(Qt.blue)) )
+ colors = (Qt.QBrush(Qt.QColor(QtCore.Qt.black)), Qt.QBrush(Qt.QColor(QtCore.Qt.blue)) )
cur = widget.textCursor()
format = cur.charFormat()
@@ -505,8 +482,8 @@ 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()
@@ -535,12 +512,12 @@ 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)
@@ -578,11 +555,10 @@ def timeout(signum, frame):
for key in keys:
group_nums[compile_obj.groupindex[key]] = key
- if self.debug:
- print "group_nums:", group_nums
- print "grp index: ", compile_obj.groupindex
- print "groups:", match_obj.groups()
- print "span: ", 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]
@@ -648,7 +624,7 @@ def closeEvent(self, ev):
ev.ignore()
return
- saveWindowSettings(self, GEO)
+ util.saveWindowSettings(self, GEO)
try:
self.regexlibwin.close()
@@ -675,7 +651,7 @@ def fileNew(self):
def importURL(self):
- self.urldialog = URLDialog(self, self.url)
+ self.urldialog = urlDialog.URLDialog(self, self.url)
self.urldialog.urlImported.connect(self.urlImported)
@@ -685,7 +661,7 @@ def urlImported(self, html, url):
def importFile(self):
- fn = QFileDialog.getOpenFileName(self,
+ fn = Qt.QFileDialog.getOpenFileName(self,
self.tr("Import File"),
self.filename,
self.tr("All (*)"))
@@ -694,7 +670,7 @@ def importFile(self):
self.updateStatus(self.tr("A file was not selected for import"),
-1,
5,
- TRUE)
+ True)
return None
filename = str(fn)
@@ -703,7 +679,7 @@ def importFile(self):
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()
@@ -715,7 +691,7 @@ def fileOpen(self):
filename = self.filename
if filename == None:
filename = ""
- fn = QFileDialog.getOpenFileName(self,
+ fn = Qt.QFileDialog.getOpenFileName(self,
self.tr("Open Kodos File"),
filename,
self.tr("Kodos file (*.kds);;All (*)"))
@@ -735,7 +711,7 @@ def openFile(self, filename):
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
try:
@@ -744,11 +720,10 @@ def openFile(self, filename):
self.matchstring = u.load()
flags = u.load()
except Exception, e: #FIXME: don't catch everything
- if self.debug:
- print unicode(e)
+ self.log.error('Error unpickling data from file: %s' % e)
msg = "%s %s" % (unicode(self.tr("Error reading from file:")),
filename)
- self.updateStatus(msg, -1, 5, TRUE)
+ self.updateStatus(msg, -1, 5, True)
return 0
self.matchNumberSpinBox.setValue(1)
@@ -768,7 +743,7 @@ def openFile(self, filename):
self.filename = filename
msg = "%s %s" % (filename, unicode(self.tr("loaded successfully")))
- self.updateStatus(msg, -1, 5, TRUE)
+ self.updateStatus(msg, -1, 5, True)
self.editstate = STATE_UNEDITED
return 1
@@ -777,16 +752,16 @@ def fileSaveAs(self):
filename = self.filename
if filename == None:
filename = ""
- filedialog = QFileDialog(self,
+ filedialog = Qt.QFileDialog(self,
self.tr("Save Kodos File"),
filename,
"Kodos file (*.kds);;All (*)")
- filedialog.setAcceptMode(QFileDialog.AcceptSave)
+ filedialog.setAcceptMode(Qt.QFileDialog.AcceptSave)
filedialog.setDefaultSuffix("kds")
ok = filedialog.exec_()
- if ok == 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()))
@@ -805,7 +780,7 @@ def fileSave(self):
except:
msg = "%s: %s" % (unicode(self.tr("Could not open file for writing:")),
self.filename)
- self.updateStatus(msg, -1, 5, TRUE)
+ self.updateStatus(msg, -1, 5, True)
return None
self.editstate = STATE_UNEDITED
@@ -818,7 +793,7 @@ def fileSave(self):
fp.close()
msg = "%s %s" % (unicode(self.filename),
unicode(self.tr("successfully saved")))
- self.updateStatus(msg, -1, 5, TRUE)
+ self.updateStatus(msg, -1, 5, True)
self.recent_files.add(self.filename)
@@ -848,17 +823,17 @@ def checkEditState(self):
if self.editstate == STATE_EDITED:
message = self.tr("You have made changes. Would you like to save them before continuing?")
- prompt = QMessageBox.warning(None,
+ prompt = Qt.QMessageBox.warning(None,
self.tr("Save changes?"),
message,
- QMessageBox.Save |
- QMessageBox.Cancel |
- QMessageBox.Discard)
+ Qt.QMessageBox.Save |
+ Qt.QMessageBox.Cancel |
+ Qt.QMessageBox.Discard)
- if prompt == QMessageBox.Cancel:
+ if prompt == Qt.QMessageBox.Cancel:
return False
- if prompt == QMessageBox.Save:
+ if prompt == Qt.QMessageBox.Save:
self.fileSave()
if not self.filename: self.checkEditState()
@@ -888,14 +863,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)
def getWidget(self):
- widget = qApp.focusWidget()
+ widget = self.qApp.focusWidget()
if (widget == self.regexMultiLineEdit or
widget == self.stringMultiLineEdit or
widget == self.replaceTextEdit or
@@ -909,7 +884,7 @@ 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 = qApp.focusWidget()
+ widget = self.qApp.focusWidget()
if anywidget or (
widget == self.regexMultiLineEdit or
widget == self.stringMultiLineEdit or
@@ -972,156 +947,38 @@ def helpPythonRegex(self):
def helpRegexLib(self):
f = os.path.join("help", "regex-lib.xml")
- self.regexlibwin = RegexLibrary(f)
+ self.regexlibwin = regexLibrary.RegexLibrary(f)
self.regexlibwin.pasteRegexLib.connect(self.pasteFromRegexLib)
self.regexlibwin.show()
def helpAbout(self):
- self.aboutWindow = About()
+ self.aboutWindow = about.About()
self.aboutWindow.show()
def kodos_website(self):
- self.launch_browser_wrapper("http://kodos.sourceforge.net")
-
-
- 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:
- QMessageBox.information(None,
- self.tr("No Update is Available"),
- unicode(self.tr("You are currently using the latest version of Kodos")) + " (%s)" % VERSION)
- else:
- message = "%s\n\n%s: %s.\n%s: %s.\n\n%s\n" % \
- (unicode(self.tr("There is a newer version of Kodos available.")),
- unicode(self.tr("You are using version:")),
- VERSION,
- unicode(self.tr("The latest version is:")),
- latest_version,
- unicode(self.tr("Press OK to launch browser")))
-
- self.launch_browser_wrapper(url,
- self.tr("Kodos Update Available"),
- message)
- else:
- message = "%s.\n\n%s" % \
- (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)
+ 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)
+ 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()
def report_bug(self):
- self.bug_report_win = reportBugWindow(self)
-
-
-##############################################################################
-#
-#
-##############################################################################
-
-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
- sys.exit(0)
-
-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()
-
- for opt, arg in opts:
- if opt in ('-h', '-?', '--help'):
- usage()
- if opt == '-k':
- kodos_dir = arg
- if opt in ('-d', '--debug'):
- try:
- debug = int(arg)
- except:
- print "debug value must be an integer"
- usage()
- if opt in ('-f', '--file'):
- filename = arg
- if opt in ('-l', '--locale'):
- locale = arg
-
- os.environ['KODOS_DIR'] = kodos_dir
-
- qApp = QApplication(sys.argv)
- qApp.setOrganizationName("kodos")
- qApp.setApplicationName("kodos")
- qApp.setOrganizationDomain("kodos.sourceforge.net")
-
- if locale not in (None, 'en'):
- localefile = "kodos_%s.qm" % (locale or QTextCodec.locale())
- localepath = findFile(os.path.join("translations", localefile))
- if debug:
- print "locale changed to:", locale
- print localefile
- print localepath
-
- translator = QTranslator(qApp)
- translator.load(localepath)
-
- qApp.installTranslator(translator)
-
- kodos = Kodos(filename, debug)
-
- kodos.show()
-
- sys.exit(qApp.exec_())
-
-
-
-if __name__ == '__main__':
- 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 90%
rename from modules/parseRegexLib.py
rename to kodos/parseRegexLib.py
index d58c233..da81b9d 100644
--- a/modules/parseRegexLib.py
+++ b/kodos/parseRegexLib.py
@@ -1,6 +1,6 @@
import re
import os
-from util import findFile
+from . import util
rx_entry = re.compile(r"(?P.*?)", re.DOTALL)
@@ -25,7 +25,7 @@
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:
@@ -52,7 +52,7 @@ def parse(self, data=""):
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()
diff --git a/modules/prefs.py b/kodos/prefs.py
similarity index 86%
rename from modules/prefs.py
rename to kodos/prefs.py
index 56ea409..e8e874d 100644
--- a/modules/prefs.py
+++ b/kodos/prefs.py
@@ -1,18 +1,21 @@
# -*- coding: utf-8 -*-
# prefs.py: -*- Python -*- DESCRIPTIVE TEXT.
+import logging
+
from PyQt4.QtCore import pyqtSignal, QSettings
from PyQt4.QtGui import QDialog, QFontDialog
-from prefsBA import PrefsBA
-import help
+from . import prefsBA
+from . import help
-class Preferences(PrefsBA):
+class Preferences(prefsBA.PrefsBA):
prefsSaved = pyqtSignal()
def __init__(self, parent, autoload=0):
+ self.log = logging.getLogger('kodos.prefs')
self.parent = parent
- PrefsBA.__init__(self, parent)
+ prefsBA.PrefsBA.__init__(self, parent)
self.settings = QSettings()
@@ -27,19 +30,17 @@ def load(self):
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, e:
- print "Loading of configuration key", preference, "failed."
+ 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('Email Server', self.emailServerEdit.text())
self.settings.setValue('Recent Files Count', self.recentFilesSpinBox.text())
self.settings.sync()
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 76%
rename from modules/recent_files.py
rename to kodos/recent_files.py
index 31b7dc8..cd6d55f 100644
--- a/modules/recent_files.py
+++ b/kodos/recent_files.py
@@ -1,15 +1,17 @@
# -*- coding: utf-8 -*-
+import logging
+
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()
@@ -28,13 +30,13 @@ def load(self):
break
self.__recent_files.append(str(s))
except Exception, e:
- print "Loading of recent file entry", i, "failed."
- 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:", self.__recent_files
+ self.log.debug("recent_files: %s" % self.__recent_files)
self.addToMenu()
@@ -97,19 +99,3 @@ def setNumShown(self, numShown):
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)
- menu.insertItem(QIconSet(QPixmap(":images/document-open-recent.png")),
- filename,
- -1,
- idx)
- try:
- self.__recent_files.remove(filename)
- except:
- pass
- self.__indecies.insert(0, filename)
-
diff --git a/modules/reference.py b/kodos/reference.py
similarity index 79%
rename from modules/reference.py
rename to kodos/reference.py
index 85c2627..927ce41 100644
--- a/modules/reference.py
+++ b/kodos/reference.py
@@ -2,17 +2,17 @@
# reference.py: -*- Python -*- DESCRIPTIVE TEXT.
from PyQt4.QtCore import pyqtSignal
-from referenceBA import ReferenceBA
-from util import kodos_toolbar_logo, restoreWindowSettings, saveWindowSettings
+from . import referenceBA
+from .util import kodos_toolbar_logo, restoreWindowSettings, saveWindowSettings
GEO = "regex-ref_geometry"
-class Reference(ReferenceBA):
+class Reference(referenceBA.ReferenceBA):
pasteSymbol = pyqtSignal(str)
def __init__(self, parent):
- ReferenceBA.__init__(self, None)
+ referenceBA.ReferenceBA.__init__(self, None)
self.parent = parent
restoreWindowSettings(self, GEO)
diff --git a/modules/referenceBA.ui b/kodos/referenceBA.ui
similarity index 100%
rename from modules/referenceBA.ui
rename to kodos/referenceBA.ui
diff --git a/modules/regexLibrary.py b/kodos/regexLibrary.py
similarity index 80%
rename from modules/regexLibrary.py
rename to kodos/regexLibrary.py
index 13af979..abce53b 100644
--- a/modules/regexLibrary.py
+++ b/kodos/regexLibrary.py
@@ -1,17 +1,17 @@
# -*- coding: utf-8 -*-
from PyQt4.QtCore import pyqtSignal
-from regexLibraryBA import RegexLibraryBA
-from parseRegexLib import ParseRegexLib
-from util import restoreWindowSettings, saveWindowSettings, kodos_toolbar_logo
+from . import regexLibraryBA
+from . import parseRegexLib
+from .util import restoreWindowSettings, saveWindowSettings, kodos_toolbar_logo
GEO = "regex-lib_geometry"
-class RegexLibrary(RegexLibraryBA):
+class RegexLibrary(regexLibraryBA.RegexLibraryBA):
pasteRegexLib = pyqtSignal(dict)
def __init__(self, filename):
- RegexLibraryBA.__init__(self, None)
+ regexLibraryBA.RegexLibraryBA.__init__(self, None)
self.filename = filename
self.selected = None
@@ -28,7 +28,7 @@ def closeEvent(self, ev):
def parseXML(self):
- parser = ParseRegexLib(self.filename)
+ parser = parseRegexLib.ParseRegexLib(self.filename)
self.xml_dicts = parser.parse()
diff --git a/modules/regexLibraryBA.ui b/kodos/regexLibraryBA.ui
similarity index 100%
rename from modules/regexLibraryBA.ui
rename to kodos/regexLibraryBA.ui
diff --git a/modules/resultsBA.ui b/kodos/resultsBA.ui
similarity index 100%
rename from modules/resultsBA.ui
rename to kodos/resultsBA.ui
diff --git a/modules/status_bar.py b/kodos/status_bar.py
similarity index 87%
rename from modules/status_bar.py
rename to kodos/status_bar.py
index e0ba25a..b895b74 100644
--- a/modules/status_bar.py
+++ b/kodos/status_bar.py
@@ -1,13 +1,12 @@
# -*- coding: utf-8 -*-
# status_bar.py: -*- Python -*- DESCRIPTIVE TEXT.
-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()
@@ -16,7 +15,7 @@ def __init__(self, parent, progress_bar=FALSE, message=''):
self.__statusTimer.timeout.connect(self.reset_message)
self.__statusLabel = QLabel("msg", self.statusBar)
- self.tooltip = Tooltip('')
+ self.tooltip = tooltip.Tooltip('')
self.tooltip.addWidget(self.__statusLabel)
self.last_status_message = ''
@@ -30,13 +29,13 @@ def __init__(self, parent, progress_bar=FALSE, message=''):
self.statusBar.addWidget(self.__statusLabel)
if progress_bar:
self.progressBar = QProgressBar(self.statusBar)
- self.statusBar.addWidget(self.progressBar, 1, TRUE)
+ self.statusBar.addWidget(self.progressBar, 1, True)
if message:
self.set_message(message)
- 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.
diff --git a/modules/tooltip.py b/kodos/tooltip.py
similarity index 69%
rename from modules/tooltip.py
rename to kodos/tooltip.py
index ae3dd8e..539051f 100644
--- a/modules/tooltip.py
+++ b/kodos/tooltip.py
@@ -1,29 +1,27 @@
# -*- coding: utf-8 -*-
# tooltip.py: -*- Python -*- DESCRIPTIVE TEXT.
-from PyQt4.QtGui import *
-from PyQt4.QtCore import *
-from util import *
+from PyQt4 import Qt, QtCore
-class Tooltip(QLabel):
+class Tooltip(Qt.QLabel):
def __init__(self, text, bgcolor="#ffd700",fgcolor="#000000",delay=1000):
self.delay = delay
- QLabel.__init__(self, None, Qt.WindowStaysOnTopHint
- | Qt.FramelessWindowHint
- | Qt.Tool)
+ Qt.QLabel.__init__(self, None, QtCore.Qt.WindowStaysOnTopHint
+ | QtCore.Qt.FramelessWindowHint
+ | QtCore.Qt.Tool)
self.setMargin(1)
self.setIndent(0)
- self.setFrameStyle(QFrame.Plain | QFrame.Box)
+ self.setFrameStyle(Qt.QFrame.Plain | Qt.QFrame.Box)
self.setLineWidth(1)
self.setText(text)
self.adjustSize()
# set the pallete...
- pal = QPalette()
- pal.setColor(QPalette.Active, QPalette.Window, QColor(bgcolor))
- pal.setColor(QPalette.Active, QPalette.WindowText, QColor(fgcolor))
- pal.setColor(QPalette.Inactive, QPalette.Window, QColor(bgcolor))
- pal.setColor(QPalette.Inactive, QPalette.WindowText, 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
@@ -67,15 +65,15 @@ def timerEvent( self, ev ):
def eventFilter(self, obj, ev):
type = ev.type()
- if type == QEvent.Enter:
+ if type == Qt.QEvent.Enter:
self.killCustomTimers()
self.enter_timer_id = self.startTimer(self.delay)
self.event_widget = obj
- elif type == 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):
@@ -84,7 +82,7 @@ def tooltip_open(self):
try:
pos = self.event_widget.mapToGlobal(
- 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() )
diff --git a/modules/urlDialog.py b/kodos/urlDialog.py
similarity index 86%
rename from modules/urlDialog.py
rename to kodos/urlDialog.py
index 1900bf2..7ea64db 100644
--- a/modules/urlDialog.py
+++ b/kodos/urlDialog.py
@@ -1,17 +1,18 @@
# -*- coding: utf-8 -*-
+
from PyQt4.QtCore import pyqtSignal
from PyQt4.QtGui import QMessageBox
-from urlDialogBA import URLDialogBA
-import help
+from . import urlDialogBA
+from . import help
import urllib
-class URLDialog(URLDialogBA):
+class URLDialog(urlDialogBA.URLDialogBA):
urlImported = pyqtSignal(str, str)
def __init__(self, parent, url=None):
- URLDialogBA.__init__(self, parent)
+ urlDialogBA.URLDialogBA.__init__(self, parent)
if url:
self.URLTextEdit.setPlainText(url)
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/modules/util.py b/kodos/util.py
similarity index 64%
rename from modules/util.py
rename to kodos/util.py
index 2fca4f0..da53882 100644
--- a/modules/util.py
+++ b/kodos/util.py
@@ -2,47 +2,38 @@
# util.py: -*- Python -*- DESCRIPTIVE TEXT.
import os
-import os.path
import sys
-from debug import *
+import logging
import webbrowser
-from PyQt4.QtGui import *
-from PyQt4.QtCore import *
+from PyQt4 import Qt
-# QT constants that should be defined
-FALSE = 0
-TRUE = 1
-
-global debug
+log = logging.getLogger('kodos.util')
def getAppPath():
"Convenience function so that we can find the necessary images"
- fullpath = os.path.abspath(sys.argv[0])
+ 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 QPixmap instance for the file fileStr relative
+ """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
-
- if debug & DEBUG_PIXMAP: print "image:", image
-
- pixmap = QPixmap(image, fileType)
+ pixmap = Qt.QPixmap(image, fileType)
pixmap.setMask(pixmap.createHeuristicMask(1))
return pixmap
def kodos_toolbar_logo(toolbar):
# hack to move logo to right
- blanklabel = QLabel()
- blanklabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
+ blanklabel = Qt.QLabel()
+ blanklabel.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Preferred)
- logolabel = QLabel("kodos_logo")
- logolabel.setPixmap(QPixmap(":/images/kodos_icon.png"))
+ logolabel = Qt.QLabel("kodos_logo")
+ logolabel.setPixmap(Qt.QPixmap(":/images/kodos_icon.png"))
toolbar.addWidget(blanklabel)
toolbar.addWidget(logolabel)
@@ -50,11 +41,11 @@ def kodos_toolbar_logo(toolbar):
return logolabel
def saveWindowSettings(window, filename):
- settings = QSettings()
+ settings = Qt.QSettings()
settings.setValue(window.objectName(), window.saveGeometry())
def restoreWindowSettings(window, filename):
- settings = QSettings()
+ settings = Qt.QSettings()
window.restoreGeometry(settings.value(window.objectName()).toByteArray())
def findFile(filename):
@@ -72,14 +63,12 @@ def launch_browser(url, caption=None, message=None):
if not caption: caption = "Info"
if not message: message = "Launch web browser?"
- button = QMessageBox.information(None, caption, message, QMessageBox.Ok | QMessageBox.Cancel)
- if button == QMessageBox.Cancel:
+ 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, e:
- if debug:
- print e
- print "Couldn't open URL:", url
+ log.error("Couldn't open URL %r: %s" % (url, e))
return False
return True
diff --git a/modules/version.py b/kodos/version.py
similarity index 100%
rename from modules/version.py
rename to kodos/version.py
diff --git a/modules/debug.py b/modules/debug.py
deleted file mode 100755
index 32fd790..0000000
--- a/modules/debug.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# debug.py: -*- Python -*- DESCRIPTIVE TEXT.
-
-################################# 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/reportBug.py b/modules/reportBug.py
deleted file mode 100644
index e4351e4..0000000
--- a/modules/reportBug.py
+++ /dev/null
@@ -1,104 +0,0 @@
-# -*- coding: utf-8 -*-
-# reportBug.py: -*- Python -*- DESCRIPTIVE TEXT.
-
-from reportBugBA import reportBugBA
-from util import *
-from PyQt4.QtGui import *
-from PyQt4.QtCore import *
-from PyQt4 import *
-import sys
-import string
-import smtplib
-from version import VERSION
-
-AUTHOR_ADDR = "phil_schwartz@users.sourceforge.net"
-
-class reportBug(reportBugBA):
- def __init__(self, parent=None, name=None):
- reportBugBA.__init__(self, parent)
- self.parent = parent
- self.kodos_main = parent.kodos_main
- self.populate()
-
-
- def populate(self):
- self.OSEdit.setText(sys.platform)
- pyvers = string.replace(sys.version, "\n", " - ")
- self.pythonVersionEdit.setText(pyvers)
- self.PyQtVersionEdit.setText(QT_VERSION_STR)
- self.regexMultiLineEdit.setPlainText(self.kodos_main.regexMultiLineEdit.toPlainText())
- self.stringMultiLineEdit.setPlainText(self.kodos_main.stringMultiLineEdit.toPlainText())
-
-
- def cancel_slot(self):
- self.parent.close()
-
- 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.")
-
- QMessageBox.information(None,
- self.tr("You must supply a valid email address"),
- msg)
- return
-
- msg = "Subject: Kodos bug report\n\n"
- msg += "Kodos Version: %s\n" % VERSION
- msg += "Operating System: %s\n" % unicode(self.OSEdit.text())
- msg += "Python Version: %s\n" % unicode(self.pythonVersionEdit.text())
- msg += "PyQt Version: %s\n" % unicode(self.PyQtVersionEdit.text())
- msg += "\n" + "=" * 70 + "\n"
- msg += "Regex:\n%s\n" % unicode(self.regexMultiLineEdit.text())
- msg += "=" * 70 + "\n"
- msg += "String:\n%s\n" % unicode(self.stringMultiLineEdit.text())
- msg += "=" * 70 + "\n"
- msg += "Comments:\n%s\n" % 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()
- QMessageBox.information(None,
- self.tr("Bug report sent"),
- self.tr("Your bug report has been sent."))
- self.parent.close()
- except Exception, e:
- QMessageBox.information(None,
- self.tr("An exception occurred sending bug report"),
- str(e))
-
-
-class reportBugWindow(QMainWindow):
- def __init__(self, kodos_main):
- self.kodos_main = kodos_main
- QMainWindow.__init__(self, kodos_main)#, Qt.Window | Qt.WA_DeleteOnClose)
-
- self.setGeometry(100, 50, 800, 600)
- self.setWindowTitle(self.tr("Report a Bug"))
- self.setWindowIcon(QIcon(QPixmap(":images/kodos_icon.png")))
-
- self.bug_report = reportBug(self)
- self.setCentralWidget(self.bug_report)
-
-
- self.createMenu()
- self.createToolBar()
-
- self.show()
-
-
- def createMenu(self):
- self.menubar = self.menuBar()
- self.filemenu = self.menubar.addMenu(self.tr("&File"))
- self.filemenu.addAction(self.tr("&Close"), self, SLOT("close()"))
-
-
- def createToolBar(self):
- toolbar = QToolBar()
- self.addToolBar(toolbar)
- self.logolabel = kodos_toolbar_logo(toolbar)
-
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/setup.py b/setup.py
index 10d62ed..822db89 100644
--- a/setup.py
+++ b/setup.py
@@ -1,13 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from modules.version import VERSION
+from kodos.version import VERSION
from distutils.core import setup
-from distutils.command.install import install as DistutilsInstall
-#from distutils.sysconfig import get_python_lib
+from distutils.command.build_py import build_py as _build_py
import os
-import os.path
import sys
from glob import glob
+import subprocess
args = sys.argv[1:]
@@ -15,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":
@@ -27,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,
@@ -43,21 +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},
)
-
|