Skip to content

Commit 46b0148

Browse files
committed
Prepared backbone of the project
0 parents  commit 46b0148

23 files changed

Lines changed: 1430 additions & 0 deletions

.coveragerc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[report]
2+
omit =
3+
*/python?.?/*
4+
*/site-packages/nose/*
5+
*__init__*

.gitignore

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*.pyc
5+
*.pyo
6+
7+
# C extensions
8+
*.so
9+
10+
# Distribution / packaging
11+
.Python
12+
env/
13+
build/
14+
develop-eggs/
15+
dist/
16+
downloads/
17+
eggs/
18+
.eggs/
19+
lib/
20+
lib64/
21+
parts/
22+
sdist/
23+
var/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.coverage
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
47+
# Translations
48+
*.mo
49+
*.pot
50+
51+
# Logs:
52+
*.log
53+
*.log.*
54+
55+
# Sphinx documentation
56+
docs/_build/
57+
docs/build/
58+
59+
# PyBuilder
60+
target/
61+
62+
# Eclipse
63+
.project
64+
.settings/
65+
*.pydevproject
66+
67+
# Idea PyCharm
68+
.idea/
69+
.idea_modules/
70+
out/

.travis.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Travis CI Configuration file
2+
# @link https://travis-ci.org/
3+
4+
# Using Python for the project
5+
language: python
6+
python:
7+
# Python 2.6 is obsolete
8+
#- "2.6"
9+
# Python 2.7 is set to test the docs in the configuration matrix
10+
#- "2.7"
11+
# Python 3.2 is obsolete
12+
#- "3.2"
13+
- "3.3"
14+
- "3.4"
15+
# Python 3.5 is set to test and deploy the docs, and to run the coverage report, in the configuration matrix
16+
#- "3.5"
17+
- "pypy"
18+
- "pypy3"
19+
matrix:
20+
include:
21+
# Tests docs
22+
- python: "2.7"
23+
env: TEST_DOCS=true
24+
# Tests and deploys docs, also runs coverage report
25+
- python: "3.5"
26+
env: COVERAGE=true TEST_DOCS=true DEPLOY_DOCS=true
27+
28+
before_install:
29+
# Gets scripts
30+
- git clone -b v0.2.0 --single-branch https://github.com/Bernardo-MG/ci-shell-scripts.git ~/.scripts
31+
# Sets scripts as executable
32+
- chmod -R +x ~/.scripts/*
33+
# Prepares CI environment
34+
- source ~/.scripts/travis/load-travis-environment.sh
35+
- source ~/.scripts/travis/load-travis-environment-python.sh
36+
install:
37+
# tox is required for the tests
38+
- pip install tox
39+
script:
40+
# Tests are run
41+
- ~/.scripts/python/run_tests.sh true $PYTHON_VERSION_TEST
42+
# Documentation tests are run
43+
- ~/.scripts/python/run_tests.sh $DO_TEST_DOCS docs
44+
# Documentation tests are run
45+
- ~/.scripts/python/run_tests.sh $DO_COVERAGE coverage
46+
after_success:
47+
# Documentation deployment
48+
- ~/.scripts/rtd/deploy.sh $DO_DEPLOY_DOCS dice-notation

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Bernardo Martínez Garrido
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MANIFEST.in

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Miscellany files
2+
include LICENSE
3+
include README.rst
4+
include Makefile
5+
include make.bat
6+
include tox.ini
7+
include requirements.txt
8+
include .coveragerc
9+
10+
# Tests
11+
recursive-exclude tests *.pyc
12+
recursive-exclude tests *.pyo
13+
14+
# Documentation
15+
recursive-include docs *
16+
recursive-exclude docs *.pyc
17+
recursive-exclude docs *.pyo
18+
prune docs/_build

Makefile

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Makefile for the Python project
2+
#
3+
# It supports creating distribution files, and deploying them to Pypi and Pypitest or installing them locally
4+
#
5+
# A Python interpreter is required, and it should be accessible from the command line.
6+
7+
# Sets the variables.
8+
9+
# Sets the Python executable.
10+
# It will be the executable for the interpreter set up for the command line.
11+
PYTHON = python
12+
13+
# Sets the distribution folder.
14+
# It will be the 'dist' folder.
15+
DISTDIR = dist
16+
17+
# Sets the .egg file path.
18+
# The file will be located at the project's root.
19+
EGGDIR = dice-notation.egg-info
20+
21+
# Sets the tox folder path.
22+
# It will be the '.tox' folder.
23+
TOXDIR = .tox
24+
25+
# Sets the docs output folder path.
26+
# It will be in the 'docs' folder.
27+
DOCBUILDDIR = docs\\build
28+
29+
# User-friendly check for sphinx-build
30+
ifeq ($(shell which $(PYTHON) >/dev/null 2>&1; echo $$?), 1)
31+
$(error The '$(PYTHON)' command was not found. Make sure you have a version of the python interpreter installed, then add the directory where it was installed to the PATH.)
32+
endif
33+
34+
.PHONY: help clean
35+
36+
# Help option
37+
# Shows the allowed commands to be received as parameters
38+
help:
39+
@echo "Please use 'make <target>' where <target> is one of"
40+
@echo " clean to remove the distribution folders"
41+
@echo " build to build the distribution"
42+
@echo " install to install the project"
43+
@echo " requirements to install the project requirements"
44+
@echo " register to register on pypi"
45+
@echo " register-test to register on testpypi"
46+
@echo " deploy to upload to pypi"
47+
@echo " deploy-test to upload to testpypi"
48+
@echo " test to run tests"
49+
50+
# Clean option
51+
# Removes the distribution folder and the .egg file
52+
clean:
53+
rm -r -f $(DISTDIR)
54+
rm -r -f $(EGGDIR)
55+
rm -r -f $(TOXDIR)
56+
rm -r -f $(DOCBUILDDIR)
57+
58+
# Distribution.
59+
build:
60+
$(PYTHON) setup.py sdist
61+
62+
# Install in local libraries repository
63+
install:
64+
$(PYTHON) setup.py install
65+
66+
# Install the project requirements
67+
requirements:
68+
pip install --upgrade -r requirements.txt
69+
70+
# Pypi registration.
71+
register:
72+
$(PYTHON) setup.py register -r pypi
73+
74+
# Pypitest registration.
75+
register-test:
76+
$(PYTHON) setup.py register -r testpypi
77+
78+
# Pypi deployment.
79+
deploy:
80+
$(PYTHON) setup.py sdist
81+
twine upload dist/*
82+
83+
# Pypitest deployment.
84+
deploy-test:
85+
$(PYTHON) setup.py sdist upload -r testpypi
86+
87+
# Tests suite.
88+
test:
89+
tox

README.rst

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
==============================
2+
Dice Notation Tools for Python
3+
==============================
4+
5+
This notation is widely used on tabletop games, such as wargames or RPGs, and
6+
was created on the late 70s for Dungeons & Dragons, as a way to allow generating
7+
random values in specific distributions.
8+
9+
With the pass of years it has evolved, and while it never underwent a formal
10+
standarization process a core set of rules is kept among all the variations,
11+
mostly representing dice in a format such as '1d6', and the use of algebra
12+
operations like addition and subtraction.
13+
14+
This project aims to give support to the dice notation, allowing parsing and
15+
operating with it on any Python application.
16+
17+
.. image:: https://badge.fury.io/py/dice-notation.svg
18+
:target: https://pypi.python.org/pypi/dice-notation
19+
:alt: Dice Notation Tools for Python Pypi package page
20+
21+
.. image:: https://readthedocs.org/projects/dice-notation/badge/?version=latest
22+
:target: http://dice-notation.readthedocs.org/en/latest/
23+
:alt: Dice Notation Tools for Python latest documentation Status
24+
.. image:: https://readthedocs.org/projects/dice-notation/badge/?version=develop
25+
:target: http://dice-notation.readthedocs.org/en/develop/
26+
:alt: Dice Notation Tools for Python development documentation Status
27+
28+
Features
29+
--------
30+
31+
The library contains the following features:
32+
33+
- API for dice and dice notation, along classes to generate values from them
34+
- Parser to create API instances from the notation
35+
36+
Documentation
37+
-------------
38+
39+
Documentation sources are included with the project, and used to generate the
40+
documentation sites:
41+
42+
- The `latest docs`_ are always generated for the latest release, kept in the 'master' branch
43+
- The `development docs`_ are generated from the latest code in the 'develop' branch
44+
45+
You can also create the documentation from the source files, kept in the 'docs'
46+
folder, with the help of Sphinx. For this use the makefile, or the make.bat
47+
file, contained on that folder.
48+
49+
Prerequisites
50+
~~~~~~~~~~~~~
51+
52+
The project has been tested in the following versions of the interpreter:
53+
54+
- Python 2.7
55+
- Python 3.3
56+
- Python 3.4
57+
- Python 3.5
58+
- Pypy
59+
- Pypy 3
60+
61+
All other dependencies are indicated on the requirements.txt file.
62+
The included makefile can install them with the command:
63+
64+
``$ make requirements``
65+
66+
Installing
67+
~~~~~~~~~~
68+
69+
The project is offered as a `Pypi package`_, and using pip is the preferred way
70+
to install it. For this use the following command;
71+
72+
``$ pip install dice-notation``
73+
74+
If manual installation is required, the project includes a setup.py file, along
75+
a makefile allowing direct installation of the library, which can be done with
76+
the following command:
77+
78+
``$ make install``
79+
80+
Usage
81+
-----
82+
83+
The application has been coded in Python, without using any particular
84+
framework.
85+
86+
Collaborate
87+
-----------
88+
89+
Any kind of help with the project will be well received, and there are two main ways to give such help:
90+
91+
- Reporting errors and asking for extensions through the issues management
92+
- or forking the repository and extending the project
93+
94+
Issues management
95+
~~~~~~~~~~~~~~~~~
96+
97+
Issues are managed at the GitHub `project issues tracker`_, where any Github
98+
user may report bugs or ask for new features.
99+
100+
Getting the code
101+
~~~~~~~~~~~~~~~~
102+
103+
If you wish to fork or modify the code, visit the `GitHub project page`_, where
104+
the latest versions are always kept. Check the 'master' branch for the latest
105+
release, and the 'develop' for the current, and stable, development version.
106+
107+
License
108+
-------
109+
110+
The project has been released under the `MIT License`_.
111+
112+
.. _GitHub project page: https://github.com/Bernardo-MG/dice-notation
113+
.. _latest docs: http://dice-notation.readthedocs.org/en/latest/
114+
.. _development docs: http://dice-notation.readthedocs.org/en/develop/
115+
.. _Pypi package: https://pypi.python.org/pypi/dice-notation
116+
.. _MIT License: http://www.opensource.org/licenses/mit-license.php
117+
.. _project issues tracker: https://github.com/Bernardo-MG/dice-notation/issues
118+
.. _Sphinx: http://sphinx-doc.org/

dice-notation/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Dice Notation Tools for Python
4+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5+
Dice notation tools
6+
:copyright: (c) 2016 by Bernardo Martínez Garrido
7+
:license: MIT, see LICENSE for more details.
8+
"""
9+
10+
__version__ = '0.1.0'
11+
__license__ = 'MIT'

dice-notation/__main__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# -*- coding: utf-8 -*-
2+
3+
if __name__ == "__main__":
4+
print('Hello world!')

0 commit comments

Comments
 (0)