Change the filelist and dirlist type to be a hash of lists, delete postgres sql schema

dirlist is in the form:
{'Site': [ "/path/to/dir", "filter" ] }

Where filter will be the plugin to convert to stars/fpdb hand history file.

filelist is in the form:
{'file': [ "site", "filter" ] }
This commit is contained in:
Worros 2008-11-06 00:36:24 +13:00
parent 093302e76d
commit 92381254e8
3 changed files with 15 additions and 240 deletions

View File

@ -110,8 +110,8 @@ class GuiAutoImport (threading.Thread):
self.tiltpath=self.tiltDirPath.get_text() self.tiltpath=self.tiltDirPath.get_text()
# Add directory to importer object. # Add directory to importer object.
self.importer.addImportDirectory(self.starspath, True) self.importer.addImportDirectory(self.starspath, True, "PokerStars", "passthrough")
self.importer.addImportDirectory(self.tiltpath, True) self.importer.addImportDirectory(self.tiltpath, True, "FullTilt", "passthrough")
self.do_import() self.do_import()
interval=int(self.intervalEntry.get_text()) interval=int(self.intervalEntry.get_text())

View File

@ -47,8 +47,8 @@ class Importer:
self.caller=caller self.caller=caller
self.db = None self.db = None
self.cursor = None self.cursor = None
self.filelist = [] self.filelist = {}
self.dirlist = [] self.dirlist = {}
self.monitor = False self.monitor = False
self.updated = {} #Time last import was run {file:mtime} self.updated = {} #Time last import was run {file:mtime}
self.callHud = False self.callHud = False
@ -100,29 +100,25 @@ class Importer:
# self.updated = time() # self.updated = time()
def clearFileList(self): def clearFileList(self):
self.filelist = [] self.filelist = {}
#Add an individual file to filelist #Add an individual file to filelist
def addImportFile(self, filename): def addImportFile(self, filename, site = "default", filter = "passthrough"):
#TODO: test it is a valid file #TODO: test it is a valid file
self.filelist = self.filelist + [filename] self.filelist[filename] = [site] + [filter]
#Remove duplicates
self.filelist = list(set(self.filelist))
#Add a directory of files to filelist #Add a directory of files to filelist
def addImportDirectory(self,dir,monitor = False, filter = "passthrough"): #Only one import directory per site supported.
#dirlist is a hash of lists:
#dirlist{ 'PokerStars' => ["/path/to/import/", "filtername"] }
def addImportDirectory(self,dir,monitor = False, site = "default", filter = "passthrough"):
if os.path.isdir(dir): if os.path.isdir(dir):
if monitor == True: if monitor == True:
self.monitor = True self.monitor = True
self.dirlist = self.dirlist + [dir] self.dirlist[site] = [dir] + [filter]
for file in os.listdir(dir): for file in os.listdir(dir):
if os.path.isdir(file): self.addImportFile(os.path.join(dir, file), site, filter)
print "BulkImport is not recursive - please select the final directory in which the history files are"
else:
self.filelist = self.filelist + [os.path.join(dir, file)]
#Remove duplicates
self.filelist = list(set(self.filelist))
else: else:
print "Warning: Attempted to add: '" + str(dir) + "' as an import directory" print "Warning: Attempted to add: '" + str(dir) + "' as an import directory"
@ -136,11 +132,8 @@ class Importer:
#Check for new files in directory #Check for new files in directory
#todo: make efficient - always checks for new file, should be able to use mtime of directory #todo: make efficient - always checks for new file, should be able to use mtime of directory
# ^^ May not work on windows # ^^ May not work on windows
for dir in self.dirlist: for site in self.dirlist:
for file in os.listdir(dir): self.addImportDirectory(self.dirlist[site][0], False, site, self.dirlist[site][1])
self.filelist = self.filelist + [os.path.join(dir, file)]
self.filelist = list(set(self.filelist))
for file in self.filelist: for file in self.filelist:
stat_info = os.stat(file) stat_info = os.stat(file)

View File

