justcheckers/tasks.py

62 lines
1.5 KiB
Python
Raw Normal View History

import os
from os import path
import shutil
from invoke import task, run
@task
2017-04-19 08:41:32 -04:00
def run_game(ctx):
run('python main.py')
@task
def clean(ctx):
"""Clean generated files."""
run('rm *.pyc')
@task
2017-04-19 08:41:32 -04:00
def docs(ctx):
"""Creates the HTML documentation through Sphinx."""
build_dirs = ['docs/_api', 'docs/_build']
for build_dir in build_dirs:
if not path.exists(build_dir):
os.mkdir(build_dir)
run('sphinx-apidoc -o docs/_api rookeries')
run('sphinx-build -b html docs docs/_build')
@task
2017-04-19 08:41:32 -04:00
def clean_docs(ctx):
"""Clean up the generated Sphinx documentation."""
sphinx_api_docs_dir = os.path.join(os.curdir, 'docs', '_api')
if os.path.exists(sphinx_api_docs_dir):
shutil.rmtree(sphinx_api_docs_dir)
sphinx_build_docs_dir = os.path.join(os.curdir, 'docs', '_build')
if os.path.exists(sphinx_build_docs_dir):
shutil.rmtree(sphinx_build_docs_dir)
@task
2017-04-19 08:41:32 -04:00
def test_style(ctx):
"""Test the coding style using Flake8."""
run('flake8')
@task
2017-04-19 08:41:32 -04:00
def build_package(ctx):
"""Prepares the project for packaging."""
run('python setup.py sdist')
@task
2017-04-19 08:41:32 -04:00
def clean_package(ctx):
"""Cleans up generated files after packaging the project."""
packaging_dirs = [os.path.join(os.curdir, packaging) for packaging in ['justcheckers.egg-info', 'dist']]
for packaging in packaging_dirs:
if os.path.exists(packaging):
print("Removing '{}'".format(packaging))
shutil.rmtree(packaging)