summaryrefslogtreecommitdiff
path: root/qml/python
diff options
context:
space:
mode:
Diffstat (limited to 'qml/python')
-rw-r--r--qml/python/board.py7
-rw-r--r--qml/python/configuration.py25
2 files changed, 30 insertions, 2 deletions
diff --git a/qml/python/board.py b/qml/python/board.py
index 5bc0ac5..19f720a 100644
--- a/qml/python/board.py
+++ b/qml/python/board.py
@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import os
+import os.path
try:
import pyotherside
except:
@@ -22,7 +23,10 @@ def setPath(qtPath):
def loadBoard(filename):
global cursor
- sgfPath = os.path.join(path,"../content","sgf",filename);
+ if os.path.isfile(filename):
+ sgfPath = filename
+ else:
+ sgfPath = os.path.join(path,"../content","sgf",filename);
pyotherside.send('log', sgfPath)
try:
f = open(sgfPath)
@@ -48,7 +52,6 @@ def getGame(n):
game = Game(cursor)
game.normalize()
- pyotherside.send('log', "Game loaded !!")
return {
"tree": game.tree,
diff --git a/qml/python/configuration.py b/qml/python/configuration.py
new file mode 100644
index 0000000..e2cd826
--- /dev/null
+++ b/qml/python/configuration.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import os
+import os.path
+
+try:
+ import pyotherside
+except:
+ print("no pyotherside module loaded")
+
+def get_level_desc(path):
+ return {"name": os.path.basename(path),
+ "path": path,
+ }
+
+def get_levels(qtPath, documents):
+
+ pyotherside.send('log', documents)
+
+ level_path = os.path.join(qtPath, "../content", "sgf")
+ provided_levels = [get_level_desc(os.path.join(level_path, f)) for f in os.listdir(level_path)]
+
+ return provided_levels
+