psu-python 0.1.0__tar.gz → 0.2.3__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.
@@ -0,0 +1,69 @@
1
+ Metadata-Version: 2.4
2
+ Name: psu-python
3
+ Version: 0.2.3
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
+ Project-URL: Homepage, https://tedtasman.github.io/psu-python/
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Education
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Natural Language :: English
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Provides-Extra: docs
16
+ Requires-Dist: sphinx>=4.0.0; extra == "docs"
17
+ Requires-Dist: furo; extra == "docs"
18
+ Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
19
+ Dynamic: license-file
20
+
21
+ # PSU Python
22
+
23
+ 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. [Packaged for distribution on PyPi](https://pypi.org/project/psu-python/)
24
+
25
+ ## Usage
26
+
27
+ psu-python is packaged and available on PyPi. To use psu-python, install it with pip in your python environment:
28
+
29
+ ```bash
30
+ pip install psu-python
31
+ ```
32
+
33
+ You will now be able to import psu-python modules in your python code:
34
+
35
+ ```python
36
+ # import all functions
37
+ from psu_python import *
38
+ # or specific ones
39
+ from psu_python import to_lower, get_item
40
+
41
+ def main():
42
+ ...
43
+ ```
44
+
45
+ ## Developer Install
46
+
47
+ 1. Clone the repository
48
+
49
+ ```bash
50
+ git clone git@github.com:tedtasman/psu-python.git
51
+ cd ./psu-python
52
+ ```
53
+
54
+ 2. Create a virtual environment
55
+ - MacOS / Linux:
56
+ ```bash
57
+ python3 -m venv .venv
58
+ source ./.venv/bin/activate
59
+ ```
60
+ - Windows Powershell
61
+ ```Powershell
62
+ python -m venv .venv
63
+ .\.venv\Scripts\activate
64
+ ```
65
+
66
+ 3. Install psu-python locally in editable mode
67
+ ```bash
68
+ pip install -e .
69
+ ```
@@ -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. [Packaged for distribution on PyPi](https://pypi.org/project/psu-python/)
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
+ ```
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["setuptools", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name='psu-python'
7
+ version='0.2.3'
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
+ authors=[
10
+ {name='Theodore Tasman', email='psupython@ttasman.com'}
11
+ ]
12
+ license='GPL-3.0'
13
+ readme='README.md'
14
+ dependencies=[]
15
+ classifiers=[
16
+ 'Development Status :: 3 - Alpha',
17
+ 'Intended Audience :: Education',
18
+ 'Programming Language :: Python :: 3',
19
+ 'Operating System :: OS Independent',
20
+ 'Natural Language :: English',
21
+ ]
22
+
23
+ [project.optional-dependencies]
24
+ docs = [
25
+ "sphinx>=4.0.0",
26
+ "furo",
27
+ "sphinx-autodoc-typehints",
28
+ ]
29
+
30
+ [project.urls]
31
+ Homepage = 'https://tedtasman.github.io/psu-python/'
32
+
@@ -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,69 @@
1
+ Metadata-Version: 2.4
2
+ Name: psu-python
3
+ Version: 0.2.3
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
+ Project-URL: Homepage, https://tedtasman.github.io/psu-python/
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Education
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Natural Language :: English
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Provides-Extra: docs
16
+ Requires-Dist: sphinx>=4.0.0; extra == "docs"
17
+ Requires-Dist: furo; extra == "docs"
18
+ Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
19
+ Dynamic: license-file
20
+
21
+ # PSU Python
22
+
23
+ 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. [Packaged for distribution on PyPi](https://pypi.org/project/psu-python/)
24
+
25
+ ## Usage
26
+
27
+ psu-python is packaged and available on PyPi. To use psu-python, install it with pip in your python environment:
28
+
29
+ ```bash
30
+ pip install psu-python
31
+ ```
32
+
33
+ You will now be able to import psu-python modules in your python code:
34
+
35
+ ```python
36
+ # import all functions
37
+ from psu_python import *
38
+ # or specific ones
39
+ from psu_python import to_lower, get_item
40
+
41
+ def main():
42
+ ...
43
+ ```
44
+
45
+ ## Developer Install
46
+
47
+ 1. Clone the repository
48
+
49
+ ```bash
50
+ git clone git@github.com:tedtasman/psu-python.git
51
+ cd ./psu-python
52
+ ```
53
+
54
+ 2. Create a virtual environment
55
+ - MacOS / Linux:
56
+ ```bash
57
+ python3 -m venv .venv
58
+ source ./.venv/bin/activate
59
+ ```
60
+ - Windows Powershell
61
+ ```Powershell
62
+ python -m venv .venv
63
+ .\.venv\Scripts\activate
64
+ ```
65
+
66
+ 3. Install psu-python locally in editable mode
67
+ ```bash
68
+ pip install -e .
69
+ ```
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/psu_python/__init__.py
5
+ src/psu_python/dictionaries.py
6
+ src/psu_python/lists.py
7
+ src/psu_python/strings.py
8
+ src/psu_python.egg-info/PKG-INFO
9
+ src/psu_python.egg-info/SOURCES.txt
10
+ src/psu_python.egg-info/dependency_links.txt
11
+ src/psu_python.egg-info/requires.txt
12
+ src/psu_python.egg-info/top_level.txt
@@ -0,0 +1,5 @@
1
+
2
+ [docs]
3
+ sphinx>=4.0.0
4
+ furo
5
+ sphinx-autodoc-typehints
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
@@ -1,23 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools", "wheel"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name='psu-python'
7
- version='0.1.0'
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
- authors=[
10
- {name='Theodore Tasman', email='psupython@ttasman.com'}
11
- ]
12
- license='GPL-3.0'
13
- readme='README.md'
14
- dependencies=[]
15
- classifiers=[
16
- 'Development Status :: 4 - Beta',
17
- 'Intended Audience :: Developers',
18
- 'Programming Language :: Python :: 3',
19
- 'Topic :: Scientific/Engineering',
20
- 'Operating System :: OS Independent',
21
- 'Natural Language :: English',
22
- ]
23
-
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
@@ -1,7 +0,0 @@
1
- LICENSE
2
- pyproject.toml
3
- src/psu_python/__init__.py
4
- src/psu_python.egg-info/PKG-INFO
5
- src/psu_python.egg-info/SOURCES.txt
6
- src/psu_python.egg-info/dependency_links.txt
7
- src/psu_python.egg-info/top_level.txt
File without changes
File without changes