Merge branch 'master' of git+ssh://git.yukkurigames.com/~/bare/mlpccg-meta
authorJess <jessicatz.fairymeadow@gmail.com>
Mon, 25 Aug 2014 22:09:02 +0000 (00:09 +0200)
committerJess <jessicatz.fairymeadow@gmail.com>
Mon, 25 Aug 2014 22:09:02 +0000 (00:09 +0200)
Conflicts:
main.py
mlpccg/CardDb.pyc
mlpccg/Clustering.py
mlpccg/Clustering.pyc
mlpccg/DeckList.pyc
static/index.html

.gitignore [new file with mode: 0644]
mlpccg/CardDb.pyc [deleted file]
mlpccg/Clustering.pyc [deleted file]
mlpccg/DeckList.pyc [deleted file]
mlpccg/Tournament.py [new file with mode: 0644]
mlpccg/__init__.pyc [deleted file]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..2f78cf5
--- /dev/null
@@ -0,0 +1,2 @@
+*.pyc
+
diff --git a/mlpccg/CardDb.pyc b/mlpccg/CardDb.pyc
deleted file mode 100644 (file)
index ec143fa..0000000
Binary files a/mlpccg/CardDb.pyc and /dev/null differ
diff --git a/mlpccg/Clustering.pyc b/mlpccg/Clustering.pyc
deleted file mode 100644 (file)
index 018b492..0000000
Binary files a/mlpccg/Clustering.pyc and /dev/null differ
diff --git a/mlpccg/DeckList.pyc b/mlpccg/DeckList.pyc
deleted file mode 100644 (file)
index 29d8135..0000000
Binary files a/mlpccg/DeckList.pyc and /dev/null differ
diff --git a/mlpccg/Tournament.py b/mlpccg/Tournament.py
new file mode 100644 (file)
index 0000000..94723eb
--- /dev/null
@@ -0,0 +1,29 @@
+import csv
+import sqlite3
+
+class Tournament:
+    def __init__(self):
+        #self.from_sqlite('data/db.sqlite3')
+        self.from_csv('data/tournaments.csv')
+
+    def from_sqlite(self, sqlite_path):
+        conn = sqlite3.connect(sqlite_path)
+        conn.row_factory = sqlite3.Row
+
+        c = conn.cursor()
+        for row in c.execute("SELECT strftime('%s', date) - 0 AS t, * FROM tournaments_record"):
+            self.records += [dict(zip(row.keys(), row))]
+        conn.close()
+
+    def from_csv(self, csv_path):
+        with open(csv_path) as f:
+            reader = csv.DictReader(f)
+            for row in reader:
+                pass #row['date']
+            self.records = [row for row in reader]
+
+    def add(self, record):
+        self.records += [record]
+
+    def all(self):
+        return self.records
diff --git a/mlpccg/__init__.pyc b/mlpccg/__init__.pyc
deleted file mode 100644 (file)
index 35dc891..0000000
Binary files a/mlpccg/__init__.pyc and /dev/null differ