diff --git a/pyfpdb/CarbonToFpdb.py b/pyfpdb/CarbonToFpdb.py
new file mode 100644
index 00000000..0dc7dfaf
--- /dev/null
+++ b/pyfpdb/CarbonToFpdb.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+# Copyright 2008, Carl Gherardi
+
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+########################################################################
+
+# Standard Library modules
+import Configuration
+import traceback
+import xml.dom.minidom
+from xml.dom.minidom import Node
+from HandHistoryConverter import HandHistoryConverter
+
+# Carbon format looks like:
+
+# 1)
+# 2)
+# 3)
+#
+# ...
+# 4)
+#
+#
+# 5)
+#
+# 6)
+#
+# ....
+#
+
+# The full sequence for a NHLE cash game is:
+# BLINDS, PREFLOP, POSTFLOP, POSTTURN, POSTRIVER, SHOWDOWN, END_OF_GAME
+# This sequence can be terminated after BLINDS at any time by END_OF_FOLDED_GAME
+
+
+class CarbonPoker(HandHistoryConverter):
+ def __init__(self, config, filename):
+ print "Initialising Carbon Poker converter class"
+ HandHistoryConverter.__init__(self, config, filename) # Call super class init
+ self.sitename = "Carbon"
+ self.setFileType("xml")
+
+ def readSupportedGames(self):
+ pass
+ def determineGameType(self):
+ desc_node = doc.getElementsByTagName("description")
+ type = desc_node.getAttribute("type")
+ stakes = desc_node.getAttribute("stakes")
+
+ def readPlayerStacks(self):
+ pass
+ def readBlinds(self):
+ pass
+ def readAction(self):
+ pass
+
+
+if __name__ == "__main__":
+ c = Configuration.Config()
+ e = CarbonPoker(c, "regression-test-files/carbon-poker/Niagara Falls (15245216).xml")
+ print str(e)
diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py
index 9f6b760b..515f28d7 100644
--- a/pyfpdb/EverleafToFpdb.py
+++ b/pyfpdb/EverleafToFpdb.py
@@ -16,11 +16,16 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
########################################################################
+import Configuration
from HandHistoryConverter import HandHistoryConverter
class Everleaf(HandHistoryConverter):
- def __init__(self):
+ def __init__(self, config, file):
print "Initialising Everleaf converter class"
+ HandHistoryConverter.__init__(self, config, file) # Call super class init.
+ self.sitename = "Everleaf"
+ self.setFileType("text")
+
def readSupportedGames(self):
pass
@@ -37,4 +42,7 @@ class Everleaf(HandHistoryConverter):
pass
if __name__ == "__main__":
- e = Everleaf()
+ c = Configuration.Config()
+ e = Everleaf(c, "regression-test-files/everleaf/Speed_Kuala.txt")
+ print str(e)
+
diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py
index 9a62776c..731b2bb5 100644
--- a/pyfpdb/HandHistoryConverter.py
+++ b/pyfpdb/HandHistoryConverter.py
@@ -16,8 +16,22 @@
#agpl-3.0.txt in the docs folder of the package.
class HandHistoryConverter:
- def __init__(self):
- pass
+ def __init__(self, config, file):
+ print "HandHistory init called"
+ self.c = config
+ self.sitename = ""
+ self.obs = "" # One big string
+ self.filetype = "text"
+ self.doc = None # For XML based HH files
+ self.file = file
+ self.hhbase = self.c.get_import_parameters().get("hhArchiveBase")
+
+ def __str__(self):
+ tmp = "HandHistoryConverter: '%s'\n" % (self.sitename)
+ tmp = tmp + "\thhbase: %s\n" % (self.hhbase)
+ tmp = tmp + "\tfiletype: %s\n" % (self.filetype)
+ return tmp
+
# Functions to be implemented in the inheriting class
def readSupportedGames(self): abstract
def determineGameType(self): abstract
@@ -25,11 +39,47 @@ class HandHistoryConverter:
def readBlinds(self): abstract
def readAction(self): abstract
+
# Functions not necessary to implement in sub class
+ def setFileType(self, filetype = "text"):
+ self.filetype = filetype
+
+ def processFile(self):
+ self.readFile()
+
def readFile(self, filename):
"""Read file"""
+ if(self.filetype == "text"):
+ infile=open(filename, "rU")
+ self.obs = readfile(inputFile)
+ inputFile.close()
+ elif(self.filetype == "xml"):
+ try:
+ doc = xml.dom.minidom.parse(filename)
+ self.doc = doc
+ except:
+ traceback.print_exc(file=sys.stderr)
def writeStars(self):
"""Write out parsed data"""
-
+# print sitename + " Game #" + handid + ": " + gametype + " (" + sb + "/" + bb + " - " + starttime
+# print "Table '" + tablename + "' " + maxseats + "-max Seat #" + buttonpos + " is the button"
+#
+# counter = 1
+# for player in seating:
+# print "Seat " + counter + ": " + playername + "($" + playermoney + " in chips"
+#
+# print playername + ": posts small blind " + sb
+# print playername + ": posts big blind " + bb
+#
+# print "*** HOLE CARDS ***"
+# print "Dealt to " + hero + " [" + holecards + "]"
+#
+## ACTION STUFF
+#
+# print "*** SUMMARY ***"
+# print "Total pot $" + totalpot + " | Rake $" + rake
+# print "Board [" + boardcards + "]"
+#
+## SUMMARY STUFF