Skip to content

Commit

Permalink
Require cmd2>=0.10.0
Browse files Browse the repository at this point in the history
Also:
- Updated .gitignore
- Added flake8 and tagging to invoke tasks
- Fixed flake8 warnings
- Added Pipfile for ease of use
  • Loading branch information
tleonhardt committed Feb 21, 2020
1 parent ef8c90a commit 30be66a
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,9 @@ venv.bak/

# mypy
.mypy_cache/

# PyCharm / IntelliJ
.idea

# Pipenv
Pipfile.lock
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 1.1.0 (2020-02-21)
- Because of a breaking change in `cmd2`, we now require `cmd2>=0.10.0`

## 1.0.2 (2019-12-07)

### Added
Expand Down
21 changes: 21 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[packages]
cmd2 = ">=0.10.0"

[dev-packages]
cmd2-abbrev = {editable = true,path = "."}
codecov = "*"
flake8 = "*"
gnureadline = {version = "*",sys_platform = "== 'darwin'"}
invoke = "*"
ipython = "*"
mock = {version = "*",markers = "python_version < '3.6'"}
pyreadline = {version = "*",sys_platform = "== 'win32'"}
pytest = "*"
pytest-cov = "*"
pytest-mock = "*"
twine = ">=1.11"
2 changes: 1 addition & 1 deletion cmd2_abbrev/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# coding=utf-8
# flake8: noqa F401
"""An abbreviation plugin for cmd2
Adds a user setting `abbrev` which defaults to false. When set to True
Expand All @@ -8,7 +9,6 @@
See examples/example.py
"""

from pkg_resources import get_distribution, DistributionNotFound

from .abbrev import AbbrevMixin
Expand Down
1 change: 1 addition & 0 deletions cmd2_abbrev/abbrev.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import cmd2


class AbbrevMixin:
"""A cmd2 plugin (mixin class) which adds support for abbreviated commands."""
def __init__(self, *args, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import cmd2
import cmd2_abbrev


class AbbrevExample(cmd2_abbrev.AbbrevMixin, cmd2.Cmd):
"""A cmd2 program to demonstrate the use of the cmd2_abbrev plugin"""
def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -35,6 +36,7 @@ def do_speak(self, args):
# .poutput handles newlines, and accommodates output redirection too
self.poutput(' '.join(words))


if __name__ == '__main__':
app = AbbrevExample()
app.cmdloop()
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

packages=['cmd2_abbrev'],

python_requires='>=3.4',
install_requires=['cmd2 >= 0.9.12, <=2'],
python_requires='>=3.5',
install_requires=['cmd2 >= 0.10.0, <=2'],

setup_requires=['setuptools_scm'],

Expand All @@ -42,12 +42,13 @@
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
],

# dependencies for development and testing
# $ pip install -e .[dev]
extras_require={
'dev': ['setuptools_scm', 'pytest', 'codecov', 'pytest-cov',
'pylint', 'invoke', 'wheel', 'twine']
'flake8', 'invoke', 'wheel', 'twine']
},
)
49 changes: 46 additions & 3 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
#
# -*- coding: utf-8 -*-
"""Development related tasks to be run with 'invoke'"""

# coding=utf-8
# flake8: noqa E302
"""Development related tasks to be run with 'invoke'.
Make sure you satisfy the following Python module requirements if you are trying to publish a release to PyPI:
- twine >= 1.11.0
- wheel >= 0.31.0
- setuptools >= 39.1.0
"""
import os
import re
import shutil
import sys

import invoke

Expand Down Expand Up @@ -135,6 +143,34 @@ def clean_all(context):
pass
namespace_clean.add_task(clean_all, 'all')

@invoke.task
def tag(context, name, message=''):
"Add a Git tag and push it to origin"
# If a tag was provided on the command-line, then add a Git tag and push it to origin
if name:
context.run('git tag -a {} -m {!r}'.format(name, message))
context.run('git push origin {}'.format(name))
namespace.add_task(tag)

@invoke.task()
def validatetag(context):
"Check to make sure that a tag exists for the current HEAD and it looks like a valid version number"
# Validate that a Git tag exists for the current commit HEAD
result = context.run("git describe --exact-match --tags $(git log -n1 --pretty='%h')")
tag = result.stdout.rstrip()

# Validate that the Git tag appears to be a valid version number
ver_regex = re.compile(r'(\d+)\.(\d+)\.(\d+)')
match = ver_regex.fullmatch(tag)
if match is None:
print('Tag {!r} does not appear to be a valid version number'.format(tag))
sys.exit(-1)
else:
print('Tag {!r} appears to be a valid version number'.format(tag))


namespace.add_task(validatetag)

@invoke.task(pre=[clean_all])
def sdist(context):
"Create a source distribution"
Expand All @@ -158,3 +194,10 @@ def pypi_test(context):
"Build and upload a distribution to https://test.pypi.org"
context.run('twine upload --repository-url https://test.pypi.org/legacy/ dist/*')
namespace.add_task(pypi_test)

# Flake8 - linter and tool for style guide enforcement and linting
@invoke.task
def flake8(context):
"Run flake8 linter and tool for style guide enforcement"
context.run("flake8 --ignore=E252,W503 --max-complexity=26 --max-line-length=127 --show-source --statistics --exclude=.git,__pycache__,.tox,.eggs,*.egg,.venv,.idea,.pytest_cache,.vscode,build,dist,htmlcov")
namespace.add_task(flake8)
2 changes: 1 addition & 1 deletion tests/test_abbrev.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# coding=utf-8
# flake8: noqa E302

import argparse

Expand Down

0 comments on commit 30be66a

Please sign in to comment.