db: mysqldb: Fix the UnboundLocalError

The code out of try/except peer will not be treated as part of the
block. Thus the return here didn't work with the function but ran
as a single command. 'res' was not a global variable, so the
reture would cause a UnboundLocalError.

Signed-off-by: GuofengLiu <lgf612@sina.com>
data: add arguments for two methods

Add 'field' argument for both lowestByDate() and highestByDate()
 to extend usability.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
db:mysqldb: introduce two new methods.

1) ifTableExist() returns if a table does exist.
2) createTableTemplate() creates a table using templates.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
dataMgr: introduce data manager subsystem.

Add two importers.
1) importer.py contains 'Import' class which is proposed to be the
   super class for all child Importers.
2) Introduce whImporter to support WenHua format data records.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
test: add test for dataMgr/importers.

Add test because introduced new dataMgr subsystem.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
dataMgr:importer: adjust arguments for partReimportTo()

Adjust argument 'tTo' for partReimportTo to use 'None' as default.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
dataMgr:whImporter: rename wenhuaNewImport()

Rename wenhuaNewImport() as newImport(), so to keep consistency
with Import super class.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
strategy:turtle: add turtle framework

Turtle framework provides a set of basic methods, e.g, tr, atr and
attributes which might be used by child strategies. This framework
aims to save time and code to rewrite a modified turtle strategy
(child strategy), so any child strategy also should inherit this
class and redefine some keys methods to drive this framework to run.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
dataMgr:importer/whImporter: reorganize the code structure

1) Remove 'dataFile' and 'dataTable' arguments from __init__(s) and
   change to specify them in class methods instead to extend reusibility.
2) Remove useless setAttrs() because of 1).
3) Change 'partReimportTo()' to 'partReimport()'.
4) Add getRecordField() to return a specified field from a record.
5) Add importFromDir() method to import data records from a directory.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
dataMgr:whImporter: add processRawRecords method

1) Add processRawRecords() which processes raw records before
   calling importFromDir().
2) Correct and remove commentary.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
strategy:turtle: enhance checkings for profit and positions

1) Change self.profit to statistic the current business's profit
   and use self.totalProfit to statistic the whole test.
2) Replace all 'len(self.pList)' with current position to benefit
   reading and sustaining.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
test:test_data: fix test run error.

An error was caused because there was no necessary field required
by Data.highestByDate(), add it.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
strategy:turtle: update atr and some commentaries

1) Remove 'table' argument from atr(). We just want one Turtle object
   to handle only one table in order to keep independent in logics.
2) Update some commentaries.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>