=== Requirements ===

The Python modules required are:

* SQLObject [ http://cheeseshop.python.org/pypi/SQLObject, version 0.9.0 ]
* PyProtocols [ http://cheeseshop.python.org/pypi/PyProtocols ]
* PLY (for parsing the query language) [ http://www.dabeaz.com/ply/ ]
* sqlite (or the module for whatever database one plans to use)
* PyGtk (for the GUI) [ http://cheeseshop.python.org/pypi/PyGTK ]
* Python-xml for the xml writing support
* Python-rsvg for the sutekh icon
* configobj to manage the config file

One will also need to download the official cardlist at:

* http://www.vekn.net/images/stories/downloads/cardlist.txt

to a local file.  Sutekh can also parse the official rulings
file from:

* http://www.white-wolf.com/vtes/index.php?line=rulings

so that might be useful too.

=== Getting Started ===

These instructions assume you have run setup.py install or setup.py develop,
which creates the correct name for the scripts.

Most operations can be accomplished via the gui. You will be prompted
to load the WW cardlist the first time you run Sutekh. These instructions
cover the command line tool sutekh-cli, while help for the gui can be found
either by using the help menu, or in sutekh/docs/html/

To get started, run:

sutekh-cli --help
sutekh-cli -c -r vtes_card_file.txt
sutekh-cli --ruling-file vtes_ruling_file.html (optional)

The card list and card sets can be manipulated and examined via the gui

Its possible to query individual cards:

sutekh-cli --print-card='Aching Beauty'

Likewise, it's also possible to export and read in card sets.

sutekh-cli --save-cs "Toreador Deck" --cs-filename=deck.xml
saves the card set called "Toreador Deck" to the file "deck.xml",
while
sutekh-cli --read-cs="vampires.xml"
loads the Card Set saved as vampires.xml

A card set can be printed to screen using:

sutekh-cli --print-cs='Toreador Deck'

The list of card sets can be seen using:

sutekh-cli --list-cs

A --reload option exists for when re-importing the official cardlists and
rulings.  This dumps and then reloads the card list and all the card sets.

Typically used as:
sutekh-cli -c --reload -r vtes_card_file.txt \
      --ruling-file vtes_ruling_file.html

The command line tool can be used to run filters:

sutekh-cli --filter='<Filter>'

will filter the WW card list using the given filter

The --filter-detailed will print the full details of all matching cards,
rather than just the names.

The filters can also be run on a card set, by using the --filter-cs option

So:

sutekh-cli --filter="CardText='stealth' and CardType='Action Modifier'" \
    --filter-cs='Tzimisce deck' --filter-detailed

will list and print details of all action modifiers containing with 'stealth'
in their card text for the card set 'Tzimisce deck'

=== Windows Quickstart ===

Download:
 * Python
   - http://www.python.org/ftp/python/2.5.1/python-2.5.1.msi
 * Setuptools
   - http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c6.win32-py2.5.exe
 * PyGTK
   - http://gladewin32.sourceforge.net/modules/wfdownloads/visit.php?cid=14&lid=110
   - http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.12/pygobject-2.12.3-1.win32-py2.5.exe
   - http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/1.2/pycairo-1.2.6-1.win32-py2.5.exe
   - http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.10/pygtk-2.10.4-1.win32-py2.5.exe
 * PyProtocols
   - http://files.turbogears.org/eggs/PyProtocols-1.0a0-py2.5-win32.egg
 * Sutekh

And install Python, then Setuptools, then PyGTK.

Run easy_install PyProtocols-1.0a0-py2.5-win32.egg (easy_install is in <python install dir>/Scripts).
Run easy_install <Sutekh Egg File>.

Run <python install dir>/Scripts/sutekh

=== Using Sutekh from the Python Interpreter ===

Sutekh also allows you to play around with the database from inside the Python
interpreter:

python
>>> from sutekh import *
>>> start()

An example:

Print all Malkavian cards:
>>> for oC in Clan.byName('Malkavian').cards:
...           print oC.name

>>> oTony = AbstractCard.byName('Tony')
>>> print oTony
>>> for oP in oTony.discipline:
...     print oP.level, oP.discipline
>>> print oTony.cardtype
>>> print oTony.capacity
>>> print oTony.clan
>>> print oTony.group
>>> print oTony.text
>>> oMariel = list(AbstractCard.select(AbstractCard.q.name.startswith('Mariel')))[0]

Filtering:

>>> aC = AbstractCard.select(CardTextFilter('Laibon').getExpression())
>>> for oC in aC:
...     print oC.name, oC.cardtype

>>> oF1 = DisciplineFilter('Dementation')
>>> oF2 = CardTextFilter('bleed')
>>> oF3 = CardTypeFilter('Action')
>>> oF4 = CardTypeFilter('Action Modifier')
>>> oF5 = FilterOrBox([oF3,oF4])
>>> oF = FilterAndBox([oF1,oF2,oF5])
>>> for oC in AbstractCard.select(oF.getExpression()):
...     print "---", oC.name, "---"
...     print oC.text

=== Database Notes ===

==== Using other database backends ====

Sutekh has been developed mainly with sqlite, but, since it uses SQLObject for
to manage the databases, it is possible to try other database backends by
specifying a suitable URI. For both sutekh and sutekh-cli, the -d
parameter specifies the database to use.

This can also be set for the gui using the "database url" parameter in the
config file.

Sutekh is frequently tested using MySQL and PostgresSQL.

To use a PostgresSQL database with Sutekh, specify:

sutekh -d postgres://username@host/database

With SQLObject 0.9, the url syntax for MySQL is somewhat complex, due
to the encoding issues involved. We have had good results using utf8 as the
encoding, specified as:

mysql://username@host/database?sqlobject_encoding=utf8&charset=utf8

In our experience, utf8 is the most robust and portable choice.

When using sqlobject 0.10 or later, the sqlobjct_encoding parameter is no
longer needed, and the URI can be simplified to:

mysql://username@host/database?charset=utf8

MySQL 4 or earlier will definitely NOT work. This is unlikely to ever change.

Other databases are untested.

To dump data between databases, you can use the zip file support. Something
like (assuming that the new database has already had the cardlist & rulings
imported):

sutekh-cli -d <old_database_uri> --dump-zip=zipfile.zip

sutekh-cli -d <new_database_uti> --restore-zip=zipfile.zip

==== Disabling SQLObject caching ====

When using the default sqlite database, Sutekh disables SQLObject's internal
caching. As number of the items SQLObject caches aren't important to Sutekh,
and, on large card set loads, the overhead of maintaining the cache is
significant, it can be beneficial to disable the cache with other database as
well. Disabling the cache is recommended with SQLObject 0.12 and later, where
changes to the cache culling algorithm have a more noticeable impact on
performance.

To disable the cache for the other databases, append '?cache=False' to
the database url:

sutekh -d postgres://username@host/database?cache=False

or

sutekh -d mysql://username@host/database?cache=False&charset=utf8

=== Clustering Plugin ===

Sutekh has the ability to data mine card sets for related groups of
cards using the Cluster 3.0 [1] data clustering package. You'll need to download
a version of Cluster 3.0 (the command-line only version has the least
dependencies if you're looking to get up and running quickly on a Unix platform).
Once you've created a bunch of clusters of related cards, the clustering
plugin gives you the option of creating decks from whichever clusters look
promising.

You'll also need to obtain Pycluster (from the same page) which contains the
Python bindings for Cluster 3.0. Alternatively you can the Bio.Cluster version
of Pycluster.

You may also like to obtain a program for viewing the clustering output
although Sutekh doesn't currently support writing out the clusters. One
such viewer is TreeView (unfortunately Java-based) [2].

If you don't have any of these clustering packages, Sutekh will simply not
load the clustering plugin and run fine without it.

[1] http://bonsai.ims.u-tokyo.ac.jp/~mdehoon/software/cluster/software.htm
[2] http://jtreeview.sourceforge.net/

If you're wanting to modify the clustering plugin, you can find some usage
examples at:

[3] http://www.dalkescientific.com/writings/NBN/clustering.html
[4] http://b-src.cbrc.jp/markup/Pycluster-1.29/python/test/test_Cluster.py

=== Philosophy ===

Conceptually Sutekh is organised around two datatypes, AbstractCard
and PhysicalCard. AbstractCard models a conceptual card (e.g. ".44 Magnum")
while PhysicalCard stores information about an actual rectangular piece of
cardboard (e.g. My third copy of a .44 Magnum from the VTES expansion).

=== Other Notes ===

==== Sutekh and gtk themes ====

It is possible to customise the look and feel of Sutekh quite extensively
via gtk's theming mechanism. Sutekh uses "Sutekh" as the application name
for such purposes. All the dialogs use Sutekh.dialog.

Of specific note, the pane title's are named 'frame_title' when not selected
and 'selected_title' when the pane is selected. This allows customising
the look of panes when selected easily. For instance, by putting:

style "title_selected" {
   fg[NORMAL] = "red"
}

widget "Sutekh.*.selected_title" style "title_selected"

in your gtkrc file, the selected panes will use red text to mark selected panes.

The other specially named widgets are the card list widgets.

The various frames are named respectively:

"abstract card list", "physical card list", "physical card set card list",
"abstract card set card list", "card text", "abstract card sets list",
"physical card sets list"

The TreeView widgets used by the card lists (AbstractCard, PhysicalCard and card
sets) are named "normal_view", but, in editable mode, they are named
"editable_view".

User Documentation
==================

The user documentation is available under the sutekh/docs directory. The
Documentation is maintained as text files written using textile [1] Markup in
the sutekh/docs/textile directory, and using on pytextile [2] and the included
textile2html.py script to convert it to HTML for display in the gui.

[1] http://textile.thresholdstate.com/

[2] http://pypi.python.org/pypi/textile

Testing Sutekh
==============

Sutekh has a test suite - see the tests directory.

The test suite requires nose [1] to run.

By default, the tests will use an sqlite memory database, as being the
simplest, but, as it's often desirable to test against other databases,
the SUTEKH_TEST_DB environment variable can be used to provide an URI
to use instead. For example, to test against a postgres db:

$ export SUTEKH_TEST_DB="postres://username@host/test_database"
$ nosetests <test to run>

Note that the test suite creates and drops the tables several times, so it can
be quite slow. Also, DO NOT run the tests against your personal card database,
as you will lose data. Use a dedicated test database for this.

Setting SUTEKH_SAVE_DB to yes will preserve the database state at the end of
the last test run. This can be combined with the with-ids option for selecting
which test to run to save the state after a specific test.

[1] http://somethingaboutorange.com/mrl/projects/nose/

Importing/Exporting to/from other VTES card management programs
===============================================================

Sutekh can read the inventory and deck files produced by both the "Anrach
Revolt Deck Builder" (http://code.google.com/ardb) and the "Fragment of the
Elder Library Deck Builder" (http://csillagbolcselet.hu/feldb/). Files will
be imported as card sets into Sutekh. Because of differences between the
programs, some concepts won't be transferred.

Sutekh can also export card sets to these formats, but this will probably
not work for all versions of ARDB or FELDB.

