Browse Source

Rename to 'xdice'

olinox 8 years ago
parent
commit
1af1b03105
11 changed files with 61 additions and 172 deletions
  1. 6 6
      README.md
  2. BIN
      dist/pydice-1.0.0.tar.gz
  3. 1 1
      nose2.cfg
  4. 0 99
      pydice.egg-info/PKG-INFO
  5. 0 9
      pydice.egg-info/SOURCES.txt
  6. 0 1
      pydice.egg-info/dependency_links.txt
  7. 0 2
      pydice.egg-info/top_level.txt
  8. 6 6
      roll.py
  9. 5 5
      setup.py
  10. 42 42
      test.py
  11. 1 1
      xdice.py

+ 6 - 6
README.md

@@ -1,6 +1,6 @@
-**pydice**
+**xdice**
 
-*pydice* is a lightweight python library for managing dice, scores, and dice-notation patterns.
+*xdice* is a lightweight python library for managing dice, scores, and dice-notation patterns.
 
 It allows to easily interpret literal expressions as rolls of dice ('1d6', '3d4+3', '12d6+1d4'...etc.), then manipulate the results.
 
@@ -10,7 +10,7 @@ DiceRollParser has been tested with python 3.3+
 
 ### Documentation
 
-See the **[full documentation](https://pydice.readthedocs.io/en/latest/)**
+See the **[full documentation](https://xdice.readthedocs.io/en/latest/)**
 
 #### Examples:  
 
@@ -52,7 +52,7 @@ Run `python roll.py [options] <expr>`
 	    -s               Numeric score only
 	
 	    -h --help        Displays help message
-	    --version        Displays current pydice version
+	    --version        Displays current xdice version
 
 
 #### CONTRIBUTION
@@ -61,11 +61,11 @@ Any opinion / contribution is welcome, please contact us.
 
 #### TO INSTALL
 
-	pip install pydice
+	pip install xdice
 
 #### License
 
-*pydice* is under GNU License
+*xdice* is under GNU License
 
 #### Author
 

BIN
dist/pydice-1.0.0.tar.gz


+ 1 - 1
nose2.cfg

@@ -3,5 +3,5 @@ with-coverage = True
 
 [coverage]
 always-on = True
-coverage = dice
+coverage = xdice
 coverage-report = html

+ 0 - 99
pydice.egg-info/PKG-INFO

@@ -1,99 +0,0 @@
-Metadata-Version: 1.2
-Name: pydice
-Version: 1.0.0
-Summary: Lightweight python library for managing dice, scores, and dice-notation patterns.
-Home-page: https://github.com/cro-ki/pydice
-Author: Olivier Massot
-Author-email: croki.contact@gmail.com
-License: GNU
-Description: **pydice**
-        
-        *pydice* is a lightweight python library for managing dice, scores, and dice-notation patterns.
-        
-        It allows to easily interpret literal expressions as rolls of dice ('1d6', '3d4+3', '12d6+1d4'...etc.), then manipulate the results.
-        
-        #### Python Versions
-        
-        DiceRollParser has been tested with python 3.3+
-        
-        ### Documentation
-        
-        See the **[full documentation](https://pydice.readthedocs.io/en/latest/)**
-        
-        #### Examples:  
-        
-        	import dice
-        
-        	## Roll simple dices with **rolldice()**
-        	
-        	score = rolldice(6, amount=2)
-        	
-        	# manipulates score as an integer
-        	
-        	print( score, score * 2, score == 11 )
-        	>> 11		22		True
-        	
-        	
-        	# Iterates over the results
-        	
-        	for result in score:
-        		print(result)
-        	>> 5
-        	>> 6
-        
-        	# Parse patterns with **roll()**
-        	
-        	ps = roll("2d6+18")
-        	
-        	print( ps, ps.format() )
-        	>> 28		'[5,6]+18'
-        
-        
-        #### CLI
-        
-        Run `python roll.py [options] <expr>`
-        	
-        	Usage:
-        	    roll [options] <expr>
-        	
-        	Options:
-        	    -s               Numeric score only
-        	
-        	    -h --help        Displays help message
-        	    --version        Displays current pydice version
-        
-        
-        #### CONTRIBUTION
-        
-        Any opinion / contribution is welcome, please contact us.
-        
-        #### TO INSTALL
-        
-        	pip install pydice
-        
-        #### License
-        
-        *pydice* is under GNU License
-        
-        #### Author
-        
-        Olivier Massot, 2017, with *Cro-ki Lab*
-        
-        #### Tags
-        
-        	dice roll d20 game random parser dices role board
-Keywords: dice roll d20 game random parser dices role board
-Platform: UNKNOWN
-Classifier: Development Status :: 5 - Production/Stable
-Classifier: Intended Audience :: Developers
-Classifier: Intended Audience :: Other Audience
-Classifier: Topic :: Games/Entertainment :: Board Games
-Classifier: Topic :: Games/Entertainment :: Role-Playing
-Classifier: Topic :: Games/Entertainment :: Multi-User Dungeons (MUD)
-Classifier: Topic :: Games/Entertainment :: Turn Based Strategy
-Classifier: License :: OSI Approved :: GNU General Public License (GPL)
-Classifier: Programming Language :: Python :: 3.3
-Classifier: Programming Language :: Python :: 3.4
-Classifier: Programming Language :: Python :: 3.5
-Classifier: Programming Language :: Python :: 3.6
-Requires-Python: >=3.3

+ 0 - 9
pydice.egg-info/SOURCES.txt

@@ -1,9 +0,0 @@
-MANIFEST.in
-README.md
-dice.py
-roll.py
-setup.py
-pydice.egg-info/PKG-INFO
-pydice.egg-info/SOURCES.txt
-pydice.egg-info/dependency_links.txt
-pydice.egg-info/top_level.txt

+ 0 - 1
pydice.egg-info/dependency_links.txt

@@ -1 +0,0 @@
-

+ 0 - 2
pydice.egg-info/top_level.txt

@@ -1,2 +0,0 @@
-dice
-roll

+ 6 - 6
roll.py

@@ -6,11 +6,11 @@ Options:
     -s               Numeric score only
 
     -h --help        Displays help message
-    --version        Displays current pydice version
+    --version        Displays current xdice version
 """
 import sys
 
-import dice
+import xdice
 
 def print_ex(string, exit_code=0):
     """ print and exit """
@@ -24,7 +24,7 @@ if "-h" in args:
     print_ex(__doc__)
 
 if "-v" in args:
-    print_ex("pydice {}".format(dice.__VERSION__))
+    print_ex("xdice {}".format(xdice.__VERSION__))
 
 score_only = False
 if "-s" in args:
@@ -32,12 +32,12 @@ if "-s" in args:
     args.remove("-s")
 
 if len(args) != 1:
-    print_ex("pydice CLI: invalid arguments\n" + __doc__, 1)
+    print_ex("xdice CLI: invalid arguments\n" + __doc__, 1)
 
 pattern_string = args[0]
 
-# Run pydice
-ps = dice.roll(pattern_string)
+# Run xdice
+ps = xdice.roll(pattern_string)
 
 if score_only:
     print(ps)

+ 5 - 5
setup.py

@@ -12,21 +12,21 @@ with open(path.join(here, 'README.md'), encoding='utf-8') as f:
     long_description = f.read()
 
 setup(
-    name='pydice',
+    name='xdice',
 
     version='1.0.0',
 
-    description='Lightweight python library for managing dice, scores, and dice-notation patterns.',
+    description='Lightweight python library for managing xdice, scores, and xdice-notation patterns.',
     long_description=long_description,
 
-    url='https://github.com/cro-ki/pydice',
+    url='https://github.com/cro-ki/xdice',
 
     author='Olivier Massot',
     author_email='croki.contact@gmail.com',
 
     license='GNU',
 
-    py_modules=['dice', 'roll'],
+    py_modules=['xdice', 'roll'],
     python_requires='>=3.3',
 
     include_package_data=True,
@@ -49,6 +49,6 @@ setup(
         'Programming Language :: Python :: 3.6',
     ],
 
-    keywords='dice roll d20 game random parser dices role board',
+    keywords='xdice roll d20 game random parser dices role board',
 
 )

+ 42 - 42
test.py

@@ -5,7 +5,7 @@ Created on 18 nov. 2016
 '''
 import unittest
 
-import dice
+import xdice
 
 
 class Test(unittest.TestCase):
@@ -13,46 +13,46 @@ class Test(unittest.TestCase):
 
     def test_secured_eval(self):
         # refused
-        self.assertRaises(TypeError, dice._secured_eval, "open('foo', 'r')")
+        self.assertRaises(TypeError, xdice._secured_eval, "open('foo', 'r')")
         # accepted
-        dice._secured_eval("1 + max([1,2,3])")
-        dice._secured_eval("1 + min([1,2,3])")
+        xdice._secured_eval("1 + max([1,2,3])")
+        xdice._secured_eval("1 + min([1,2,3])")
 
     def test_patterns_validation(self):
         """check the with behaviour with valid / invalid patterns"""
         # check valid expressions
-        dice.roll("3")
-        dice.roll("0d6")
-        dice.roll("1d6")
-        dice.roll("1d66")
-        dice.roll("1d4+2")
-        dice.roll("1d4-2")
-        dice.roll("1d4 - 2 ")
-        dice.roll("6d102+123")
-        dice.roll("6d102+123+8d6")
-        dice.roll("6d102+123+8d6+2+1+1-8-6d4+8-2d101+100d2")
-        dice.roll("32+3-0-2")
-        dice.roll("1d1-3")
-        dice.roll("1000d1000")
-        dice.roll("10 d 10")
-        dice.roll("10*1d10/2")
-        dice.roll("1d20**2")
-        dice.roll("abs(1d6-1d10)")
-        dice.roll("max(1d6,2d4)")
-        dice.roll("min(1d6,2d4)")
+        xdice.roll("3")
+        xdice.roll("0d6")
+        xdice.roll("1d6")
+        xdice.roll("1d66")
+        xdice.roll("1d4+2")
+        xdice.roll("1d4-2")
+        xdice.roll("1d4 - 2 ")
+        xdice.roll("6d102+123")
+        xdice.roll("6d102+123+8d6")
+        xdice.roll("6d102+123+8d6+2+1+1-8-6d4+8-2d101+100d2")
+        xdice.roll("32+3-0-2")
+        xdice.roll("1d1-3")
+        xdice.roll("1000d1000")
+        xdice.roll("10 d 10")
+        xdice.roll("10*1d10/2")
+        xdice.roll("1d20**2")
+        xdice.roll("abs(1d6-1d10)")
+        xdice.roll("max(1d6,2d4)")
+        xdice.roll("min(1d6,2d4)")
 
         # test invalid expressions
-        self.assertRaises(SyntaxError, dice.roll, "1d-8")
-        self.assertRaises(SyntaxError, dice.roll, "1d")
-        self.assertRaises(ValueError, dice.roll, "")
-        self.assertRaises(ValueError, dice.roll, "1d0")
-        self.assertRaises(TypeError, dice.roll, "d6")
-        self.assertRaises(TypeError, dice.roll, "abc")
-        self.assertRaises(TypeError, dice.roll, "1d2,3")
+        self.assertRaises(SyntaxError, xdice.roll, "1d-8")
+        self.assertRaises(SyntaxError, xdice.roll, "1d")
+        self.assertRaises(ValueError, xdice.roll, "")
+        self.assertRaises(ValueError, xdice.roll, "1d0")
+        self.assertRaises(TypeError, xdice.roll, "d6")
+        self.assertRaises(TypeError, xdice.roll, "abc")
+        self.assertRaises(TypeError, xdice.roll, "1d2,3")
 
     def test_dice_object(self):
 
-        d = dice.Dice(6, 6)
+        d = xdice.Dice(6, 6)
         self.assertEqual(d.sides, 6)
         self.assertEqual(d.amount, 6)
         self.assertEqual(d.__repr__(), "<Dice; sides=6; amount=6>")
@@ -64,13 +64,13 @@ class Test(unittest.TestCase):
         self.assertRaises(ValueError, setattr, d, "amount", "a")
         self.assertRaises(ValueError, setattr, d, "amount", None)
 
-        self.assertEqual(dice.Dice(1, 6).roll(), 6)
+        self.assertEqual(xdice.Dice(1, 6).roll(), 6)
 
-        self.assertEqual(dice.Dice.parse("6d1").roll(), 6)
+        self.assertEqual(xdice.Dice.parse("6d1").roll(), 6)
 
     def test_score_object(self):
 
-        s = dice.Score([1, 2, 3])
+        s = xdice.Score([1, 2, 3])
 
         self.assertEqual(s, 6)
         self.assertEqual(str(s), "6")
@@ -82,18 +82,18 @@ class Test(unittest.TestCase):
 
     def test_pattern_object(self):
 
-        p = dice.Pattern("6d1+6")
+        p = xdice.Pattern("6d1+6")
 
         self.assertEqual(p._normalize("1 D 6"), "1d6")
 
         p.compile()
         self.assertEqual(p.format_string, "{0}+6")
-        self.assertEqual(p.dices, [dice.Dice(1, 6)])
+        self.assertEqual(p.dices, [xdice.Dice(1, 6)])
 
         self.assertEqual(p.roll(), 12)
 
     def test_patternscore_objet(self):
-        ps = dice.PatternScore("{0}+6", [dice.Score([1, 1, 1, 1, 1, 1])])
+        ps = xdice.PatternScore("{0}+6", [xdice.Score([1, 1, 1, 1, 1, 1])])
 
         self.assertEqual(ps, 12)
         self.assertEqual(ps.score(0), 6)
@@ -101,21 +101,21 @@ class Test(unittest.TestCase):
         self.assertEqual(ps.format(), "[1, 1, 1, 1, 1, 1]+6")
 
     def test_compile(self):
-        p1 = dice.compile("6d1+6")
-        p2 = dice.Pattern("6d1+6")
+        p1 = xdice.compile("6d1+6")
+        p2 = xdice.Pattern("6d1+6")
         p2.compile()
 
         self.assertEqual(p1.format_string, p2.format_string)
         self.assertEqual(p1.dices, p2.dices)
 
     def test_roll(self):
-        ps1 = dice.roll("6d1+6")
-        ps2 = dice.PatternScore("{0}+6", [dice.Score([1, 1, 1, 1, 1, 1])])
+        ps1 = xdice.roll("6d1+6")
+        ps2 = xdice.PatternScore("{0}+6", [xdice.Score([1, 1, 1, 1, 1, 1])])
 
         self.assertEqual(ps1, ps2)
 
     def test_rolldice(self):
-        self.assertEqual(dice.rolldice(1, 6), dice.Dice(1, 6).roll())
+        self.assertEqual(xdice.rolldice(1, 6), xdice.Dice(1, 6).roll())
 
 if __name__ == "__main__":
     unittest.main()

+ 1 - 1
dice.py → xdice.py

@@ -1,5 +1,5 @@
 '''
-    pydice is a lightweight python 3.3+ library for managing rolls of dice.
+    xdice is a lightweight python 3.3+ library for managing rolls of dice.
 
     License: GNU