@ -1,218 +0,0 @@
DROP TABLE IF EXISTS Settings CASCADE;
CREATE TABLE Settings (version SMALLINT);
DROP TABLE IF EXISTS Sites CASCADE;
CREATE TABLE Sites (
id SERIAL UNIQUE, PRIMARY KEY (id),
name varchar(32),
currency char(3));
DROP TABLE IF EXISTS Gametypes CASCADE;
CREATE TABLE Gametypes (
id SERIAL UNIQUE, PRIMARY KEY (id),
siteId INTEGER, FOREIGN KEY (siteId) REFERENCES Sites(id),
type char(4),
base char(4),
category varchar(9),
limitType char(2),
hiLo char(1),
smallBlind int,
bigBlind int,
smallBet int,
bigBet int);
DROP TABLE IF EXISTS Players CASCADE;
CREATE TABLE Players (
id SERIAL UNIQUE, PRIMARY KEY (id),
name VARCHAR(32),
siteId INTEGER, FOREIGN KEY (siteId) REFERENCES Sites(id),
comment text,
commentTs timestamp without time zone);
DROP TABLE IF EXISTS Autorates CASCADE;
CREATE TABLE Autorates (
id BIGSERIAL UNIQUE, PRIMARY KEY (id),
playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
description varchar(50),
shortDesc char(8),
ratingTime timestamp without time zone,
handCount int);
DROP TABLE IF EXISTS Hands CASCADE;
CREATE TABLE Hands (
id BIGSERIAL UNIQUE, PRIMARY KEY (id),
tableName VARCHAR(20),
siteHandNo BIGINT,
gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
handStart timestamp without time zone,
importTime timestamp without time zone,
seats SMALLINT,
maxSeats SMALLINT,
comment TEXT,
commentTs timestamp without time zone);
DROP TABLE IF EXISTS BoardCards CASCADE;
CREATE TABLE BoardCards (
id BIGSERIAL UNIQUE, PRIMARY KEY (id),
handId BIGINT, FOREIGN KEY (handId) REFERENCES Hands(id),
card1Value smallint,
card1Suit char(1),
card2Value smallint,
card2Suit char(1),
card3Value smallint,
card3Suit char(1),
card4Value smallint,
card4Suit char(1),
card5Value smallint,
card5Suit char(1));
DROP TABLE IF EXISTS TourneyTypes CASCADE;
CREATE TABLE TourneyTypes (
id SERIAL, PRIMARY KEY (id),
siteId INT, FOREIGN KEY (siteId) REFERENCES Sites(id),
buyin INT,
fee INT,
knockout INT,
rebuyOrAddon BOOLEAN);
DROP TABLE IF EXISTS Tourneys CASCADE;
CREATE TABLE Tourneys (
id SERIAL UNIQUE, PRIMARY KEY (id),
tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
siteTourneyNo BIGINT,
entries INT,
prizepool INT,
startTime timestamp without time zone,
comment TEXT,
commentTs timestamp without time zone);
DROP TABLE IF EXISTS TourneysPlayers CASCADE;
CREATE TABLE TourneysPlayers (
id BIGSERIAL UNIQUE, PRIMARY KEY (id),
tourneyId INT, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
payinAmount INT,
rank INT,
winnings INT,
comment TEXT,
commentTs timestamp without time zone);
DROP TABLE IF EXISTS HandsPlayers CASCADE;
CREATE TABLE HandsPlayers (
id BIGSERIAL UNIQUE, PRIMARY KEY (id),
handId BIGINT, FOREIGN KEY (handId) REFERENCES Hands(id),
playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
startCash INT,
position CHAR(1),
seatNo SMALLINT,
ante INT,
card1Value smallint,
card1Suit char(1),
card2Value smallint,
card2Suit char(1),
card3Value smallint,
card3Suit char(1),
card4Value smallint,
card4Suit char(1),
card5Value smallint,
card5Suit char(1),
card6Value smallint,
card6Suit char(1),
card7Value smallint,
card7Suit char(1),
winnings int,
rake int,
comment text,
commentTs timestamp without time zone,
tourneysPlayersId BIGINT, FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id));
DROP TABLE IF EXISTS HandsActions CASCADE;
CREATE TABLE HandsActions (
id BIGSERIAL UNIQUE, PRIMARY KEY (id),
handPlayerId BIGINT, FOREIGN KEY (handPlayerId) REFERENCES HandsPlayers(id),
street SMALLINT,
actionNo SMALLINT,
action CHAR(5),
allIn BOOLEAN,
amount INT,
comment TEXT,
commentTs timestamp without time zone);
DROP TABLE IF EXISTS HudCache CASCADE;
CREATE TABLE HudCache (
id BIGSERIAL UNIQUE, PRIMARY KEY (id),
gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
activeSeats SMALLINT,
position CHAR(1),
tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
HDs INT,
street0VPI INT,
street0Aggr INT,
street0_3B4BChance INT,
street0_3B4BDone INT,
street1Seen INT,
street2Seen INT,
street3Seen INT,
street4Seen INT,
sawShowdown INT,
street1Aggr INT,
street2Aggr INT,
street3Aggr INT,
street4Aggr INT,
otherRaisedStreet1 INT,
otherRaisedStreet2 INT,
otherRaisedStreet3 INT,
otherRaisedStreet4 INT,
foldToOtherRaisedStreet1 INT,
foldToOtherRaisedStreet2 INT,
foldToOtherRaisedStreet3 INT,
foldToOtherRaisedStreet4 INT,
wonWhenSeenStreet1 FLOAT,
wonAtSD FLOAT,
stealAttemptChance INT,
stealAttempted INT,
foldBbToStealChance INT,
foldedBbToSteal INT,
foldSbToStealChance INT,
foldedSbToSteal INT,
street1CBChance INT,
street1CBDone INT,
street2CBChance INT,
street2CBDone INT,
street3CBChance INT,
street3CBDone INT,
street4CBChance INT,
street4CBDone INT,
foldToStreet1CBChance INT,
foldToStreet1CBDone INT,
foldToStreet2CBChance INT,
foldToStreet2CBDone INT,
foldToStreet3CBChance INT,
foldToStreet3CBDone INT,
foldToStreet4CBChance INT,
foldToStreet4CBDone INT,
totalProfit INT,
street1CheckCallRaiseChance INT,
street1CheckCallRaiseDone INT,
street2CheckCallRaiseChance INT,
street2CheckCallRaiseDone INT,
street3CheckCallRaiseChance INT,
street3CheckCallRaiseDone INT,
street4CheckCallRaiseChance INT,
street4CheckCallRaiseDone INT);
INSERT INTO Settings VALUES (118);
INSERT INTO Sites ("name", currency) VALUES ('Full Tilt Poker', 'USD');
INSERT INTO Sites ("name", currency) VALUES ('PokerStars', 'USD');
INSERT INTO TourneyTypes (buyin, fee, knockout, rebuyOrAddon) VALUES (0, 0, 0, FALSE);