Skip to content
This repository has been archived by the owner on Jan 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #15 from alexras/alexras/better-enums
Browse files Browse the repository at this point in the history
Print valid values when failing to parse an enum.
  • Loading branch information
alexras authored Dec 29, 2018
2 parents 46ac8e5 + d49c51c commit 69913cd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bread/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .lifecycle import *

__title__ = 'bread'
__version__ = '3.0.1'
__version__ = '3.0.2'
__author__ = 'Alex Rasmussen'
__license__ = 'MIT'
__copyright__ = 'Copyright 2015 Alex Rasmussen'
4 changes: 2 additions & 2 deletions bread/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def make_enum_field(parent, **field_options):

def encode_enum(key):
if key not in keys:
raise ValueError('%s is not a valid enum value' % (key))
raise ValueError('%s is not a valid enum value; valid values %s' % (key, keys))

return old_encode_fn(keys[key])

Expand All @@ -24,7 +24,7 @@ def decode_enum(encoded):
return default
else:
raise ValueError(
'%d is not a valid enum value' % (decoded_value))
'%d is not a valid enum value; valid values %s' % (decoded_value, values))

return values[decoded_value]

Expand Down
10 changes: 9 additions & 1 deletion change_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ if [ "$#" -ne 1 ]; then
exit 2
fi

if [[ ${version} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
then
echo "Version format is valid"
else
echo "Version format invalid; must be of the form 'MAJOR.MINOR.PATCH'"
exit 1
fi


# Set version and build to version
sed -i .bak -e "s/version = '.*'/version = '${version}'/g" docs/source/conf.py
sed -i .bak -e "s/release = '.*'/release = '${version}'/g" docs/source/conf.py
Expand All @@ -19,4 +28,3 @@ find . -name "*.bak" -exec rm {} \;

# Tag revision as this version in git
git commit -a -m "Bumping version to ${git_tag}"
git tag ${git_tag}
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
# built documents.
#
# The short X.Y version.
version = '3.0.1'
version = '3.0.2'
# The full version, including alpha/beta/rc tags.
release = '3.0.1'
release = '3.0.2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup

setup(name='bread',
version='3.0.1',
version='3.0.2',
description='Binary format parsing made easier',
url='https://github.com/alexras/bread',
author='Alex Rasmussen',
Expand Down

0 comments on commit 69913cd

Please sign in to comment.