Skip to content

Commit

Permalink
Merge branch 'release/20190321'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMiras committed Mar 21, 2019
2 parents a3e7d5b + 6f819a8 commit d0300bf
Show file tree
Hide file tree
Showing 18 changed files with 515 additions and 162 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Change Log


## [20190321]

- Add readthedocs Sphinx documentation, refs #2
- Improves setup, refs #3
- Condigurable API key


## [20181031]

- Remove legacy pyetherapp & pyethereum dependencies
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pytest = {version="*"}
eth-account = "*"
eth-utils = "*"
pycryptodome = "*"
py-etherscan-api = {file = "https://github.com/corpetty/py-etherscan-api/archive/18ee101.zip"}
py-etherscan-api = {file = "https://github.com/corpetty/py-etherscan-api/archive/3c68b57.zip"}
requests-cache = "*"
rlp = "*"
"web3" = "*"
Expand Down
251 changes: 129 additions & 122 deletions Pipfile.lock

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# pyetheroll

[![Build Status](https://travis-ci.com/AndreMiras/pyetheroll.svg?branch=develop)](https://travis-ci.com/AndreMiras/pyetheroll)
[![PyPI version](https://badge.fury.io/py/pyetheroll.svg)](https://badge.fury.io/py/pyetheroll)
[![Documentation Status](https://readthedocs.org/projects/pyetheroll/badge/?version=latest)](https://pyetheroll.readthedocs.io/en/latest/?badge=latest)

Python library to Etheroll smart contract

Expand Down Expand Up @@ -31,12 +33,13 @@ contract_address = '0xe12c6dEb59f37011d2D9FdeC77A6f1A8f3B8B1e8'
etheroll = Etheroll(chain_id, contract_address)
```

Find out more in [docs/Examples.md](docs/Examples.md).

## Install

[Latest stable release](https://github.com/AndreMiras/pyetheroll/tree/master):
```sh
pip install --process-dependency-links \
https://github.com/AndreMiras/pyetheroll/archive/master.zip
pip install pyetheroll
```

[Development branch](https://github.com/AndreMiras/pyetheroll/tree/develop):
Expand Down
7 changes: 7 additions & 0 deletions docs/Examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Examples

Here is a list of common things the library can help with.

## Get address last rolls
Basically what you need is the `Etheroll.get_last_bets_transactions()` method.
See example [rolls2csv.py](rolls2csv.py) for a detailed example.
19 changes: 19 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
22 changes: 19 additions & 3 deletions docs/Release.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,38 @@ This is documenting the release process.

Make sure the CHANGELOG.md is up to date and follows the http://keepachangelog.com guidelines.
Start the release with git flow:
```
```sh
git flow release start YYYYMMDD
```
Now update the [CHANGELOG.md](/CHANGELOG.md) `[Unreleased]` section to match the new release version.
Also update the `version` string in the [setup.py](/setup.py) file. Then commit and finish release.
```
```sh
git commit -a -m "YYYYMMDD"
git flow release finish
```
Push everything, make sure tags are also pushed:
```
```sh
git push
git push origin master:master
git push --tags
```

## Publish to PyPI

Build it:
```sh
python3 setup.py sdist bdist_wheel
```
Check archive content:
```sh
tar -tvf dist/pyetheroll-*.tar.gz
```
Twine check and upload:
```sh
twine check dist/*
twine upload dist/*
```

## GitHub

Got to GitHub [Release/Tags](https://github.com/AndreMiras/pyetheroll/tags), click "Add release notes" for the tag just created.
Expand Down
178 changes: 178 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

project = 'pyetheroll'
copyright = '2019, Andre Miras'
author = 'Andre Miras'

# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = ''


# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'm2r',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
source_suffix = ['.rst', '.md']

# The master toctree document.
master_doc = 'index'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'pyetherolldoc'


# -- Options for LaTeX output ------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'pyetheroll.tex', 'pyetheroll Documentation',
'Andre Miras', 'manual'),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'pyetheroll', 'pyetheroll Documentation',
[author], 1)
]


# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'pyetheroll', 'pyetheroll Documentation',
author, 'pyetheroll', 'One line description of project.',
'Miscellaneous'),
]


# -- Options for Epub output -------------------------------------------------

# Bibliographic Dublin Core info.
epub_title = project

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']


# -- Extension configuration -------------------------------------------------
23 changes: 23 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.. pyetheroll documentation master file, created by
sphinx-quickstart on Wed Mar 13 14:24:10 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to pyetheroll's documentation!
======================================

.. toctree::
:maxdepth: 2
:caption: Contents:

readme.rst
Examples.md
Release.md


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
4 changes: 4 additions & 0 deletions docs/readme.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Readme
======

.. mdinclude:: ../README.md
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
m2r==0.2.1
sphinx_rtd_theme==0.4.3
62 changes: 62 additions & 0 deletions docs/rolls2csv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Dumps last rolls to a CSV file, example usage:
```
./roll2csv --address 0x706a62cae6c65472cce04a8d013156d071f8c998 --csv rolls.csv
```
Results example:
```
Transaction hash,Date time,Bet size,Roll under
0x5ccf0ee807ddbecfbfc8355478a7dfb0f562ac8f7d1a89e7699c3d9d17909120,4864-12-05 15:17:44,0.19,2
0x51ca16cb583e7a9200524c8b34e89bbc543bb11f890811721e1948fd77b7c555,4864-12-05 15:15:17,0.1,3
0xf932cd98955b3deb0fb96075c9f109455c3d763f75468655ddfe6d5d0fa951ba,4864-12-05 15:12:41,0.1,3
0x4c93791068933692bd1f85cf8cba0bb0d7fdd78f9d5a457752243e0ec358a747,4864-12-05 14:42:56,0.5,12
0x84809637b0f796bb53be439107557698bf7a09cfedb4286ff11f470340a24ee1,4864-12-05 14:41:58,0.5,3
0x88a2429790e10f81136df14da4b8d6595e6de7e6a94bb3f8d8e92d42965100a2,4864-12-05 14:39:16,0.5,3
0x30a914c957750c22e3005e5028531c2799175741c10d660733ef3b1a66bf9740,4864-12-05 14:21:52,0.5,3
0x3d1d8b57a4c95ea0dab95c274fc5ebd47f8b8abc59ea54800db69c4b44a83b6a,4864-12-05 14:21:13,2.0,7
0x3ca253933a9a51f7d4e6f7ec718f83bed1b213a60cc37188a897686f46efb38c,4864-12-05 14:17:28,2.0,11
```
"""
import argparse
import csv

from pyetheroll.etheroll import Etheroll


def parse_arg():
parser = argparse.ArgumentParser(description='Dumps player rolls to CSV')
parser.add_argument('--address', help='Player address', required=True)
parser.add_argument('--csv', help='CSV output file', required=True)
return parser.parse_args()


def get_last_bets_transactions(address):
etheroll = Etheroll()
return etheroll.get_last_bets_transactions(address)


def dump_rolls(rolls, filename):
with open(filename, mode='w') as roll_file:
csv_write = csv.writer(roll_file)
csv_write.writerow(
['Transaction hash', 'Date time', 'Bet size', 'Roll under'])
for roll in rolls:
csv_write.writerow([
roll['transaction_hash'],
roll['datetime'],
roll['bet_size_ether'],
roll['roll_under']])


def main():
args = parse_arg()
address = args.address
filename = args.csv
rolls = get_last_bets_transactions(address)
dump_rolls(rolls, filename)


if __name__ == '__main__':
main()

0 comments on commit d0300bf

Please sign in to comment.