diff --git a/src/pytomb/tomblib/test_parser.py b/src/pytomb/tomblib/test_parser.py new file mode 100644 index 0000000..d601f4d --- /dev/null +++ b/src/pytomb/tomblib/test_parser.py @@ -0,0 +1,29 @@ +from tomblib.parser import * + +class TestWrong: + def test_wrong_tag(self): + assert parse_line(' [a] foo') is None + def test_no_space(self): + assert parse_line(' [!]foo') is None + +class TestError: + def test_simple(self): + parse = parse_line('[!] foo') + assert parse is not None + assert parse['type'] == 'error' + assert parse['content'] == 'foo' + def test_preceding(self): + parse = parse_line(' [!] foo') + assert parse is not None + assert parse['type'] == 'error' + assert parse['content'] == 'foo' + def test_following(self): + parse = parse_line('[!]shdad foo') + assert parse is not None + assert parse['type'] == 'error' + assert parse['content'] == 'foo' + def test_mul_words(self): + parse = parse_line('[!] shdad foo') + assert parse is not None + assert parse['type'] == 'error' + assert parse['content'] == 'shdad foo' diff --git a/src/qt/.gitignore b/src/qt/.gitignore index 3bb2efd..dd75296 100644 --- a/src/qt/.gitignore +++ b/src/qt/.gitignore @@ -1,2 +1,4 @@ .*.swp *.pyc +TombQt.egg-info +build diff --git a/src/qt/setup.py b/src/qt/setup.py new file mode 100644 index 0000000..cca8ae2 --- /dev/null +++ b/src/qt/setup.py @@ -0,0 +1,46 @@ +import os +import glob +from setuptools import setup +from StringIO import StringIO + +from distutils import log +from distutils.core import Command +from distutils.dep_util import newer + +class build_ui(Command): +# Stolen from picard + description = "build Qt UI files" + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + from PyQt4 import uic + for uifile in glob.glob("tombqt/*.ui"): + pyfile = "ui_%s.py" % os.path.splitext(os.path.basename(uifile))[0] + pyfile = os.path.join('tombqt', pyfile) + if newer(uifile, pyfile): + log.info("compiling %s -> %s", uifile, pyfile) + tmp = StringIO() + uic.compileUi(uifile, tmp) + source = tmp.getvalue() + f = open(pyfile, "w") + f.write(source) + f.close() + +setup( + name = 'TombQt', + version = '0.1', + packages = ['tombqt'], + cmdclass = { + 'build_ui': build_ui + } +) + + + + diff --git a/src/qt/create.py b/src/qt/tombqt/create.py similarity index 100% rename from src/qt/create.py rename to src/qt/tombqt/create.py diff --git a/src/qt/create.ui b/src/qt/tombqt/create.ui similarity index 100% rename from src/qt/create.ui rename to src/qt/tombqt/create.ui diff --git a/src/qt/ui_create.py b/src/qt/tombqt/ui_create.py similarity index 100% rename from src/qt/ui_create.py rename to src/qt/tombqt/ui_create.py diff --git a/src/qt/worker.py b/src/qt/tombqt/worker.py similarity index 100% rename from src/qt/worker.py rename to src/qt/tombqt/worker.py