def _loadPayouts(self, dirs, config_file_name): config = Config(dirs) config.load(config_file_name) self.payouts = [] for node in config.header.xpathEval("/payouts/payout"): properties = config.headerNodeProperties(node) self.payouts.append(( int(properties['max']), map(lambda percent: float(percent) / 100, node.content.split())))
def _loadPayouts(self, dirs, config_file_name): config = Config(dirs) config.load(config_file_name) self.payouts = [] for node in config.header.xpathEval("/payouts/payout"): properties = config.headerNodeProperties(node) self.payouts.append((int(properties['max']), [float(percent)/100 for percent in node.content.split()]))
def _loadPayouts(self, dirs, config_file_name): config = Config(dirs) config.load(config_file_name) self.payouts = [] for node in config.doc.xpath("/payouts/payout"): maxPlayers = node.get("max") self.payouts.append( (int(maxPlayers), [float(percent) / 100 for percent in node.text.split()]))
def translateFile2Name(self, file): if not self.file2name.has_key(file): config = Config(self.dirs) config.load("poker.%s.xml" % file) name = config.headerGet("/bet/description") if not name: name = config.headerGet("/poker/variant/@name") if not name: self.error("*CRITICAL* can't find readable name for %s" % file) name = file self.file2name[file] = name return self.file2name[file]
def translateFile2Name(self, file): if file not in self.file2name: config = Config(self.dirs) config.load("poker.%s.xml" % file) name = config.headerGet("/bet/description") if not name: name = config.headerGet("/poker/variant/@name") if not name: self.log.crit("can't find readable name for '%s'", file) name = file self.file2name[file] = name return self.file2name[file]
def test1(self): shutil.rmtree("conftest", ignore_errors = True) os.mkdir("conftest") os.system("%(cmd)s --upgrades=%(upgrades)s --reference=%(configs)s conftest" % { 'cmd': path.join(TESTS_PATH, '../pokerconfigupgrade'), 'upgrades': path.join(TESTS_PATH, '../upgrades'), 'configs': path.join(TESTS_PATH, '../conf') }) os.chmod("conftest", 0755) os.system("%(cmd)s --upgrades=%(upgrades)s conftest" % { 'cmd': path.join(TESTS_PATH, '../pokerconfigupgrade'), 'upgrades': path.join(TESTS_PATH, '../upgrades') }) config = Config(['conftest']) for file in os.listdir("conftest"): if ".xml" in file: config.load(file) self.assertEqual(config.headerGet("/child::*/@poker_engine_version"), version) shutil.rmtree("conftest")
# # You should have received a copy of the GNU Affero General Public License # along with this program in a file in the toplevel directory called # "AGPLv3". If not, see <http://www.gnu.org/licenses/>. # # Authors: # Loic Dachary <*****@*****.**> # # Build a khotkeys (KDE) file from the key binding # specifications of poker2d.xml.in # from pokerengine.pokerengineconfig import Config poker2d_title = "Poker" settings = Config(['.']) import os srcdir = os.environ['srcdir'] if srcdir == None or srcdir == "": srcdir = "." settings.load(srcdir + '/' + 'poker2d.xml.in') keys = settings.headerGetProperties('/settings/keys/key') print """ [Data] DataCount=1 [Data_1] Comment=poker2d desktop wide key bindings forwarded to the poker2d window key bindings http://freshmeat.net/projects/poker-network/ DataCount=""" + str(len(keys)) + """ Enabled=false