impara 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- impara-0.2.0/LICENSE +21 -0
- impara-0.2.0/PKG-INFO +29 -0
- impara-0.2.0/README.md +15 -0
- impara-0.2.0/pyproject.toml +26 -0
- impara-0.2.0/setup.cfg +4 -0
- impara-0.2.0/src/impara/__init__.py +6 -0
- impara-0.2.0/src/impara/__main__.py +3 -0
- impara-0.2.0/src/impara/cli.py +35 -0
- impara-0.2.0/src/impara/operations.py +19 -0
- impara-0.2.0/src/impara.egg-info/PKG-INFO +29 -0
- impara-0.2.0/src/impara.egg-info/SOURCES.txt +13 -0
- impara-0.2.0/src/impara.egg-info/dependency_links.txt +1 -0
- impara-0.2.0/src/impara.egg-info/entry_points.txt +2 -0
- impara-0.2.0/src/impara.egg-info/top_level.txt +1 -0
- impara-0.2.0/tests/test_operations.py +15 -0
impara-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ivanbright
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
impara-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: impara
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A simple calculator package and command-line tool
|
|
5
|
+
Author-email: ivanbright <mugishaivanbright250@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/ivanbright/impara
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# impara
|
|
16
|
+
A simple calculator package.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
pip install impara
|
|
20
|
+
|
|
21
|
+
## Use in the terminal
|
|
22
|
+
impara add 10 25 # 35
|
|
23
|
+
impara multiply 4 5 # 20
|
|
24
|
+
impara average 10 20 30 40 # 25
|
|
25
|
+
|
|
26
|
+
## Use in Python
|
|
27
|
+
from impara import add, multiply, average
|
|
28
|
+
add(10, 25) # 35
|
|
29
|
+
average([10, 20, 30, 40]) # 25.0
|
impara-0.2.0/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# impara
|
|
2
|
+
A simple calculator package.
|
|
3
|
+
|
|
4
|
+
## Install
|
|
5
|
+
pip install impara
|
|
6
|
+
|
|
7
|
+
## Use in the terminal
|
|
8
|
+
impara add 10 25 # 35
|
|
9
|
+
impara multiply 4 5 # 20
|
|
10
|
+
impara average 10 20 30 40 # 25
|
|
11
|
+
|
|
12
|
+
## Use in Python
|
|
13
|
+
from impara import add, multiply, average
|
|
14
|
+
add(10, 25) # 35
|
|
15
|
+
average([10, 20, 30, 40]) # 25.0
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "impara"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "A simple calculator package and command-line tool"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [{ name = "ivanbright", email = "mugishaivanbright250@gmail.com" }]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Programming Language :: Python :: 3",
|
|
13
|
+
"License :: OSI Approved :: MIT License",
|
|
14
|
+
"Operating System :: OS Independent",
|
|
15
|
+
]
|
|
16
|
+
requires-python = ">=3.8"
|
|
17
|
+
dependencies = []
|
|
18
|
+
|
|
19
|
+
[project.scripts]
|
|
20
|
+
impara = "impara.cli:main"
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Homepage = "https://github.com/ivanbright/impara"
|
|
24
|
+
|
|
25
|
+
[tool.setuptools.packages.find]
|
|
26
|
+
where = ["src"]
|
impara-0.2.0/setup.cfg
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
|
|
3
|
+
from . import __version__, add, multiply, average
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def _fmt(x):
|
|
7
|
+
"""Show 35.0 as 35, but keep 2.5 as 2.5."""
|
|
8
|
+
return str(int(x)) if x == int(x) else str(x)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def main(argv=None):
|
|
12
|
+
parser = argparse.ArgumentParser(prog="impara", description="A simple calculator")
|
|
13
|
+
parser.add_argument("--version", action="version", version=f"impara {__version__}")
|
|
14
|
+
sub = parser.add_subparsers(dest="command")
|
|
15
|
+
|
|
16
|
+
p = sub.add_parser("add", help="add two numbers")
|
|
17
|
+
p.add_argument("a", type=float)
|
|
18
|
+
p.add_argument("b", type=float)
|
|
19
|
+
p.set_defaults(func=lambda x: add(x.a, x.b))
|
|
20
|
+
|
|
21
|
+
p = sub.add_parser("multiply", help="multiply two numbers")
|
|
22
|
+
p.add_argument("a", type=float)
|
|
23
|
+
p.add_argument("b", type=float)
|
|
24
|
+
p.set_defaults(func=lambda x: multiply(x.a, x.b))
|
|
25
|
+
|
|
26
|
+
p = sub.add_parser("average", help="average of one or more numbers")
|
|
27
|
+
p.add_argument("numbers", type=float, nargs="+")
|
|
28
|
+
p.set_defaults(func=lambda x: average(x.numbers))
|
|
29
|
+
|
|
30
|
+
args = parser.parse_args(argv)
|
|
31
|
+
if not hasattr(args, "func"):
|
|
32
|
+
parser.print_help()
|
|
33
|
+
return 1
|
|
34
|
+
print(_fmt(args.func(args)))
|
|
35
|
+
return 0
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Core arithmetic and statistical helper functions for impara."""
|
|
2
|
+
from typing import Sequence
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def add(a: float, b: float) -> float:
|
|
6
|
+
"""Return the sum of two numbers."""
|
|
7
|
+
return a + b
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def multiply(a: float, b: float) -> float:
|
|
11
|
+
"""Return the product of two numbers."""
|
|
12
|
+
return a * b
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def average(numbers: Sequence[float]) -> float:
|
|
16
|
+
"""Return the arithmetic mean of a non-empty sequence of numbers."""
|
|
17
|
+
if not numbers:
|
|
18
|
+
raise ValueError("average() requires at least one number")
|
|
19
|
+
return sum(numbers) / len(numbers)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: impara
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A simple calculator package and command-line tool
|
|
5
|
+
Author-email: ivanbright <mugishaivanbright250@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/ivanbright/impara
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# impara
|
|
16
|
+
A simple calculator package.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
pip install impara
|
|
20
|
+
|
|
21
|
+
## Use in the terminal
|
|
22
|
+
impara add 10 25 # 35
|
|
23
|
+
impara multiply 4 5 # 20
|
|
24
|
+
impara average 10 20 30 40 # 25
|
|
25
|
+
|
|
26
|
+
## Use in Python
|
|
27
|
+
from impara import add, multiply, average
|
|
28
|
+
add(10, 25) # 35
|
|
29
|
+
average([10, 20, 30, 40]) # 25.0
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/impara/__init__.py
|
|
5
|
+
src/impara/__main__.py
|
|
6
|
+
src/impara/cli.py
|
|
7
|
+
src/impara/operations.py
|
|
8
|
+
src/impara.egg-info/PKG-INFO
|
|
9
|
+
src/impara.egg-info/SOURCES.txt
|
|
10
|
+
src/impara.egg-info/dependency_links.txt
|
|
11
|
+
src/impara.egg-info/entry_points.txt
|
|
12
|
+
src/impara.egg-info/top_level.txt
|
|
13
|
+
tests/test_operations.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
impara
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from impara import add, multiply, average
|
|
3
|
+
|
|
4
|
+
def test_add():
|
|
5
|
+
assert add(10, 25) == 35
|
|
6
|
+
|
|
7
|
+
def test_multiply():
|
|
8
|
+
assert multiply(4, 5) == 20
|
|
9
|
+
|
|
10
|
+
def test_average():
|
|
11
|
+
assert average([10, 20, 30, 40]) == 25.0
|
|
12
|
+
|
|
13
|
+
def test_average_empty():
|
|
14
|
+
with pytest.raises(ValueError):
|
|
15
|
+
average([])
|