Feature: An octokit is born

This commit is contained in:
Kyle Hornberg
2018-02-05 14:43:08 -06:00
commit 2239555697
33 changed files with 11615 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
[bumpversion]
current_version = 0.1.0
commit = True
tag = True
[bumpversion:file:setup.py]
search = version='{current_version}'
replace = version='{new_version}'
[bumpversion:file:README.rst]
search = v{current_version}.
replace = v{new_version}.
[bumpversion:file:docs/conf.py]
search = version = release = '{current_version}'
replace = version = release = '{new_version}'
[bumpversion:file:src/octokit.py/__init__.py]
search = __version__ = '{current_version}'
replace = __version__ = '{new_version}'
+53
View File
@@ -0,0 +1,53 @@
# This file exists so you can easily regenerate your project.
#
# `cookiepatcher` is a convenient shim around `cookiecutter`
# for regenerating projects (it will generate a .cookiecutterrc
# automatically for any template). To use it:
#
# pip install cookiepatcher
# cookiepatcher gh:ionelmc/cookiecutter-pylibrary project-path
#
# See:
# https://pypi.python.org/pypi/cookiepatcher
#
# Alternatively, you can run:
#
# cookiecutter --overwrite-if-exists --config-file=project-path/.cookiecutterrc gh:ionelmc/cookiecutter-pylibrary
default_context:
_template: 'gh:ionelmc/cookiecutter-pylibrary'
appveyor: 'no'
c_extension_function: 'longest'
c_extension_module: '_octokit.py'
c_extension_optional: 'no'
c_extension_support: 'no'
codacy: 'no'
codeclimate: 'yes'
codecov: 'yes'
command_line_interface: 'no'
command_line_interface_bin_name: 'octokitpy'
coveralls: 'no'
distribution_name: 'octokitpy'
email: 'kyle.hornberg@gmail.com'
full_name: 'Kyle Hornberg'
github_username: 'khornberg'
landscape: 'no'
license: 'MIT license'
linter: 'flake8'
package_name: 'octokit.py'
project_name: 'octokit.py'
project_short_description: 'Python client for GitHub API'
release_date: 'today'
repo_name: 'octokit.py'
requiresio: 'yes'
scrutinizer: 'no'
sphinx_doctest: 'no'
sphinx_theme: 'sphinx-rtd-theme'
test_matrix_configurator: 'no'
test_matrix_separate_coverage: 'no'
test_runner: 'pytest'
travis: 'yes'
version: '0.1.0'
website: 'https://khornberg.github.io'
year: 'now'
+16
View File
@@ -0,0 +1,16 @@
[paths]
source =
src/octokit
*/site-packages/octokit
[run]
branch = true
source =
octokit.py
tests
parallel = true
[report]
show_missing = true
precision = 2
omit = *migrations*
+13
View File
@@ -0,0 +1,13 @@
# see http://editorconfig.org
root = true
[*]
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
charset = utf-8
[*.{bat,cmd,ps1}]
end_of_line = crlf
+103
View File
@@ -0,0 +1,103 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# dotenv
.env
# virtualenv
.venv
venv/
ENV/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.pytest_cache/
+34
View File
@@ -0,0 +1,34 @@
language: python
sudo: false
cache: pip
env:
global:
- LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
- SEGFAULT_SIGNALS=all
matrix:
- TOXENV=check
- TOXENV=docs
matrix:
include:
- python: '3.6'
env:
- TOXENV=py36,report,codecov
before_install:
- python --version
- uname -a
- lsb_release -a
install:
- pip install tox
- virtualenv --version
- easy_install --version
- pip --version
- tox --version
script:
- tox -v
after_failure:
- more .tox/log/* | cat
- more .tox/*/log/* | cat
notifications:
email:
on_success: never
on_failure: always
+5
View File
@@ -0,0 +1,5 @@
Authors
=======
* Kyle Hornberg - https://khornberg.github.io
+8
View File
@@ -0,0 +1,8 @@
Changelog
=========
0.1.0 (?)
------------------
* First release on PyPI.
+88
View File
@@ -0,0 +1,88 @@
============
Contributing
============
Contributions are welcome, and they are greatly appreciated! Every
little bit helps.
Bug reports
===========
When `reporting a bug <https://github.com/khornberg/octokit.py/issues>`_ please include:
* Your operating system name and version.
* Any details about your local setup that might be helpful in troubleshooting.
* Detailed steps to reproduce the bug.
Documentation improvements
==========================
octokit.py could always use more documentation, whether as part of the
official octokit.py docs or even on the web in blog posts, articles, and such.
Feature requests and feedback
=============================
The best way to send feedback is to file an issue at https://github.com/khornberg/octokit.py/issues.
If you are proposing a feature:
* Explain in detail how it would work.
* Keep the scope as narrow as possible, to make it easier to implement.
* Remember that this is a volunteer-driven project, and that code contributions are welcome :)
Development
===========
To set up `octokit.py` for local development:
1. Fork `octokit.py <https://github.com/khornberg/octokit.py>`_
(look for the "Fork" button).
2. Clone your fork locally::
git clone git@github.com:your_name_here/octokit.py.git
3. Create a branch for local development::
git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
4. When you're done making changes, run all the checks, doc builder and spell checker with `tox <http://tox.readthedocs.io/en/latest/install.html>`_ one command::
tox
5. Commit your changes and push your branch to GitHub::
git add .
git commit -m "Your detailed description of your changes."
git push origin name-of-your-bugfix-or-feature
6. Submit a pull request through the GitHub website.
Pull Request Guidelines
-----------------------
If you need some code review or feedback while you're developing the code just make the pull request.
For merging, you should:
1. Include passing tests (run ``tox``) [1]_.
2. Update documentation when there's new API, functionality etc.
4. Add yourself to ``AUTHORS.rst``.
.. [1] If you don't have all the necessary python versions available locally you can rely on Travis - it will
`run the tests <https://travis-ci.org/khornberg/octokit.py/pull_requests>`_ for each change you add in the pull request.
It will be slower though ...
Tips
----
To run a subset of tests::
tox -e envname -- py.test -k test_myfeature
To run all the test environments in *parallel* (you need to ``pip install detox``)::
detox
+9
View File
@@ -0,0 +1,9 @@
MIT License
Copyright (c) 2018,
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+19
View File
@@ -0,0 +1,19 @@
graft docs
graft src
graft ci
graft tests
include .bumpversion.cfg
include .coveragerc
include .cookiecutterrc
include .editorconfig
include AUTHORS.rst
include CHANGELOG.rst
include CONTRIBUTING.rst
include LICENSE
include README.rst
include tox.ini .travis.yml appveyor.yml
global-exclude *.py[cod] __pycache__ *.so *.dylib
+158
View File
@@ -0,0 +1,158 @@
========
Overview
========
.. start-badges
.. list-table::
:stub-columns: 1
* - docs
- |docs|
* - tests
- | |travis| |requires|
| |codeclimate|
* - package
- | |version| |wheel| |supported-versions| |supported-implementations|
| |commits-since|
.. |docs| image:: https://readthedocs.org/projects/octokit.py/badge/?style=flat
:target: https://readthedocs.org/projects/octokitpy
:alt: Documentation Status
.. |travis| image:: https://travis-ci.org/khornberg/octokit.py.svg?branch=master
:alt: Travis-CI Build Status
:target: https://travis-ci.org/khornberg/octokit.py
.. |requires| image:: https://requires.io/github/khornberg/octokit.py/requirements.svg?branch=master
:alt: Requirements Status
:target: https://requires.io/github/khornberg/octokit.py/requirements/?branch=master
.. |codeclimate| image:: https://codeclimate.com/github/khornberg/octokit.py/badges/gpa.svg
:target: https://codeclimate.com/github/khornberg/octokit.py
:alt: CodeClimate Quality Status
.. |version| image:: https://img.shields.io/pypi/v/octokitpy.svg
:alt: PyPI Package latest release
:target: https://pypi.python.org/pypi/octokitpy
.. |commits-since| image:: https://img.shields.io/github/commits-since/khornberg/octokit.py/v0.1.0.svg
:alt: Commits since latest release
:target: https://github.com/khornberg/octokit.py/compare/v0.1.0...master
.. |wheel| image:: https://img.shields.io/pypi/wheel/octokitpy.svg
:alt: PyPI Wheel
:target: https://pypi.python.org/pypi/octokitpy
.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/octokitpy.svg
:alt: Supported versions
:target: https://pypi.python.org/pypi/octokitpy
.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/octokitpy.svg
:alt: Supported implementations
:target: https://pypi.python.org/pypi/octokitpy
.. end-badges
Python client for GitHub API
Installation
============
**requires python 3.6+**
Yes that is opinionated. Python 2 is near the end of the life and this is a new project.
*Note octokit and octokit.py were already taken in the cheese shop*
::
pip install octokitpy
Documentation
=============
https://octokitpy.readthedocs.io/
Example
-------
::
from octokit import Octokit
repos = Octokit.repos.get_for_org(org='octokit', type='public')
Default values
::
TODO Show them
Authentication
--------------
Instatiate a client with the authentication scheme and credentials that you want to use.
Example
::
client = Octokit(type='app', token='xyz')
client.repos.get_for_org(org='octokit', type='private')
TODO
[ ] basic
[ ] oauth
[ ] oauth key/secret
[ ] token
[ ] app
Pagination
----------
TODO
Development
===========
To run the all tests run::
tox
Note, to combine the coverage data from all the tox environments run:
.. list-table::
:widths: 10 90
:stub-columns: 1
- - Windows
- ::
set PYTEST_ADDOPTS=--cov-append
tox
- - Other
- ::
PYTEST_ADDOPTS=--cov-append tox
Contributing
============
Pull requests are very welcome!
Please see [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
Credits
=======
Package based on [cookiecutter-pylibrary](https://github.com/ionelmc/cookiecutter-pylibrary)
License
=======
.. _MIT: LICENSE
+39
View File
@@ -0,0 +1,39 @@
TODO
===
[paper](https://paper.dropbox.com/doc/Octokit-Program-2hnq6lO7f4Q1mGUlRXGIn)
[ ] REST
[ ] GraphQL
[ ] GitHub Apps
[ ] OAuth
[ ] Webhooks
## Generated client
This is setting up the client based on the available [data](https://github.com/octokit/node-github/blob/master/lib/routes.json)
## Native
[ ] PEP 8
## Documentation
Yes needed
## Tested
[ ] unit tests
[ ] integration tests? - need fixtures to assert against
## Errors
primative for now
## Best Practices
[ ] throttling
[ ] handles rate limiting
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
import os
import sys
from os.path import abspath
from os.path import dirname
from os.path import exists
from os.path import join
if __name__ == "__main__":
base_path = dirname(dirname(abspath(__file__)))
print("Project path: {0}".format(base_path))
env_path = join(base_path, ".tox", "bootstrap")
if sys.platform == "win32":
bin_path = join(env_path, "Scripts")
else:
bin_path = join(env_path, "bin")
if not exists(env_path):
import subprocess
print("Making bootstrap env in: {0} ...".format(env_path))
try:
subprocess.check_call(["virtualenv", env_path])
except subprocess.CalledProcessError:
subprocess.check_call([sys.executable, "-m", "virtualenv", env_path])
print("Installing `jinja2` into bootstrap environment...")
subprocess.check_call([join(bin_path, "pip"), "install", "jinja2"])
activate = join(bin_path, "activate_this.py")
# noinspection PyCompatibility
exec(compile(open(activate, "rb").read(), activate, "exec"), dict(__file__=activate))
import jinja2
import subprocess
jinja = jinja2.Environment(
loader=jinja2.FileSystemLoader(join(base_path, "ci", "templates")),
trim_blocks=True,
lstrip_blocks=True,
keep_trailing_newline=True
)
tox_environments = [
line.strip()
# WARNING: 'tox' must be installed globally or in the project's virtualenv
for line in subprocess.check_output(['tox', '--listenvs'], universal_newlines=True).splitlines()
]
tox_environments = [line for line in tox_environments if line not in ['clean', 'report', 'docs', 'check']]
for name in os.listdir(join("ci", "templates")):
with open(join(base_path, name), "w") as fh:
fh.write(jinja.get_template(name).render(tox_environments=tox_environments))
print("Wrote {}".format(name))
print("DONE.")
+36
View File
@@ -0,0 +1,36 @@
language: python
sudo: false
cache: pip
env:
global:
- LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
- SEGFAULT_SIGNALS=all
matrix:
- TOXENV=check
- TOXENV=docs
matrix:
include:
{%- for env in tox_environments %}{{ '' }}
- python: '{{ '{0[0]}-5.4'.format(env.split('-')) if env.startswith('pypy') else '{0[2]}.{0[3]}'.format(env) }}'
env:
- TOXENV={{ env }},report,codecov
{%- endfor %}{{ '' }}
before_install:
- python --version
- uname -a
- lsb_release -a
install:
- pip install tox
- virtualenv --version
- easy_install --version
- pip --version
- tox --version
script:
- tox -v
after_failure:
- more .tox/log/* | cat
- more .tox/*/log/* | cat
notifications:
email:
on_success: never
on_failure: always
+1
View File
@@ -0,0 +1 @@
.. include:: ../AUTHORS.rst
+1
View File
@@ -0,0 +1 @@
.. include:: ../CHANGELOG.rst
+53
View File
@@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.coverage',
'sphinx.ext.doctest',
'sphinx.ext.extlinks',
'sphinx.ext.ifconfig',
'sphinx.ext.napoleon',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
]
if os.getenv('SPELLCHECK'):
extensions += 'sphinxcontrib.spelling',
spelling_show_suggestions = True
spelling_lang = 'en_US'
source_suffix = '.rst'
master_doc = 'index'
project = 'octokit.py'
year = '2018'
author = 'Kyle Hornberg'
copyright = '{0}, {1}'.format(year, author)
version = release = '0.1.0'
pygments_style = 'trac'
templates_path = ['.']
extlinks = {
'issue': ('https://github.com/khornberg/octokit.py/issues/%s', '#'),
'pr': ('https://github.com/khornberg/octokit.py/pull/%s', 'PR #'),
}
# on_rtd is whether we are on readthedocs.org
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if not on_rtd: # only set the theme if we're building docs locally
html_theme = 'sphinx_rtd_theme'
html_use_smartypants = True
html_last_updated_fmt = '%b %d, %Y'
html_split_index = False
html_sidebars = {
'**': ['searchbox.html', 'globaltoc.html', 'sourcelink.html'],
}
html_short_title = '%s-%s' % (project, version)
napoleon_use_ivar = True
napoleon_use_rtype = False
napoleon_use_param = False
+1
View File
@@ -0,0 +1 @@
.. include:: ../CONTRIBUTING.rst
+22
View File
@@ -0,0 +1,22 @@
========
Contents
========
.. toctree::
:maxdepth: 2
readme
installation
usage
reference/index
contributing
authors
changelog
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
+7
View File
@@ -0,0 +1,7 @@
============
Installation
============
At the command line::
pip install octokitpy
+1
View File
@@ -0,0 +1 @@
.. include:: ../README.rst
+7
View File
@@ -0,0 +1,7 @@
Reference
=========
.. toctree::
:glob:
octokit.py*
+9
View File
@@ -0,0 +1,9 @@
octokit.py
==========
.. testsetup::
from octokit.py import *
.. automodule:: octokit.py
:members:
+3
View File
@@ -0,0 +1,3 @@
sphinx>=1.3
sphinx-rtd-theme
-e .
+11
View File
@@ -0,0 +1,11 @@
builtin
builtins
classmethod
staticmethod
classmethods
staticmethods
args
kwargs
callstack
Changelog
Indices
+7
View File
@@ -0,0 +1,7 @@
=====
Usage
=====
To use octokit.py in a project::
import octokit.py
+32
View File
@@ -0,0 +1,32 @@
[bdist_wheel]
universal = 1
[flake8]
max-complexity = 5
max-line-length = 120
exclude = */migrations/*
[tool:pytest]
testpaths = tests
norecursedirs =
migrations
python_files =
test_*.py
*_test.py
tests.py
addopts =
-ra
--strict
--doctest-modules
--doctest-glob=\*.rst
--tb=short
[isort]
force_single_line = True
line_length = 120
known_first_party = octokit.py
default_section = THIRDPARTY
forced_separate = test_octokit.py
not_skip = __init__.py
skip = migrations
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
from __future__ import absolute_import
from __future__ import print_function
import io
import re
from glob import glob
from os.path import basename
from os.path import dirname
from os.path import join
from os.path import splitext
from setuptools import find_packages
from setuptools import setup
def read(*names, **kwargs):
return io.open(
join(dirname(__file__), *names),
encoding=kwargs.get('encoding', 'utf8')
).read()
setup(
name='octokitpy',
version='0.1.0',
license='MIT license',
description='Python client for GitHub API',
long_description='%s\n%s' % (
re.compile('^.. start-badges.*^.. end-badges', re.M | re.S).sub('', read('README.rst')),
re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('CHANGELOG.rst'))
),
author='Kyle Hornberg',
author_email='kyle.hornberg@gmail.com',
url='https://github.com/khornberg/octokit.py',
packages=find_packages('src'),
package_dir={'': 'src'},
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
include_package_data=True,
zip_safe=False,
classifiers=[
# complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: Unix',
'Operating System :: POSIX',
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Utilities',
],
keywords=[
'github', 'octokit', 'api'
],
install_requires=[
# eg: 'aspectlib==1.1.1', 'six>=1.7',
],
extras_require={
# eg:
# 'rst': ['docutils>=0.11'],
# ':python_version=="2.6"': ['argparse'],
},
)
+1
View File
@@ -0,0 +1 @@
__version__ = '0.1.0'
+10630
View File
File diff suppressed because it is too large Load Diff
+7
View File
@@ -0,0 +1,7 @@
import octokit
class TestClass(object):
def test_1(self):
pass
+97
View File
@@ -0,0 +1,97 @@
; a generative tox configuration, see: https://testrun.org/tox/latest/config.html#generative-envlist
[tox]
envlist =
; clean,
; check,
{py36},
; report,
; docs
[testenv]
basepython =
py36: {env:TOXPYTHON:python3.6}
{bootstrap,clean,check,report,coveralls,codecov}: {env:TOXPYTHON:python3}
setenv =
PYTHONPATH={toxinidir}/tests
PYTHONUNBUFFERED=yes
passenv =
*
usedevelop = false
deps =
certifi==2018.1.18
chardet==3.0.4
ecdsa==0.13
future==0.16.0
idna==2.6
pycryptodome==3.4.9
python-jose==2.0.2
requests==2.18.4
six==1.11.0
urllib3==1.22
pytest
pytest-travis-fold
pytest-cov
commands =
{posargs:py.test --cov --cov-report=term-missing -vv tests}
[testenv:bootstrap]
deps =
jinja2
matrix
skip_install = true
commands =
python ci/bootstrap.py
[testenv:spell]
setenv =
SPELLCHECK=1
commands =
sphinx-build -b spelling docs dist/docs
skip_install = true
deps =
-r{toxinidir}/docs/requirements.txt
sphinxcontrib-spelling
pyenchant
[testenv:docs]
deps =
-r{toxinidir}/docs/requirements.txt
commands =
sphinx-build {posargs:-E} -b html docs dist/docs
sphinx-build -b linkcheck docs dist/docs
[testenv:check]
deps =
docutils
check-manifest
flake8
readme-renderer
pygments
isort
skip_install = true
commands =
python setup.py check --strict --metadata --restructuredtext
check-manifest {toxinidir}
flake8 src tests setup.py
isort --verbose --check-only --diff --recursive src tests setup.py
[testenv:coveralls]
deps =
coveralls
skip_install = true
commands =
coveralls []
[testenv:report]
deps = coverage
skip_install = true
commands =
coverage combine --append
coverage report
coverage html
[testenv:clean]
commands = coverage erase
skip_install = true
deps = coverage