Hello community, here is the log from the commit of package python-pysol-cards for openSUSE:Factory checked in at 2020-08-05 20:30:06 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pysol-cards (Old) and /work/SRC/openSUSE:Factory/.python-pysol-cards.new.3592 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pysol-cards" Wed Aug 5 20:30:06 2020 rev:2 rq:824527 version:0.10.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pysol-cards/python-pysol-cards.changes 2020-03-17 13:11:31.961862884 +0100 +++ /work/SRC/openSUSE:Factory/.python-pysol-cards.new.3592/python-pysol-cards.changes 2020-08-05 20:30:23.011129443 +0200 @@ -1,0 +2,9 @@ +Wed Aug 5 15:27:44 UTC 2020 - Marketa Calabkova <[email protected]> + +- Update to 0.10.1 + * allow accepting "ms[0-9]+" game nums + * add single\_deal\_args\_parse + * better PySol compat: fix reset() + * better PySol compat: str2int+int2str + +------------------------------------------------------------------- Old: ---- pysol_cards-0.8.8.tar.gz New: ---- pysol_cards-0.10.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pysol-cards.spec ++++++ --- /var/tmp/diff_new_pack.tNcxtL/_old 2020-08-05 20:30:25.715130854 +0200 +++ /var/tmp/diff_new_pack.tNcxtL/_new 2020-08-05 20:30:25.719130855 +0200 @@ -1,6 +1,7 @@ # -# spec file for package python-pysol-cards.spec +# spec file for package python-pysol-cards # +# Copyright (c) 2020 SUSE LLC # Copyright (c) 2020 Malcolm J Lewis <[email protected]> # # All modifications and additions to the file contributed by third parties @@ -15,22 +16,23 @@ # Please submit bugfixes or comments via https://bugs.opensuse.org/ # + %define skip_python2 1 %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-pysol-cards -Version: 0.8.8 +Version: 0.10.1 Release: 0 Summary: Python module for pysol-cards License: Apache-2.0 Group: Development/Languages/Python -Url: https://pypi.org/project/pysol-cards/ -Source: https://pypi.io/packages/source/p/pysol_cards/pysol_cards-%{version}.tar.gz +URL: https://pypi.org/project/pysol-cards/ +Source: https://files.pythonhosted.org/packages/source/p/pysol_cards/pysol_cards-%{version}.tar.gz BuildRequires: %{python_module oslotest} BuildRequires: %{python_module pbr >= 2.0} BuildRequires: %{python_module pytest} BuildRequires: %{python_module random2} -BuildRequires: %{python_module six} BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module six} BuildRequires: fdupes BuildRequires: python-rpm-macros ## MANUAL BEGIN ## ++++++ pysol_cards-0.8.8.tar.gz -> pysol_cards-0.10.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysol_cards-0.8.8/ChangeLog new/pysol_cards-0.10.1/ChangeLog --- old/pysol_cards-0.8.8/ChangeLog 2020-03-08 11:24:16.000000000 +0100 +++ new/pysol_cards-0.10.1/ChangeLog 2020-06-14 11:34:41.000000000 +0200 @@ -1,6 +1,74 @@ CHANGES ======= +0.10.1 +------ + +* bump version +* allow accepting "ms[0-9]+" game nums + +0.10.0 +------ + +* add single\_deal\_args\_parse + +0.8.18 +------ + +* bump version +* optimize +* add tests + +0.8.17 +------ + +* better PySol compat: fix reset() + +0.8.16 +------ + +* better PySol compat: str2int+int2str + +0.8.15 +------ + +* bump version +* better PySol compat: getstate +* Extract a method or a function + +0.8.14 +------ + +* add setstate + +0.8.13 +------ + +* bump version +* better PySol compat: getstate +* better PySol compat: increaseSeed + +0.8.12 +------ + +* bump version +* better PySol compat + +0.8.11 +------ + +* bump ver for real this time + +0.8.10 +------ + +* better PySol compat + +0.8.9 +----- + +* Python2 compatibility: add Game.next() (thanks to Travis-CI) + 0.8.8 ----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysol_cards-0.8.8/PKG-INFO new/pysol_cards-0.10.1/PKG-INFO --- old/pysol_cards-0.8.8/PKG-INFO 2020-03-08 11:24:17.312336200 +0100 +++ new/pysol_cards-0.10.1/PKG-INFO 2020-06-14 11:34:41.960426000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pysol_cards -Version: 0.8.8 +Version: 0.10.1 Summary: Deal PySol FC Cards Home-page: https://fc-solve.shlomifish.org/ Author: Shlomi Fish diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysol_cards-0.8.8/pysol_cards/__init__.py new/pysol_cards-0.10.1/pysol_cards/__init__.py --- old/pysol_cards-0.8.8/pysol_cards/__init__.py 2019-12-10 10:56:13.000000000 +0100 +++ new/pysol_cards-0.10.1/pysol_cards/__init__.py 2020-06-14 11:33:21.000000000 +0200 @@ -1 +1 @@ -VERSION = __version__ = (0, 8, 7) +VERSION = __version__ = (0, 10, 1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysol_cards-0.8.8/pysol_cards/deal_game.py new/pysol_cards-0.10.1/pysol_cards/deal_game.py --- old/pysol_cards-0.8.8/pysol_cards/deal_game.py 2020-03-08 11:15:20.000000000 +0100 +++ new/pysol_cards-0.10.1/pysol_cards/deal_game.py 2020-05-25 09:58:29.000000000 +0200 @@ -192,6 +192,9 @@ self.card_idx += 1 return c + def next(self): + return self.__next__() + def add(self, idx, card): self.board.add(idx, card) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysol_cards-0.8.8/pysol_cards/random.py new/pysol_cards-0.10.1/pysol_cards/random.py --- old/pysol_cards-0.8.8/pysol_cards/random.py 2019-12-10 10:56:13.000000000 +0100 +++ new/pysol_cards-0.10.1/pysol_cards/random.py 2020-05-27 08:42:56.000000000 +0200 @@ -34,15 +34,37 @@ # ************************************************************************/ -class LCRandom64(PysolRandom): +class _LCBase(PysolRandom): + def __init__(self, seed=None): + if seed is None: + seed = self._getRandomSeed() + PysolRandom.__init__(self, seed) + self.initial_seed = seed + self.setSeed(seed) + self.origin = self.ORIGIN_UNKNOWN + + def reset(self): + self.setSeed(self.initial_seed) + + def getSeedAsStr(self): + return self._getSeedStrPrefix() + str(self.seed) + + def getSeedStr(self): + return self._getSeedStrPrefix() + str(self.initial_seed) + + +class LCRandom64(_LCBase): MAX_SEED = 0xffffffffffffffff # 64 bits def random(self): self.seed = (self.seed * 6364136223846793005 + 1) & self.MAX_SEED return ((self.seed >> 21) & 0x7fffffff) / 2147483648.0 + def _getSeedStrPrefix(self): + return "old" + -class LCRandom31(RandomBase): +class LCRandom31(_LCBase): MAX_SEED = ((1 << (31 + 2)) - 1) # 33 bits def setSeed(self, seed): @@ -50,6 +72,7 @@ raise ValueError("seed is out of range") self.seed = seed self.seedx = seed if (seed < 0x100000000) else (seed - 0x100000000) + return self.seed def random(self): if (self.seed < 0x100000000): @@ -69,6 +92,19 @@ def randint(self, a, b): return a + self.random() % (b + 1 - a) + def _getSeedStrPrefix(self): + return "ms" + + def increaseSeed(self, seed): + """docstring for increaseSeed""" + integer_seed = super(LCRandom31, self).increaseSeed(seed) + return "ms{}".format(integer_seed) + + def str(self, seed): + if match_ms_deal_prefix(seed) is None: + return "%05d" % int(seed) + return seed + # * Mersenne Twister random number generator class MTRandom(RandomBase, random2.Random): @@ -86,9 +122,10 @@ def setSeed(self, seed): random2.Random.__init__(self, seed) self.initial_state = self.getstate() + return seed def reset(self): - self.setstate(self.initial_state) + self.setSeed(self.initial_seed) def shuffle(cards, game_num, which_deals): @@ -105,3 +142,26 @@ def match_ms_deal_prefix(mystring): ret = re.match(_ms_pat, mystring) return None if not ret else int(ret.group(1)) + + +MS_LONG_BIT = (1 << 1000) +CUSTOM_BIT = (1 << 999) + + +def random__str2int(s): + if s == 'Custom': + return CUSTOM_BIT | MS_LONG_BIT + m = match_ms_deal_prefix(s) + if m is not None: + return (m | MS_LONG_BIT) + else: + return int(s) + + +def random__int2str(l): + if ((l & MS_LONG_BIT) != 0): + if ((l & CUSTOM_BIT) != 0): + return 'Custom' + return "ms" + str(l & (~ MS_LONG_BIT)) + else: + return str(l) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysol_cards-0.8.8/pysol_cards/random_base.py new/pysol_cards-0.10.1/pysol_cards/random_base.py --- old/pysol_cards-0.8.8/pysol_cards/random_base.py 2019-08-08 17:27:54.000000000 +0200 +++ new/pysol_cards-0.10.1/pysol_cards/random_base.py 2020-05-25 12:38:07.000000000 +0200 @@ -21,7 +21,7 @@ ORIGIN_SELECTED = 3 ORIGIN_NEXT_GAME = 4 - def __init__(self): + def __init__(self, seed=None): """docstring for __init__""" self.seed_as_string = None @@ -35,6 +35,14 @@ """ Get a random integer in the range [a, b] including both ends.""" return a + int(self.random() * (b + 1 - a)) + def randrange(self, a, b): + """ Get a random integer in the range [a, b) excluding b.""" + return self.randint(a, b - 1) + + def choice(self, sequence): + """ Pick a random element of sequence """ + return sequence[self.randrange(0, len(sequence))] + def setSeedAsStr(self, new_s): self.seed_as_string = new_s @@ -69,3 +77,11 @@ import time ret = int(time.time() * 256.0) return ((ret ^ (ret >> 24)) % (self.MAX_SEED + 1)) + + def getstate(self): + """getstate() for PySolFC""" + return self.seed + + def setstate(self, new_state): + """set to a new state""" + self.seed = new_state diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysol_cards-0.8.8/pysol_cards/single_deal_args_parse.py new/pysol_cards-0.10.1/pysol_cards/single_deal_args_parse.py --- old/pysol_cards-0.8.8/pysol_cards/single_deal_args_parse.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pysol_cards-0.10.1/pysol_cards/single_deal_args_parse.py 2020-06-14 11:29:42.000000000 +0200 @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# vim:fenc=utf-8 +# +# Copyright © 2020 Shlomi Fish <[email protected]> +# +# Distributed under terms of the MIT license. + +""" + +""" + +from pysol_cards.random import RandomBase +from pysol_cards.random import match_ms_deal_prefix + + +class SingleDealArgsParser(object): + def __init__(self, args): + self.print_ts = False + self.which_deals = RandomBase.DEALS_PYSOL + self.max_rank = 13 + while args[1][0] == '-': + a = args[1] + args.pop(1) + if a == "-t": + self.print_ts = True + elif (a == "--max-rank"): + self.max_rank = int(args.pop(1)) + elif (a == "--pysolfc") or (a == "-F"): + self.which_deals = RandomBase.DEALS_PYSOLFC + elif (a == "--ms") or (a == "-M"): + self.which_deals = RandomBase.DEALS_MS + else: + raise ValueError("Unknown flag " + a + "!") + + game_num_s = args[1] + msgame = match_ms_deal_prefix(game_num_s) + if msgame is not None: + if self.which_deals == RandomBase.DEALS_MS or \ + self.which_deals == RandomBase.DEALS_PYSOL: + self.which_deals = RandomBase.DEALS_MS + self.game_num = msgame + else: + raise ValueError("ms deals mismatch") + else: + self.game_num = int(game_num_s) + self.which_game = args[2] if len(args) >= 3 else "freecell" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysol_cards-0.8.8/pysol_cards/tests/test_pysol_cards.py new/pysol_cards-0.10.1/pysol_cards/tests/test_pysol_cards.py --- old/pysol_cards-0.8.8/pysol_cards/tests/test_pysol_cards.py 2020-03-08 11:17:10.000000000 +0100 +++ new/pysol_cards-0.10.1/pysol_cards/tests/test_pysol_cards.py 2020-06-14 11:30:47.000000000 +0200 @@ -14,6 +14,8 @@ Tests for `pysol_cards` module. """ +import pysol_cards.random + from pysol_cards.tests import base @@ -26,8 +28,6 @@ import pysol_cards.deal_game # noqa: F401 def test_import_random(self): - import pysol_cards.random - class Foo(pysol_cards.random.LCRandom31): def bar(self): return super(pysol_cards.random.LCRandom31, self).shuffle([0]) @@ -35,6 +35,32 @@ r.setSeed(5) self.assertEqual(r.bar(), [0], "super()") + def test_inc_seed(self): + r = pysol_cards.random.LCRandom31(200000) + seed = r.increaseSeed(200000) + self.assertEqual(seed, 'ms200001', "increaseSeed()") + + def test_mtrandom_reset(self): + r = pysol_cards.random.MTRandom(10000000) + bef0 = r.randint(0, 100) + bef1 = r.randint(0, 100) + r.reset() + aft0 = r.randint(0, 100) + aft1 = r.randint(0, 100) + self.assertEqual([aft0, aft1], [bef0, bef1], "MTRandom.reset()") + + def test_choice(self): + r = pysol_cards.random.LCRandom64(500) + result = r.choice([500, 600, 700]) + self.assertTrue((result in (500, 600, 700)), "choice") + + def test_ms_single_deal(self): + from pysol_cards.single_deal_args_parse import SingleDealArgsParser + from pysol_cards.random import RandomBase + obj = SingleDealArgsParser(["dealer.py", "ms2000000", ]) + self.assertEqual(obj.which_deals, RandomBase.DEALS_MS) + self.assertEqual(obj.game_num, 2000000) + def test_ms_seed_prefix(self): from pysol_cards.random import match_ms_deal_prefix self.assertEqual(match_ms_deal_prefix('123'), None, "no prefix") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysol_cards-0.8.8/pysol_cards.egg-info/PKG-INFO new/pysol_cards-0.10.1/pysol_cards.egg-info/PKG-INFO --- old/pysol_cards-0.8.8/pysol_cards.egg-info/PKG-INFO 2020-03-08 11:24:16.000000000 +0100 +++ new/pysol_cards-0.10.1/pysol_cards.egg-info/PKG-INFO 2020-06-14 11:34:41.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pysol-cards -Version: 0.8.8 +Version: 0.10.1 Summary: Deal PySol FC Cards Home-page: https://fc-solve.shlomifish.org/ Author: Shlomi Fish diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysol_cards-0.8.8/pysol_cards.egg-info/SOURCES.txt new/pysol_cards-0.10.1/pysol_cards.egg-info/SOURCES.txt --- old/pysol_cards-0.8.8/pysol_cards.egg-info/SOURCES.txt 2020-03-08 11:24:17.000000000 +0100 +++ new/pysol_cards-0.10.1/pysol_cards.egg-info/SOURCES.txt 2020-06-14 11:34:41.000000000 +0200 @@ -41,6 +41,7 @@ pysol_cards/errors.py pysol_cards/random.py pysol_cards/random_base.py +pysol_cards/single_deal_args_parse.py pysol_cards.egg-info/PKG-INFO pysol_cards.egg-info/SOURCES.txt pysol_cards.egg-info/dependency_links.txt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pysol_cards-0.8.8/pysol_cards.egg-info/pbr.json new/pysol_cards-0.10.1/pysol_cards.egg-info/pbr.json --- old/pysol_cards-0.8.8/pysol_cards.egg-info/pbr.json 2020-03-08 11:24:16.000000000 +0100 +++ new/pysol_cards-0.10.1/pysol_cards.egg-info/pbr.json 2020-06-14 11:34:41.000000000 +0200 @@ -1 +1 @@ -{"git_version": "613adef", "is_release": false} \ No newline at end of file +{"git_version": "eca7276", "is_release": false} \ No newline at end of file
