/usr/share/gnubg/scripts/batch_win.py is in gnubg-data 1.04.000-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #
# batch_win.py -- batch import and analysis of multiple files using gnubg
#
# by Oystein Johansen <oystein@gnubg.org>, 2004
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
#
# $Id: batch_win.py,v 1.4 2013/08/21 03:45:23 mdpetch Exp $
# This file is inspired of the batch.py file of Jon Kinsey. The code
# contains MS-Windows specific code and will therefore only work on MS-Windows
# together with GNU Backgammon and Python.
import win32ui
import win32con
# file extensions, names and gnubg import commands
extensions = ['mat', 'pos', 'sgg', 'tmg', 'txt']
extTypes = ['.mat', '.pos', 'Games grid', 'True money game', 'Snowie text']
extCmds = ['mat', 'pos', 'sgg', 'tmg', 'snowietxt']
def BatchAnalyze(filelist):
for file in filelist:
dot = file.rfind('.')
if dot != -1:
ext = file[dot + 1:].lower()
if ext in extensions:
AnalyzeFile(file, extensions.index(ext))
def GetFiles():
import win32ui
import win32con
filedialog = win32ui.CreateFileDialog(
1, "", "", win32con.OFN_ALLOWMULTISELECT | win32con.OFN_HIDEREADONLY)
filedialog.SetOFNTitle("Select files to analyse")
filedialog.DoModal()
return filedialog.GetPathNames()
def AnalyzeFile(file, type):
"Run commands to analyze file in gnubg"
gnubg.command('import ' + extCmds[type] + ' "' + file + '"')
gnubg.command('analyze match')
file = file[:-len(extensions[type])] + "sgf"
gnubg.command('save match "' + file + '"')
files = GetFiles()
BatchAnalyze(files)
|