diff options
| author | Raghuram Subramani <raghus2247@gmail.com> | 2022-06-19 19:47:51 +0530 |
|---|---|---|
| committer | Raghuram Subramani <raghus2247@gmail.com> | 2022-06-19 19:47:51 +0530 |
| commit | 4fd287655a72b9aea14cdac715ad5b90ed082ed2 (patch) | |
| tree | 65d393bc0e699dd12d05b29ba568e04cea666207 /circuitpython/tools/huffman/tasks.py | |
| parent | 0150f70ce9c39e9e6dd878766c0620c85e47bed0 (diff) | |
add circuitpython code
Diffstat (limited to 'circuitpython/tools/huffman/tasks.py')
| -rw-r--r-- | circuitpython/tools/huffman/tasks.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/circuitpython/tools/huffman/tasks.py b/circuitpython/tools/huffman/tasks.py new file mode 100644 index 0000000..6c3cf71 --- /dev/null +++ b/circuitpython/tools/huffman/tasks.py @@ -0,0 +1,69 @@ +from __future__ import print_function + +import os +import errno +import shutil +from six.moves import urllib + +from invoke import task + +ROOT = os.path.abspath(os.path.dirname(__file__)) + + +def fileurl(path): + path = os.path.abspath(path) + return urllib.parse.urljoin('file:', urllib.request.pathname2url(path)) + + +@task +def clean(ctx): + rm_targets = ['build', 'dist', 'huffman.egg-info'] + + for t in rm_targets: + try: + print('removing {}...'.format(t), end=' ') + shutil.rmtree(os.path.join(ROOT, t)) + print('OK.') + except OSError as e: + if e.errno != errno.ENOENT: + raise + print('already gone.') + + +@task +def build(ctx): + ctx.run('python setup.py sdist bdist_wheel') + + +@task +def install(ctx): + if int(os.environ.get('INSTALL_WHEEL', 0)): + print('installing bdist_wheel...') + ctx.run('pip install dist/huffman-*.whl') + else: + print('installing sdist...') + ctx.run('pip install dist/huffman-*.tar.gz') + + +@task +def test(ctx, coverage=False): + cmd = 'nosetests tests' + if coverage: + cmd += ' --with-coverage --cover-erase --cover-package=huffman' + + ctx.run(cmd) + + if coverage: + ctx.run('coverage xml') + ctx.run('coverage html') + + +@task +def report(ctx): + import webbrowser + webbrowser.open_new_tab(fileurl(os.path.join(ROOT, 'coverage_html_report', 'index.html'))) + + +@task +def publish(ctx): + ctx.run('twine upload dist/*') |
