Skip to content

Commit 9cced67

Browse files
Merge pull request #240 from maximvelichko/fix
Fix: str2bool does not raise ValueError on invalid value, enable build and pytest
2 parents c194b88 + 93fbd41 commit 9cced67

File tree

4 files changed

+50
-3
lines changed

4 files changed

+50
-3
lines changed

.github/workflows/buddy-build.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Buddy Build
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
max-parallel: 4
10+
matrix:
11+
python-version: [3.11, 3.13]
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install setuptools wheel pytest responses
25+
26+
- name: Build
27+
env:
28+
CI: 1
29+
run: |
30+
python setup.py sdist bdist_wheel
31+
32+
- name: Install wheel
33+
run:
34+
pip install dist/amcrest-*.whl
35+
36+
- name: Test
37+
run: |
38+
pytest -v

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,6 @@ ENV/
105105
# Rope project settings
106106
.ropeproject
107107

108-
# Vim temporary files
108+
# Vim/emacs temporary/backup files
109109
*.swp
110+
*~

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def readme():
99

1010
setup(
1111
name="amcrest",
12-
version="1.9.9",
12+
version="1.9.10",
1313
description="Python wrapper implementation for Amcrest cameras.",
1414
long_description=readme(),
1515
author="Douglas Schilling Landgraf, Marcelo Moreira de Mello",

src/amcrest/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,15 @@ def str2bool(value: Union[str, int]) -> bool:
5151
False values: n, no, false, off, 0
5252
"""
5353
if isinstance(value, str):
54-
return value.lower() in ("y", "yes", "on", "1", "true", "t")
54+
valueCompare = value.lower()
55+
56+
if valueCompare in ("y", "yes", "on", "1", "true", "t"):
57+
return True
58+
elif valueCompare in ("n", "no", "off", "0", "false"):
59+
return False
60+
else:
61+
raise ValueError(value)
62+
5563
return bool(value)
5664

5765

0 commit comments

Comments
 (0)