odt-waffles 0.1.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.
- odt_waffles-0.1.0/PKG-INFO +56 -0
- odt_waffles-0.1.0/README.md +45 -0
- odt_waffles-0.1.0/odt.py +67 -0
- odt_waffles-0.1.0/odt_waffles.egg-info/PKG-INFO +56 -0
- odt_waffles-0.1.0/odt_waffles.egg-info/SOURCES.txt +7 -0
- odt_waffles-0.1.0/odt_waffles.egg-info/dependency_links.txt +1 -0
- odt_waffles-0.1.0/odt_waffles.egg-info/top_level.txt +1 -0
- odt_waffles-0.1.0/pyproject.toml +21 -0
- odt_waffles-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: odt-waffles
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Ordered Dictionary Tools for Python
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# ODT — Ordered Dictionary Tools
|
|
14
|
+
|
|
15
|
+
ODT is a Python utility library for manipulating
|
|
16
|
+
dictionary entries by position.
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- Insert entries at specific positions
|
|
21
|
+
- Remove entries by position
|
|
22
|
+
- Retrieve entries by position
|
|
23
|
+
- Move entries
|
|
24
|
+
- Swap entries
|
|
25
|
+
- Sort dictionaries by value
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
python -m pip install odt-waffles
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Example
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from odt import insert_at, get_at
|
|
37
|
+
|
|
38
|
+
player = {
|
|
39
|
+
"name": "Nova",
|
|
40
|
+
"health": 100,
|
|
41
|
+
"level": 5,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
player = insert_at(player, 1, "xp", 250)
|
|
45
|
+
|
|
46
|
+
print(player)
|
|
47
|
+
print(get_at(player, 1))
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Version
|
|
51
|
+
|
|
52
|
+
0.1.0
|
|
53
|
+
|
|
54
|
+
Created by Waffleson
|
|
55
|
+
https://youtube.com/@butterywaffleson?si=wiNxCLoV8Ges6o_S
|
|
56
|
+
https://github.com/ButteryWaffleson
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
# ODT — Ordered Dictionary Tools
|
|
3
|
+
|
|
4
|
+
ODT is a Python utility library for manipulating
|
|
5
|
+
dictionary entries by position.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Insert entries at specific positions
|
|
10
|
+
- Remove entries by position
|
|
11
|
+
- Retrieve entries by position
|
|
12
|
+
- Move entries
|
|
13
|
+
- Swap entries
|
|
14
|
+
- Sort dictionaries by value
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
python -m pip install odt-waffles
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Example
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from odt import insert_at, get_at
|
|
26
|
+
|
|
27
|
+
player = {
|
|
28
|
+
"name": "Nova",
|
|
29
|
+
"health": 100,
|
|
30
|
+
"level": 5,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
player = insert_at(player, 1, "xp", 250)
|
|
34
|
+
|
|
35
|
+
print(player)
|
|
36
|
+
print(get_at(player, 1))
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Version
|
|
40
|
+
|
|
41
|
+
0.1.0
|
|
42
|
+
|
|
43
|
+
Created by Waffleson
|
|
44
|
+
https://youtube.com/@butterywaffleson?si=wiNxCLoV8Ges6o_S
|
|
45
|
+
https://github.com/ButteryWaffleson
|
odt_waffles-0.1.0/odt.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
|
|
2
|
+
"""ODT — Ordered Dictionary Tools"""
|
|
3
|
+
|
|
4
|
+
__version__ = "0.1.0"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def insert_at(dictionary, position, key, value):
|
|
8
|
+
"""Insert a new key-value pair at a specific position."""
|
|
9
|
+
if key in dictionary:
|
|
10
|
+
raise KeyError(f"Key already exists: {key!r}")
|
|
11
|
+
|
|
12
|
+
items = list(dictionary.items())
|
|
13
|
+
items.insert(position, (key, value))
|
|
14
|
+
return dict(items)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def remove_at(dictionary, position):
|
|
18
|
+
"""Remove the entry at a specific position."""
|
|
19
|
+
items = list(dictionary.items())
|
|
20
|
+
items.pop(position)
|
|
21
|
+
return dict(items)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def get_at(dictionary, position):
|
|
25
|
+
"""Get the key-value pair at a specific position."""
|
|
26
|
+
items = list(dictionary.items())
|
|
27
|
+
return items[position]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def move_to(dictionary, old_position, new_position):
|
|
31
|
+
"""Move an entry from one position to another."""
|
|
32
|
+
items = list(dictionary.items())
|
|
33
|
+
entry = items.pop(old_position)
|
|
34
|
+
items.insert(new_position, entry)
|
|
35
|
+
return dict(items)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def swap(dictionary, position_a, position_b):
|
|
39
|
+
"""Swap the entries at two positions."""
|
|
40
|
+
items = list(dictionary.items())
|
|
41
|
+
items[position_a], items[position_b] = (
|
|
42
|
+
items[position_b],
|
|
43
|
+
items[position_a],
|
|
44
|
+
)
|
|
45
|
+
return dict(items)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def sort_by_value(dictionary, reverse=False, key=None):
|
|
49
|
+
"""Sort entries by value, optionally using a custom sorting key."""
|
|
50
|
+
items = list(dictionary.items())
|
|
51
|
+
|
|
52
|
+
if key is None:
|
|
53
|
+
items.sort(
|
|
54
|
+
key=lambda item: (
|
|
55
|
+
type(item[1]).__name__,
|
|
56
|
+
str(item[1]),
|
|
57
|
+
),
|
|
58
|
+
reverse=reverse,
|
|
59
|
+
)
|
|
60
|
+
else:
|
|
61
|
+
items.sort(
|
|
62
|
+
key=lambda item: key(item[1]),
|
|
63
|
+
reverse=reverse,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
return dict(items)
|
|
67
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: odt-waffles
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Ordered Dictionary Tools for Python
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# ODT — Ordered Dictionary Tools
|
|
14
|
+
|
|
15
|
+
ODT is a Python utility library for manipulating
|
|
16
|
+
dictionary entries by position.
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- Insert entries at specific positions
|
|
21
|
+
- Remove entries by position
|
|
22
|
+
- Retrieve entries by position
|
|
23
|
+
- Move entries
|
|
24
|
+
- Swap entries
|
|
25
|
+
- Sort dictionaries by value
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
python -m pip install odt-waffles
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Example
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from odt import insert_at, get_at
|
|
37
|
+
|
|
38
|
+
player = {
|
|
39
|
+
"name": "Nova",
|
|
40
|
+
"health": 100,
|
|
41
|
+
"level": 5,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
player = insert_at(player, 1, "xp", 250)
|
|
45
|
+
|
|
46
|
+
print(player)
|
|
47
|
+
print(get_at(player, 1))
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Version
|
|
51
|
+
|
|
52
|
+
0.1.0
|
|
53
|
+
|
|
54
|
+
Created by Waffleson
|
|
55
|
+
https://youtube.com/@butterywaffleson?si=wiNxCLoV8Ges6o_S
|
|
56
|
+
https://github.com/ButteryWaffleson
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
odt
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
[build-system]
|
|
3
|
+
requires = ["setuptools>=61"]
|
|
4
|
+
build-backend = "setuptools.build_meta"
|
|
5
|
+
|
|
6
|
+
[project]
|
|
7
|
+
name = "odt-waffles"
|
|
8
|
+
version = "0.1.0"
|
|
9
|
+
description = "Ordered Dictionary Tools for Python"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
license = "MIT"
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[tool.setuptools]
|
|
20
|
+
py-modules = ["odt"]
|
|
21
|
+
|