Developer Guide¶
This part of the documentation currently acts as a note pad. Information contained may be incomplete and incoherent. It will improve over time.
Coding Conventions¶
Adding a new Source Code File¶
- Add the file to the packages section of setup.py.
- Add the copyright note.
- Document the file by using docstrings (Sphinx).
- Add the file to the documentation:
- Add the module to the proper .rst file. You may need to create a new one. In that case, ensure that the new .rst is also added to the proper file in the documentation tree.
- Create a new build of the documentation and check if your references are set correctly and see if new errors/warnings have occurred.
- If the file contains new features, ensure you have written a test case. Add it to the test package. Repeat steps 2-4 for the test file.
Generating the Documentation¶
Sphinx is used to document SeriesMarker. The documentation is rendered per default with the Alabaster theme. You may need to install both on your system beforehand:
$pip install sphinx alabaster
To generate the documentation for SeriesMarker, perform the following steps:
Check out SeriesMarker.
Change to the
doc
sub directory.- on Linux / OS X:
execute
make html
.
- on Windows:
execute
make.bat html
.
The resulting documentation can be found at the
doc/build/html
sub directory. It contains anindex.html
file, which can be opened with a browser to display the generated documentation.
Testing¶
To run all existing test cases, after checking out SeriesMarker, execute the following command at SeriesMarker’s root directory:
$python setup test
This will build SeriesMarker and run all tests against it. To skip the package creation, run the test suite directly via:
$python -m unittest seriesmarker/test/test_runner.py
To only run topic specific test cases, similar suits can be found in the sub packages of the test directory:
$python setup.py test --test-suite="seriesmarker.test.database.database_test_runner"
$python setup.py test --test-suite="seriesmarker.test.gui.gui_test_runner.py"
respectively
$python -m unittest seriesmarker/test/database/database_test_runner.py
$python -m unittest seriesmarker/test/gui/gui_test_runner.py
Distributing SeriesMarker¶
This section describes how a binary package of SeriesMarker can be built for various operating systems.
Microsoft Windows¶
On Microsoft Windows, cx_Freeze is the recommended tool to create a binary package of SeriesMarker.
Prerequisites¶
The prerequisites to build a binary package of SeriesMarker on Microsoft Windows are the same as for building from source. Please fulfill those first before continuing.
Install Dependencies¶
Install SeriesMarker’s dependencies via pip. In addition, cx_Freeze needs to be installed:
pip install cx_Freeze
Creating a Binary Distribution¶
This section describes, how to create an installer for SeriesMarker from source.
- Check out SeriesMarker.
- Open the
Command Prompt
(cmd.exe) and change to the root directory of SeriesMarker. - Execute
python setup.py bdist_msi
to create a msi-installer, which can be found at the dist directory.
The installer can then be used as described in the install procedure for Microsoft Windows.
OS X¶
On OS X, py2app is the recommended tool to create a binary package of SeriesMarker.
Prerequisites¶
The prerequisites to build a binary package for SeriesMarker on OS X are the same as for building from source. Please fulfill those first before continuing.
Install Dependencies¶
Proceed as described in Install Dependencies. In addition, py2app needs to be installed:
$sudo port install py34-py2app
Prepare Packages¶
py2app¶
There is a py2app bug, which prevents the app to function properly with recent versions of one of its dependencies inside virtual environments. To resolve it, open the virtualenv recipe file of py2app, probably located at
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/py2app/recipes/virtualenv.py
and modify the load_module
and scan_code
method calls as shown in the bug
report.
Creating a Binary distribution¶
When your system is prepared to build SeriesMarker as described in the previous sections, you can now create a distributable binary with the following steps:
- Check out SeriesMarker.
- Open a shell (
Terminal
) and change to the root directory of SeriesMarker. - Execute
python3.4 setup.py py2app
to create an application and a disk image, containing a copy of the application. Both can be found at the dist directory.
The resulting app
can then be used as usual. The disk image is
the preferred way to distribute the application, providing a simple installer
as shown in the install procedure for OS X.
Notes¶
API Generation¶
$sphinx-apidoc --module-first --separate --force --maxdepth=5 --output-dir=./doc/source/apidoc/ ./seriesmarker
TheTVDB API¶
Links to the TheTVDB API for checking raw data.
- Languages:
- http://thetvdb.com/api/APIKEY/languages.xml
- Mirrors:
- http://thetvdb.com/api/APIKEY/mirrors.xml
- Server Time:
- http://www.thetvdb.com/api/Updates.php?type=none
- Search:
- http://www.thetvdb.com/api/GetSeries.php?seriesname=how%20i%20met%20your%20mother
- Series (basic):
- http://thetvdb.com/api/APIKEY/series/75760/en.xml
- Series (full):
- http://thetvdb.com/api/APIKEY/series/75760/all/en.xml
- Banners:
- http://thetvdb.com/api/APIKEY/series/75760/banners.xml
- Episode:
- http://thetvdb.com/api/APIKEY/episodes/1159571/en.xml
- Updates:
- http://thetvdb.com/api/APIKEY/updates/updates_all.xml
Todo List¶
Todo
Update should also recognize/announce updated episodes.
(The original entry is located in /home/tobias/Workspaces/Python/SeriesMarker/seriesmarker/gui/main_window.py:docstring of seriesmarker.gui.main_window.MainWindow.on_action_update_triggered, line 3.)
Todo
Should change view only if next style differs from current one - needs to compare with previous selection.
(The original entry is located in /home/tobias/Workspaces/Python/SeriesMarker/seriesmarker/gui/main_window.py:docstring of seriesmarker.gui.main_window.MainWindow.on_tree_view_clicked, line 7.)
Todo
Should return a pixmap of an episode snapshot image instead of
a default icon. By solving the todo, this method becomes
obsolet and needs to be deleted - use/override
DecoratedNode.banner_url()
instead.
(The original entry is located in /home/tobias/Workspaces/Python/SeriesMarker/seriesmarker/gui/model/episode_node.py:docstring of seriesmarker.gui.model.episode_node.EpisodeNode.decoration, line 6.)
Todo
The banner_loader may cause an access to an invalid index if another search with less results was initiated before all banner were loaded. Prevent the beginning of a new search before the last has been finished, or clear the banner_loader at clearing this model. Afterwards remove the warning log. Also remove the None check at setData of this model then.
(The original entry is located in /home/tobias/Workspaces/Python/SeriesMarker/seriesmarker/gui/model/search/search_model.py:docstring of seriesmarker.gui.model.search.search_model.SearchModel.node_at, line 6.)
Todo
Update of CheckState / progress kinda ugly, may be done in
check(value), but needs reference to index and model - add
reference to each node? Example: for change in changes:
self.dataChanged.emit(change.get_index())
(The original entry is located in /home/tobias/Workspaces/Python/SeriesMarker/seriesmarker/gui/model/tree_series_model.py:docstring of seriesmarker.gui.model.tree_series_model.TreeSeriesModel.setData, line 24.)
Todo
After upgrade to QT5, use SignalSpy in test case to check if only changes are emitted if there was really a change after checking.
(The original entry is located in /home/tobias/Workspaces/Python/SeriesMarker/seriesmarker/gui/model/tree_series_model.py:docstring of seriesmarker.gui.model.tree_series_model.TreeSeriesModel.setData, line 30.)
Todo
Accept button of SearchDialog should be disable while search is ongoing, or no valid result has been selected yet.
(The original entry is located in /home/tobias/Workspaces/Python/SeriesMarker/seriesmarker/gui/search_dialog.py:docstring of seriesmarker.gui.search_dialog.SearchDialog.accept, line 7.)
Todo
Method may be omitted in favor of public attribute if
unittest.mock
offers a way to set it for testing.
(The original entry is located in /home/tobias/Workspaces/Python/SeriesMarker/seriesmarker/gui/search_dialog.py:docstring of seriesmarker.gui.search_dialog.SearchDialog.result_value, line 5.)
Todo
Check if item really is generic, dispatch to proper remove function otherwise.
(The original entry is located in /home/tobias/Workspaces/Python/SeriesMarker/seriesmarker/persistence/database.py:docstring of seriesmarker.persistence.database.db_remove_item, line 3.)
Todo
Convert banner_type to Enum, as soon as Python supports it (probably 3.4).
(The original entry is located in /home/tobias/Workspaces/Python/SeriesMarker/seriesmarker/persistence/factory/banner_factory.py:docstring of seriesmarker.persistence.factory.banner_factory.BannerFactory.new_banner, line 13.)
Todo
Logging should be used to list differences on update of series/episodes.
(The original entry is located in /home/tobias/Workspaces/Python/SeriesMarker/seriesmarker/persistence/factory/base_factory.py:docstring of seriesmarker.persistence.factory.base_factory.BaseFactory._handle_list_attribute, line 15.)
Todo
Episode specials have additional attributes where regular ones do not. The pytvdbapi logs an exception if it is tried to access them on a regular episode. Either check existence beforehand, or see if pytvdbapi changes output.
(The original entry is located in /home/tobias/Workspaces/Python/SeriesMarker/seriesmarker/persistence/factory/episode_factory.py:docstring of seriesmarker.persistence.factory.episode_factory.EpisodeFactory.new_episode, line 13.)
Todo
Instead of adding each series sequentially, the model could be expanded with a method to add multiple series, which could speed up the application’s start.
(The original entry is located in /home/tobias/Workspaces/Python/SeriesMarker/seriesmarker/seriesmarker.py:docstring of seriesmarker.seriesmarker.main, line 6.)
Todo
Might be merged with StoryTest
in separate test-class to
reduce boilerplate code (setUpClass, setUp).
(The original entry is located in /home/tobias/Workspaces/Python/SeriesMarker/seriesmarker/test/gui/sorting_test.py:docstring of seriesmarker.test.gui.sorting_test.SortingTest, line 8.)