Skip to content

Commit

Permalink
Merge branch 'release/v1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Nunes committed Apr 22, 2016
2 parents 8127bb1 + ced910f commit 5cb0b73
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 32 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
Changelog
=========

1.1.0 (2016-04-22)

* Syntax errors are now properly handled.
* All dialogs now have icons.
* Added icon to windows executable.
* Last used package path is now saved for next usage.


----------------------------------


1.0.0 (2016-04-21)

* Initial stable release.
2 changes: 1 addition & 1 deletion dev/pyinstaller-build.spec
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ exe = EXE(pyz,
debug=False,
strip=False,
upx=True,
console=False )
console=False , icon='resources/file_icon.ico')
4 changes: 3 additions & 1 deletion fomod/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import traceback
import io
from PyQt5 import QtWidgets, QtGui
from . import __version__
from os.path import join
from . import __version__, cur_folder


def excepthook(exc_type, exc_value, tracebackobj):
Expand Down Expand Up @@ -46,4 +47,5 @@ def excepthook(exc_type, exc_value, tracebackobj):
errorbox.setText(notice)
errorbox.setDetailedText(msg)
errorbox.setWindowTitle("Nobody Panic!")
errorbox.setIconPixmap(QtGui.QPixmap(join(cur_folder, "resources/logo_admin.png")))
errorbox.exec_()
56 changes: 38 additions & 18 deletions fomod/mainframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from PyQt5 import uic, QtWidgets, QtCore
from os.path import join, expanduser
from PyQt5 import uic, QtWidgets, QtCore, QtGui
from configparser import ConfigParser, NoSectionError
from os.path import join, expanduser, isdir
from os import mkdir
from . import cur_folder

base_ui = uic.loadUiType(join(cur_folder, "resources", "mainframe.ui"))
Expand All @@ -27,6 +29,10 @@ def __init__(self):
self.setupUi(self)

