psu-python 0.1.0__tar.gz → 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.
- psu_python-0.2.0/PKG-INFO +64 -0
- psu_python-0.2.0/README.md +49 -0
- {psu_python-0.1.0 → psu_python-0.2.0}/pyproject.toml +2 -3
- psu_python-0.2.0/src/psu_python/__init__.py +15 -0
- psu_python-0.2.0/src/psu_python/dictionaries.py +91 -0
- psu_python-0.2.0/src/psu_python/lists.py +58 -0
- psu_python-0.2.0/src/psu_python/strings.py +20 -0
- psu_python-0.2.0/src/psu_python.egg-info/PKG-INFO +64 -0
- {psu_python-0.1.0 → psu_python-0.2.0}/src/psu_python.egg-info/SOURCES.txt +4 -0
- psu_python-0.1.0/PKG-INFO +0 -15
- psu_python-0.1.0/src/psu_python/__init__.py +0 -0
- psu_python-0.1.0/src/psu_python.egg-info/PKG-INFO +0 -15
- {psu_python-0.1.0 → psu_python-0.2.0}/LICENSE +0 -0
- {psu_python-0.1.0 → psu_python-0.2.0}/setup.cfg +0 -0
- {psu_python-0.1.0 → psu_python-0.2.0}/src/psu_python.egg-info/dependency_links.txt +0 -0
- {psu_python-0.1.0 → psu_python-0.2.0}/src/psu_python.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: psu-python
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A python package for abstracting python class methods behind a fully functional layer intended for educational use in CMPSC 131 at The Pennsylvania State University
|
|
5
|
+
Author-email: Theodore Tasman <psupython@ttasman.com>
|
|
6
|
+
License-Expression: GPL-3.0
|
|
7
|
+
Classifier: Development Status :: 4 - Beta
|
|
8
|
+
Classifier: Intended Audience :: Education
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Natural Language :: English
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# PSU Python
|
|
17
|
+
|
|
18
|
+
A python package for abstracting python class methods behind a fully functional layer. Intended for educational use in CMPSC 131 at The Pennsylvania State University
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
psu-python is packaged and available on PyPi. To use psu-python, install it with pip in your python environment:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install psu-python
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
You will now be able to import psu-python modules in your python code:
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
# import all functions
|
|
32
|
+
from psu_python import *
|
|
33
|
+
# or specific ones
|
|
34
|
+
from psu_python import to_lower, get_item
|
|
35
|
+
|
|
36
|
+
def main():
|
|
37
|
+
...
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Developer Install
|
|
41
|
+
|
|
42
|
+
1. Clone the repository
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
git clone git@github.com:tedtasman/psu-python.git
|
|
46
|
+
cd ./psu-python
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
2. Create a virtual environment
|
|
50
|
+
- MacOS / Linux:
|
|
51
|
+
```bash
|
|
52
|
+
python3 -m venv .venv
|
|
53
|
+
source ./.venv/bin/activate
|
|
54
|
+
```
|
|
55
|
+
- Windows Powershell
|
|
56
|
+
```Powershell
|
|
57
|
+
python -m venv .venv
|
|
58
|
+
.\.venv\Scripts\activate
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
3. Install psu-python locally in editable mode
|
|
62
|
+
```bash
|
|
63
|
+
pip install -e .
|
|
64
|
+
```
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# PSU Python
|
|
2
|
+
|
|
3
|
+
A python package for abstracting python class methods behind a fully functional layer. Intended for educational use in CMPSC 131 at The Pennsylvania State University
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
psu-python is packaged and available on PyPi. To use psu-python, install it with pip in your python environment:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install psu-python
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
You will now be able to import psu-python modules in your python code:
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
# import all functions
|
|
17
|
+
from psu_python import *
|
|
18
|
+
# or specific ones
|
|
19
|
+
from psu_python import to_lower, get_item
|
|
20
|
+
|
|
21
|
+
def main():
|
|
22
|
+
...
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Developer Install
|
|
26
|
+
|
|
27
|
+
1. Clone the repository
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
git clone git@github.com:tedtasman/psu-python.git
|
|
31
|
+
cd ./psu-python
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
2. Create a virtual environment
|
|
35
|
+
- MacOS / Linux:
|
|
36
|
+
```bash
|
|
37
|
+
python3 -m venv .venv
|
|
38
|
+
source ./.venv/bin/activate
|
|
39
|
+
```
|
|
40
|
+
- Windows Powershell
|
|
41
|
+
```Powershell
|
|
42
|
+
python -m venv .venv
|
|
43
|
+
.\.venv\Scripts\activate
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
3. Install psu-python locally in editable mode
|
|
47
|
+
```bash
|
|
48
|
+
pip install -e .
|
|
49
|
+
```
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name='psu-python'
|
|
7
|
-
version='0.
|
|
7
|
+
version='0.2.0'
|
|
8
8
|
description=' A python package for abstracting python class methods behind a fully functional layer intended for educational use in CMPSC 131 at The Pennsylvania State University'
|
|
9
9
|
authors=[
|
|
10
10
|
{name='Theodore Tasman', email='psupython@ttasman.com'}
|
|
@@ -14,9 +14,8 @@ readme='README.md'
|
|
|
14
14
|
dependencies=[]
|
|
15
15
|
classifiers=[
|
|
16
16
|
'Development Status :: 4 - Beta',
|
|
17
|
-
'Intended Audience ::
|
|
17
|
+
'Intended Audience :: Education',
|
|
18
18
|
'Programming Language :: Python :: 3',
|
|
19
|
-
'Topic :: Scientific/Engineering',
|
|
20
19
|
'Operating System :: OS Independent',
|
|
21
20
|
'Natural Language :: English',
|
|
22
21
|
]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from psu_python.dictionaries import delete, get_items, get_keys, get_value, get_values
|
|
2
|
+
from psu_python.lists import join, append, pop
|
|
3
|
+
from psu_python.strings import split
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"delete",
|
|
7
|
+
"get_items",
|
|
8
|
+
"get_keys",
|
|
9
|
+
"get_value",
|
|
10
|
+
"get_values",
|
|
11
|
+
"join",
|
|
12
|
+
"append",
|
|
13
|
+
"pop",
|
|
14
|
+
"split",
|
|
15
|
+
]
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
from collections.abc import KeysView, ValuesView, ItemsView
|
|
3
|
+
|
|
4
|
+
# I don't love using `d` for the dictionary parameter but I'm not sure what would be better
|
|
5
|
+
|
|
6
|
+
# delete key from d
|
|
7
|
+
# this is really just d.pop(key), but I can't call it pop because that collides with the list version
|
|
8
|
+
def delete(key: Any, d: dict) -> Any:
|
|
9
|
+
"""Remove `key` from dictionary `d` and return its value.
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
key (Any): The list index for the element to remove.
|
|
13
|
+
d (dict): The dictionary to remove from.
|
|
14
|
+
|
|
15
|
+
Raises:
|
|
16
|
+
KeyError: `key` must exist within `d`.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
Any: The value of the popped key.
|
|
20
|
+
"""
|
|
21
|
+
if not isinstance(d, dict):
|
|
22
|
+
raise TypeError("d must be of type dict")
|
|
23
|
+
|
|
24
|
+
value = d.pop(key)
|
|
25
|
+
|
|
26
|
+
if value is None:
|
|
27
|
+
raise KeyError(f"Key \"{key}\" not in dictionary")
|
|
28
|
+
|
|
29
|
+
return value
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def get_keys(d: dict) -> KeysView:
|
|
33
|
+
"""Get a dynamic view object of the dictionary `d`'s keys that reflects changes to `d`.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
d (dict): the dictionary.
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
KeysView: A view of the keys in `d`.
|
|
40
|
+
"""
|
|
41
|
+
if not isinstance(d, dict):
|
|
42
|
+
raise TypeError("d must be of type dict")
|
|
43
|
+
|
|
44
|
+
return d.keys()
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def get_values(d: dict) -> ValuesView:
|
|
48
|
+
"""Get a dynamic view object of the dictionary `d`'s values that reflects changes to `d`.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
d (dict): the dictionary.
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
ValuesView: A view of the values in `d`.
|
|
55
|
+
"""
|
|
56
|
+
if not isinstance(d, dict):
|
|
57
|
+
raise TypeError("d must be of type dict")
|
|
58
|
+
|
|
59
|
+
return d.values()
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def get_items(d: dict) -> ItemsView:
|
|
63
|
+
"""Get a dynamic view object of the dictionary `d`'s key, value pairs that reflects changes to `d`
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
d (dict): the dictionary.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
ValuesView: A view of the (key, value) tuple pairs in `d`.
|
|
70
|
+
"""
|
|
71
|
+
if not isinstance(d, dict):
|
|
72
|
+
raise TypeError("d must be of type dict")
|
|
73
|
+
|
|
74
|
+
return d.items()
|
|
75
|
+
|
|
76
|
+
# get key from d
|
|
77
|
+
def get_value(key: Any, d: dict, default: Any = None) -> Any:
|
|
78
|
+
"""Get the value corresponding to `key` from `d`. If `key` is not in `d`, returns `default`.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
key (Any): the key to get from `d`.
|
|
82
|
+
d (dict): the dictionary to check for `key`.
|
|
83
|
+
default (Any, optional): the value to return if `key` is not in `d`. If not specified, defaults to `None`.
|
|
84
|
+
|
|
85
|
+
Returns:
|
|
86
|
+
Any: The value corresponding to `key`, or `default` if not in `d`.
|
|
87
|
+
"""
|
|
88
|
+
if not isinstance(d, dict):
|
|
89
|
+
raise TypeError("d must be of type dict")
|
|
90
|
+
|
|
91
|
+
return d.get(key, default)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from typing import Any, Optional
|
|
2
|
+
|
|
3
|
+
# "join list by separator"
|
|
4
|
+
def join(lst: list, separator: str) -> str:
|
|
5
|
+
"""Join elements of a list into a single string, separated by a delimiter.
|
|
6
|
+
|
|
7
|
+
Args:
|
|
8
|
+
lst (list): the list to join
|
|
9
|
+
separator (str): string to separate list elements
|
|
10
|
+
|
|
11
|
+
Returns:
|
|
12
|
+
str: a joined string of the list elements
|
|
13
|
+
"""
|
|
14
|
+
if not isinstance(separator, str):
|
|
15
|
+
raise TypeError("separator must be of type str")
|
|
16
|
+
if not isinstance(lst, list):
|
|
17
|
+
raise TypeError("lst must be of type list")
|
|
18
|
+
|
|
19
|
+
return separator.join(lst)
|
|
20
|
+
|
|
21
|
+
# "append element to list"
|
|
22
|
+
def append(element: Any, lst: list) -> None:
|
|
23
|
+
"""Append `element` to the end of `lst`. Modifies `lst`.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
lst (list): the list to append to
|
|
27
|
+
element (Any): the item to append
|
|
28
|
+
"""
|
|
29
|
+
if not isinstance(lst, list):
|
|
30
|
+
raise TypeError("lst must be of type list")
|
|
31
|
+
lst.append(element)
|
|
32
|
+
|
|
33
|
+
# "pop list[index]"
|
|
34
|
+
def pop(lst: list, index: Optional[int] = None) -> Any:
|
|
35
|
+
"""Remove and return the element at position `index` from `lst`.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
lst (list): The list to remove from.
|
|
39
|
+
index (int, optional): The list index for the element to remove. If not specified or `None`, pops last element.
|
|
40
|
+
|
|
41
|
+
Raises:
|
|
42
|
+
IndexError: `index` must exist within `lst`.
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
Any: The popped element.
|
|
46
|
+
"""
|
|
47
|
+
if not isinstance(lst, list):
|
|
48
|
+
raise TypeError("lst must be of type list")
|
|
49
|
+
if not isinstance(index, int) and index is not None:
|
|
50
|
+
raise TypeError("index must be None or of type int")
|
|
51
|
+
|
|
52
|
+
if index is not None and (index > len(lst) - 1 or -1 * index > len(lst)):
|
|
53
|
+
raise IndexError("pop index out of range")
|
|
54
|
+
|
|
55
|
+
if index is None:
|
|
56
|
+
return lst.pop()
|
|
57
|
+
|
|
58
|
+
return lst.pop(index)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
# split string by sep
|
|
4
|
+
def split(string: str, sep: Optional[str] = None, maxsplit: int = -1) -> list[str]:
|
|
5
|
+
"""Create a list of words in `string` separated by `sep`.
|
|
6
|
+
|
|
7
|
+
Args:
|
|
8
|
+
string (str): The string to split.
|
|
9
|
+
separator (str, optional): The separator delimiting words. If not specified or `None`, splits at whitespace.
|
|
10
|
+
maxsplit (int, optional): The maximum number of splits to complete. If not specified or `-1`, all possible splits are made.
|
|
11
|
+
|
|
12
|
+
Returns:
|
|
13
|
+
list: A list containing the words after splitting.
|
|
14
|
+
"""
|
|
15
|
+
if not isinstance(string, str):
|
|
16
|
+
raise TypeError("string must be of type str")
|
|
17
|
+
if not isinstance(sep, str) and sep is not None:
|
|
18
|
+
raise TypeError("separator must be of type str")
|
|
19
|
+
|
|
20
|
+
return string.split(sep, maxsplit)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: psu-python
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A python package for abstracting python class methods behind a fully functional layer intended for educational use in CMPSC 131 at The Pennsylvania State University
|
|
5
|
+
Author-email: Theodore Tasman <psupython@ttasman.com>
|
|
6
|
+
License-Expression: GPL-3.0
|
|
7
|
+
Classifier: Development Status :: 4 - Beta
|
|
8
|
+
Classifier: Intended Audience :: Education
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Natural Language :: English
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# PSU Python
|
|
17
|
+
|
|
18
|
+
A python package for abstracting python class methods behind a fully functional layer. Intended for educational use in CMPSC 131 at The Pennsylvania State University
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
psu-python is packaged and available on PyPi. To use psu-python, install it with pip in your python environment:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install psu-python
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
You will now be able to import psu-python modules in your python code:
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
# import all functions
|
|
32
|
+
from psu_python import *
|
|
33
|
+
# or specific ones
|
|
34
|
+
from psu_python import to_lower, get_item
|
|
35
|
+
|
|
36
|
+
def main():
|
|
37
|
+
...
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Developer Install
|
|
41
|
+
|
|
42
|
+
1. Clone the repository
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
git clone git@github.com:tedtasman/psu-python.git
|
|
46
|
+
cd ./psu-python
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
2. Create a virtual environment
|
|
50
|
+
- MacOS / Linux:
|
|
51
|
+
```bash
|
|
52
|
+
python3 -m venv .venv
|
|
53
|
+
source ./.venv/bin/activate
|
|
54
|
+
```
|
|
55
|
+
- Windows Powershell
|
|
56
|
+
```Powershell
|
|
57
|
+
python -m venv .venv
|
|
58
|
+
.\.venv\Scripts\activate
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
3. Install psu-python locally in editable mode
|
|
62
|
+
```bash
|
|
63
|
+
pip install -e .
|
|
64
|
+
```
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
LICENSE
|
|
2
|
+
README.md
|
|
2
3
|
pyproject.toml
|
|
3
4
|
src/psu_python/__init__.py
|
|
5
|
+
src/psu_python/dictionaries.py
|
|
6
|
+
src/psu_python/lists.py
|
|
7
|
+
src/psu_python/strings.py
|
|
4
8
|
src/psu_python.egg-info/PKG-INFO
|
|
5
9
|
src/psu_python.egg-info/SOURCES.txt
|
|
6
10
|
src/psu_python.egg-info/dependency_links.txt
|
psu_python-0.1.0/PKG-INFO
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: psu-python
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: A python package for abstracting python class methods behind a fully functional layer intended for educational use in CMPSC 131 at The Pennsylvania State University
|
|
5
|
-
Author-email: Theodore Tasman <psupython@ttasman.com>
|
|
6
|
-
License-Expression: GPL-3.0
|
|
7
|
-
Classifier: Development Status :: 4 - Beta
|
|
8
|
-
Classifier: Intended Audience :: Developers
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Topic :: Scientific/Engineering
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Classifier: Natural Language :: English
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
License-File: LICENSE
|
|
15
|
-
Dynamic: license-file
|
|
File without changes
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: psu-python
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: A python package for abstracting python class methods behind a fully functional layer intended for educational use in CMPSC 131 at The Pennsylvania State University
|
|
5
|
-
Author-email: Theodore Tasman <psupython@ttasman.com>
|
|
6
|
-
License-Expression: GPL-3.0
|
|
7
|
-
Classifier: Development Status :: 4 - Beta
|
|
8
|
-
Classifier: Intended Audience :: Developers
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Topic :: Scientific/Engineering
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Classifier: Natural Language :: English
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
License-File: LICENSE
|
|
15
|
-
Dynamic: license-file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|