self.setWindowFlags(QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)
window_icon = QtGui.QIcon()
window_icon.addPixmap(QtGui.QPixmap(join(cur_folder, "resources/window_icon.jpg")),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.setWindowIcon(window_icon)

self.buttonBox.accepted.connect(self.accepted)
self.buttonBox.rejected.connect(self.rejected)
Expand All @@ -36,16 +42,39 @@ def __init__(self):
self.checked_validate = False
self.checked_warnings = False

if isdir(join(expanduser("~"), ".fomod")):
config = ConfigParser()
config.read(join(expanduser("~"), ".fomod", ".validator"))
try:
self.package_path = config.get("Path", "lastused", fallback="")
except NoSectionError:
pass

if not self.package_path:
self.init_path = expanduser("~")
else:
self.init_path = self.package_path
self.path_text.setText(self.package_path)

self.show()

def accepted(self):
from .validator import validate, check_warnings, \
ValidationError, WarningError, MissingFolderError, MissingFileError
from .validator import validate, check_warnings, ValidatorError

self.package_path = self.path_text.text()
self.checked_validate = self.check_validate.isChecked()
self.checked_warnings = self.check_warnings.isChecked()

try:
mkdir(join(expanduser("~"), ".fomod"))
except OSError:
pass
config = ConfigParser()
config.add_section("Path")
config.set("Path", "lastused", self.package_path)
with open(join(expanduser("~"), ".fomod", ".validator"), "w") as configfile:
config.write(configfile)

self.close()

try:
Expand All @@ -61,19 +90,10 @@ def accepted(self):
errorbox.setWindowTitle("Yay!")
errorbox.exec_()
return
except ValidationError as v:
errorbox.setText(str(v))
errorbox.setWindowTitle("Invalid File(s)")
errorbox.exec_()
return
except WarningError as w:
errorbox.setText(str(w))
errorbox.setWindowTitle("Warnings Log")
errorbox.exec_()
return
except (MissingFileError, MissingFolderError) as m:
errorbox.setText(str(m))
errorbox.setWindowTitle("I/O Error")
except ValidatorError as e:
errorbox.setText(str(e))
errorbox.setWindowTitle(e.title)
errorbox.setIconPixmap(QtGui.QPixmap(join(cur_folder, "resources/logo_admin.png")))
errorbox.exec_()
return

Expand All @@ -82,4 +102,4 @@ def rejected(self):

def path_button_clicked(self):
open_dialog = QtWidgets.QFileDialog()
self.path_text.setText(open_dialog.getExistingDirectory(self, "Package directory:", expanduser("~")))
self.path_text.setText(open_dialog.getExistingDirectory(self, "Package directory:", self.init_path))
2 changes: 1 addition & 1 deletion fomod/validator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

from .validate import validate
from .warnings import check_warnings
from .exceptions import ValidationError, WarningError, MissingFolderError, MissingFileError
from .exceptions import ValidatorError, ValidationError, WarningError, MissingFolderError, MissingFileError, ParserError
31 changes: 27 additions & 4 deletions fomod/validator/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,48 @@
# limitations under the License.


class MissingFolderError(Exception):
class ValidatorError(Exception):
def __init__(self, msg):
self.title = "Validator Error"
Exception.__init__(self, msg)


class MissingFolderError(ValidatorError):
def __init__(self, folder):
self.msg = folder + " folder is missing."
self.title = "I/O Error"
Exception.__init__(self, self.msg)


class MissingFileError(Exception):
class MissingFileError(ValidatorError):
def __init__(self, file):
self.msg = file + " file is missing."
self.title = "I/O Error"
Exception.__init__(self, self.msg)


class ValidationError(Exception):
class ValidationError(ValidatorError):
def __init__(self, msg=""):
self.msg = msg
self.title = "Invalid File(s)"
Exception.__init__(self, self.msg)


class WarningError(Exception):
class WarningError(ValidatorError):
def __init__(self, msg=""):
self.msg = msg
self.title = "Warnings Log"
Exception.__init__(self, self.msg)


class ParserError(ValidatorError):
def __init__(self, msg):
self.title = "Parser Error"
if len(msg.split(",")) <= 2:
self.msg = "The parser couldn't read the installer file. If you need help visit " \
"<a href = http://www.w3schools.com/xml/xml_syntax.asp>W3Schools</a>."
else:
self.msg = "The parser couldn't read the installer file, there was an error around" + \
msg.split(",")[len(msg.split(",")) - 2] + \
". If you need help visit <a href = http://www.w3schools.com/xml/xml_syntax.asp>W3Schools</a>."
Exception.__init__(self, self.msg)
4 changes: 3 additions & 1 deletion fomod/validator/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from os.path import join
from lxml import etree
from .utility import check_fomod, check_file
from .exceptions import MissingFileError, MissingFolderError, ValidationError
from .exceptions import MissingFileError, MissingFolderError, ValidationError, ParserError


def validate(package_path, cur_folder):
Expand All @@ -29,6 +29,8 @@ def validate(package_path, cur_folder):
xmlschema.assertValid(etree.parse(join(package_path, fomod_folder, config_file)))
except (MissingFolderError, MissingFileError):
raise
except etree.ParseError as e:
raise ParserError(str(e))
except etree.DocumentInvalid as e:
raise ValidationError(check_file(join(package_path, check_fomod(package_path))) +
" is invalid with error message:\n\n" + str(e))
9 changes: 5 additions & 4 deletions fomod/validator/warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from os.path import join, isfile, isdir
from lxml import etree
from .utility import check_file, check_fomod
from .exceptions import MissingFileError, MissingFolderError, WarningError
from .exceptions import MissingFileError, MissingFolderError, WarningError, ParserError


def check_warnings(package_path):
Expand All @@ -36,8 +36,7 @@ def __init__(self, elements, title, msg):
for elem_ in elements:
self.msgs[elem_.tag] = msg.replace("{}", elem_.tag)

result = "<b>Warnings Log</b><br><br><br><br>"
result_initial = result
result = ""

repeatable_tags = ("moduleName", "moduleImage", "moduleDependencies",
"requiredInstallFiles", "installSteps", "conditionalFileInstalls", "")
Expand Down Expand Up @@ -98,10 +97,12 @@ def __init__(self, elements, title, msg):

result += _log_warnings([repeat_log, folder_log, file_log])

if result != result_initial:
if result:
raise WarningError(result)
except (MissingFolderError, MissingFileError):
raise
except etree.ParseError as e:
raise ParserError(str(e))


def _log_warnings(list_):
Expand Down
Binary file added resources/file_icon.ico
Binary file not shown.
Binary file added resources/logo_admin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/window_icon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.0.0
current_version = 1.1.0
current_build = 0

[bumpversion:file:setup.py]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='fomod-validator',
version='1.0.0',
version='1.1.0',
packages=['validator'],
package_dir={'validator': 'fomod/validator'},
url='https://github.com/GandaG/fomod-validator',
Expand Down

0 comments on commit 5cb0b73

Please sign in to comment.