ures 2.3.0__tar.gz → 2.4.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.
- ures-2.4.0/PKG-INFO +156 -0
- ures-2.4.0/docs/index.md +117 -0
- {ures-2.3.0 → ures-2.4.0}/pyproject.toml +4 -2
- {ures-2.3.0 → ures-2.4.0}/ures/data_structure/bi_directional_links.py +16 -14
- {ures-2.3.0 → ures-2.4.0}/ures/data_structure/tree.py +21 -18
- {ures-2.3.0 → ures-2.4.0}/ures/files.py +10 -9
- {ures-2.3.0 → ures-2.4.0}/ures/literature/citation/middlewares.py +1 -1
- {ures-2.3.0 → ures-2.4.0}/ures/literature/citation/rules/__init__.py +1 -1
- {ures-2.3.0 → ures-2.4.0}/ures/markdown/zettelkasten.py +2 -1
- {ures-2.3.0 → ures-2.4.0}/ures/string.py +3 -3
- {ures-2.3.0 → ures-2.4.0}/ures/timedate.py +1 -2
- {ures-2.3.0 → ures-2.4.0}/ures/tools/decorator.py +1 -1
- {ures-2.3.0 → ures-2.4.0}/ures/tools/enum.py +1 -1
- ures-2.3.0/PKG-INFO +0 -183
- ures-2.3.0/docs/index.md +0 -148
- {ures-2.3.0 → ures-2.4.0}/LICENSE +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/__init__.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/data_structure/__init__.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/docker/__init__.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/docker/cleanup.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/docker/conf.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/docker/container.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/docker/containers.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/docker/image.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/docker/runtime.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/literature/__init__.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/literature/citation/README.md +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/literature/citation/__init__.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/literature/citation/extractors.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/literature/citation/manager.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/literature/citation/rules/acm.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/literature/citation/rules/basic.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/literature/citation/rules/data_type.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/literature/search/README.md +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/literature/search/__init__.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/literature/search/adapters.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/literature/search/paper.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/literature/search/search.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/literature/search_cli.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/markdown/__init__.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/markdown/manipulator.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/memory/__init__.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/memory/allocator.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/memory/blocks.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/memory/smoke_test.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/network.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/secrets.py +0 -0
- {ures-2.3.0 → ures-2.4.0}/ures/tools/__init__.py +0 -0
ures-2.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ures
|
|
3
|
+
Version: 2.4.0
|
|
4
|
+
Summary: Utility library for research and development: Docker workflows, Markdown and Zettelkasten, data structures, and core file/network/string/time helpers.
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: utilization,Research Tool,Python
|
|
8
|
+
Author: stone
|
|
9
|
+
Author-email: github@stone-bo.com
|
|
10
|
+
Requires-Python: >=3.11,<4.0
|
|
11
|
+
Classifier: Development Status :: 1 - Planning
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Classifier: Topic :: Utilities
|
|
22
|
+
Requires-Dist: beautifulsoup4 (>=4.13.4,<5.0.0)
|
|
23
|
+
Requires-Dist: bibtexparser (>=2.0.0b8,<3.0.0)
|
|
24
|
+
Requires-Dist: docker (>=7.1.0,<8.0.0)
|
|
25
|
+
Requires-Dist: onepassword-sdk (>=0.3.1,<0.4.0)
|
|
26
|
+
Requires-Dist: pycountry (>=24.6.1,<25.0.0)
|
|
27
|
+
Requires-Dist: pydantic (>=2.10.6,<3.0.0)
|
|
28
|
+
Requires-Dist: pyperclip (>=1.9.0,<2.0.0)
|
|
29
|
+
Requires-Dist: python-frontmatter (>=1.1.0,<2.0.0)
|
|
30
|
+
Requires-Dist: requests (>=2.32.5,<3.0.0)
|
|
31
|
+
Requires-Dist: sortedcontainers (>=2.4.0,<3.0.0)
|
|
32
|
+
Requires-Dist: tqdm (>=4.67.1,<5.0.0)
|
|
33
|
+
Requires-Dist: unidecode (>=1.4.0,<2.0.0)
|
|
34
|
+
Project-URL: Documentation, https://stone-home.github.io/Python-URes/
|
|
35
|
+
Project-URL: Homepage, https://stone-home.github.io/Python-URes/
|
|
36
|
+
Project-URL: Repository, https://github.com/stone-home/Python-URes
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
# Utility for Research (URes)
|
|
40
|
+
|
|
41
|
+
[](https://github.com/stone-home/Python-URes)
|
|
42
|
+
[](https://github.com/pre-commit/pre-commit)
|
|
43
|
+
[](https://github.com/psf/black)
|
|
44
|
+
[](https://github.com/stone-home/Python-URes/blob/main/LICENSE)
|
|
45
|
+
[](https://github.com/stone-home/Python-URes/actions/workflows/linter.yaml)
|
|
46
|
+
[](https://github.com/stone-home/Python-URes/actions/workflows/secret-check.yaml)
|
|
47
|
+
[](https://github.com/stone-home/Python-URes/actions/workflows/test.yaml)
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Overview
|
|
52
|
+
|
|
53
|
+
URes (Utility for Research) is a Python library that centralizes **reusable utilities for research and development**. It provides batteries-included helpers for Docker workflows, Markdown and Zettelkasten notes, data structures, filesystem and network tasks, time/date conversion, string manipulation, and more.
|
|
54
|
+
|
|
55
|
+
## Key Features
|
|
56
|
+
|
|
57
|
+
- **Docker management**: Build, run, and orchestrate Docker images and containers with structured configuration objects.
|
|
58
|
+
- **Markdown & Zettelkasten**: Work with Markdown files and front matter, and manage Zettelkasten-style notes with required metadata.
|
|
59
|
+
- **Data structures**: Use tree and bi-directional link structures for organizing and traversing complex data.
|
|
60
|
+
- **Core utilities**: File, time/date, string, secrets, and network helpers used across projects.
|
|
61
|
+
- **Literature tooling**: Search across literature sources and manage citation data (when those modules are enabled).
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install ures
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Modules
|
|
72
|
+
|
|
73
|
+
### Docker
|
|
74
|
+
|
|
75
|
+
The `ures.docker` module provides a high-level interface for managing Docker images and containers.
|
|
76
|
+
|
|
77
|
+
**Key Features**:
|
|
78
|
+
|
|
79
|
+
- Programmatically build Docker images from a `BuildConfig` object.
|
|
80
|
+
- Run containers with detailed runtime configurations using `RuntimeConfig`.
|
|
81
|
+
- Orchestrate the building of multiple images with dependencies using `ImageOrchestrator`.
|
|
82
|
+
|
|
83
|
+
**Example**:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from ures.docker import Image, BuildConfig, Containers
|
|
87
|
+
|
|
88
|
+
# Define build configuration
|
|
89
|
+
build_config = BuildConfig(
|
|
90
|
+
base_image="python:3.10-slim",
|
|
91
|
+
python_dependencies=["flask", "gunicorn"],
|
|
92
|
+
copies=[{"src": "./app", "dest": "/app"}],
|
|
93
|
+
entrypoint=["gunicorn", "-b", "0.0.0.0:80", "app:app"]
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Build the image
|
|
97
|
+
image = Image("my-web-app")
|
|
98
|
+
image.build_image(build_config, dest=".")
|
|
99
|
+
|
|
100
|
+
# Run the container
|
|
101
|
+
containers = Containers(image)
|
|
102
|
+
container = containers.create()
|
|
103
|
+
containers.run()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Markdown & Zettelkasten
|
|
107
|
+
|
|
108
|
+
The `ures.markdown` module offers tools for working with Markdown files, including YAML front matter. The `Zettelkasten` class builds on this for note-taking with structured metadata.
|
|
109
|
+
|
|
110
|
+
- `MarkdownDocument`: Load, create, and manipulate Markdown files with front matter.
|
|
111
|
+
- `Zettelkasten`: Create Zettelkasten notes with required fields such as `title`, `type`, and `tags`.
|
|
112
|
+
|
|
113
|
+
### Data structures
|
|
114
|
+
|
|
115
|
+
The `ures.data_structure` module provides reusable data structures:
|
|
116
|
+
|
|
117
|
+
- `TreeNode`: A tree structure with methods for adding, removing, and traversing nodes.
|
|
118
|
+
- `BiDirectional`: A bi-directional linked list for forward and backward traversal.
|
|
119
|
+
|
|
120
|
+
### Core utilities
|
|
121
|
+
|
|
122
|
+
- `ures.files`: File system helpers (recursive file listing, filtering by name, listing directories, creating temp folders).
|
|
123
|
+
- `ures.timedate`: Time/date conversion helpers (datetimes and Unix timestamps to formatted strings, getting the current time).
|
|
124
|
+
- `ures.string`: String utilities such as Zettelkasten-style IDs, unique IDs, memory-size formatting, and capitalization.
|
|
125
|
+
- `ures.secrets`: `SecureKeyManager` for managing API keys and other secrets via different storage methods.
|
|
126
|
+
- `ures.network`: IP and subnet helpers (validation, containment checks, and IP generation from subnets).
|
|
127
|
+
|
|
128
|
+
### Literature tooling (optional)
|
|
129
|
+
|
|
130
|
+
If you use the literature search and citation modules, URes can also help with:
|
|
131
|
+
|
|
132
|
+
- **Literature search**: Configuration-driven multi-source paper search, with adapters and caching.
|
|
133
|
+
- **Literature citation**: Extractors and helpers to manage citation data and apply citation rules.
|
|
134
|
+
|
|
135
|
+
## Development
|
|
136
|
+
|
|
137
|
+
To contribute to URes, please follow these steps:
|
|
138
|
+
|
|
139
|
+
1. Clone the repository:
|
|
140
|
+
```bash
|
|
141
|
+
git clone https://github.com/stone-home/Python-URes.git
|
|
142
|
+
```
|
|
143
|
+
2. Install the dependencies:
|
|
144
|
+
```bash
|
|
145
|
+
cd Python-URes
|
|
146
|
+
poetry install
|
|
147
|
+
```
|
|
148
|
+
3. Run the tests:
|
|
149
|
+
```bash
|
|
150
|
+
poetry run pytest
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
This project is licensed under the MIT License – see the [LICENSE](https://github.com/stone-home/Python-URes/blob/main/LICENSE) file for details.
|
|
156
|
+
|
ures-2.4.0/docs/index.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Utility for Research (URes)
|
|
2
|
+
|
|
3
|
+
[](https://github.com/stone-home/Python-URes)
|
|
4
|
+
[](https://github.com/pre-commit/pre-commit)
|
|
5
|
+
[](https://github.com/psf/black)
|
|
6
|
+
[](https://github.com/stone-home/Python-URes/blob/main/LICENSE)
|
|
7
|
+
[](https://github.com/stone-home/Python-URes/actions/workflows/linter.yaml)
|
|
8
|
+
[](https://github.com/stone-home/Python-URes/actions/workflows/secret-check.yaml)
|
|
9
|
+
[](https://github.com/stone-home/Python-URes/actions/workflows/test.yaml)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
URes (Utility for Research) is a Python library that centralizes **reusable utilities for research and development**. It provides batteries-included helpers for Docker workflows, Markdown and Zettelkasten notes, data structures, filesystem and network tasks, time/date conversion, string manipulation, and more.
|
|
16
|
+
|
|
17
|
+
## Key Features
|
|
18
|
+
|
|
19
|
+
- **Docker management**: Build, run, and orchestrate Docker images and containers with structured configuration objects.
|
|
20
|
+
- **Markdown & Zettelkasten**: Work with Markdown files and front matter, and manage Zettelkasten-style notes with required metadata.
|
|
21
|
+
- **Data structures**: Use tree and bi-directional link structures for organizing and traversing complex data.
|
|
22
|
+
- **Core utilities**: File, time/date, string, secrets, and network helpers used across projects.
|
|
23
|
+
- **Literature tooling**: Search across literature sources and manage citation data (when those modules are enabled).
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install ures
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Modules
|
|
34
|
+
|
|
35
|
+
### Docker
|
|
36
|
+
|
|
37
|
+
The `ures.docker` module provides a high-level interface for managing Docker images and containers.
|
|
38
|
+
|
|
39
|
+
**Key Features**:
|
|
40
|
+
|
|
41
|
+
- Programmatically build Docker images from a `BuildConfig` object.
|
|
42
|
+
- Run containers with detailed runtime configurations using `RuntimeConfig`.
|
|
43
|
+
- Orchestrate the building of multiple images with dependencies using `ImageOrchestrator`.
|
|
44
|
+
|
|
45
|
+
**Example**:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from ures.docker import Image, BuildConfig, Containers
|
|
49
|
+
|
|
50
|
+
# Define build configuration
|
|
51
|
+
build_config = BuildConfig(
|
|
52
|
+
base_image="python:3.10-slim",
|
|
53
|
+
python_dependencies=["flask", "gunicorn"],
|
|
54
|
+
copies=[{"src": "./app", "dest": "/app"}],
|
|
55
|
+
entrypoint=["gunicorn", "-b", "0.0.0.0:80", "app:app"]
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# Build the image
|
|
59
|
+
image = Image("my-web-app")
|
|
60
|
+
image.build_image(build_config, dest=".")
|
|
61
|
+
|
|
62
|
+
# Run the container
|
|
63
|
+
containers = Containers(image)
|
|
64
|
+
container = containers.create()
|
|
65
|
+
containers.run()
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Markdown & Zettelkasten
|
|
69
|
+
|
|
70
|
+
The `ures.markdown` module offers tools for working with Markdown files, including YAML front matter. The `Zettelkasten` class builds on this for note-taking with structured metadata.
|
|
71
|
+
|
|
72
|
+
- `MarkdownDocument`: Load, create, and manipulate Markdown files with front matter.
|
|
73
|
+
- `Zettelkasten`: Create Zettelkasten notes with required fields such as `title`, `type`, and `tags`.
|
|
74
|
+
|
|
75
|
+
### Data structures
|
|
76
|
+
|
|
77
|
+
The `ures.data_structure` module provides reusable data structures:
|
|
78
|
+
|
|
79
|
+
- `TreeNode`: A tree structure with methods for adding, removing, and traversing nodes.
|
|
80
|
+
- `BiDirectional`: A bi-directional linked list for forward and backward traversal.
|
|
81
|
+
|
|
82
|
+
### Core utilities
|
|
83
|
+
|
|
84
|
+
- `ures.files`: File system helpers (recursive file listing, filtering by name, listing directories, creating temp folders).
|
|
85
|
+
- `ures.timedate`: Time/date conversion helpers (datetimes and Unix timestamps to formatted strings, getting the current time).
|
|
86
|
+
- `ures.string`: String utilities such as Zettelkasten-style IDs, unique IDs, memory-size formatting, and capitalization.
|
|
87
|
+
- `ures.secrets`: `SecureKeyManager` for managing API keys and other secrets via different storage methods.
|
|
88
|
+
- `ures.network`: IP and subnet helpers (validation, containment checks, and IP generation from subnets).
|
|
89
|
+
|
|
90
|
+
### Literature tooling (optional)
|
|
91
|
+
|
|
92
|
+
If you use the literature search and citation modules, URes can also help with:
|
|
93
|
+
|
|
94
|
+
- **Literature search**: Configuration-driven multi-source paper search, with adapters and caching.
|
|
95
|
+
- **Literature citation**: Extractors and helpers to manage citation data and apply citation rules.
|
|
96
|
+
|
|
97
|
+
## Development
|
|
98
|
+
|
|
99
|
+
To contribute to URes, please follow these steps:
|
|
100
|
+
|
|
101
|
+
1. Clone the repository:
|
|
102
|
+
```bash
|
|
103
|
+
git clone https://github.com/stone-home/Python-URes.git
|
|
104
|
+
```
|
|
105
|
+
2. Install the dependencies:
|
|
106
|
+
```bash
|
|
107
|
+
cd Python-URes
|
|
108
|
+
poetry install
|
|
109
|
+
```
|
|
110
|
+
3. Run the tests:
|
|
111
|
+
```bash
|
|
112
|
+
poetry run pytest
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## License
|
|
116
|
+
|
|
117
|
+
This project is licensed under the MIT License – see the [LICENSE](https://github.com/stone-home/Python-URes/blob/main/LICENSE) file for details.
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "ures"
|
|
3
|
-
version = "2.
|
|
4
|
-
description = "
|
|
3
|
+
version = "2.4.0"
|
|
4
|
+
description = "Utility library for research and development: Docker workflows, Markdown and Zettelkasten, data structures, and core file/network/string/time helpers."
|
|
5
5
|
authors = ["stone <github@stone-bo.com>"]
|
|
6
6
|
license = "MIT"
|
|
7
7
|
readme = "docs/index.md"
|
|
8
|
+
homepage = "https://stone-home.github.io/Python-URes/"
|
|
9
|
+
documentation = "https://stone-home.github.io/Python-URes/"
|
|
8
10
|
repository = "https://github.com/stone-home/Python-URes"
|
|
9
11
|
keywords = [
|
|
10
12
|
"utilization",
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
import uuid
|
|
3
|
-
from typing import Any, Optional
|
|
3
|
+
from typing import Any, Generic, Optional, TypeVar, cast
|
|
4
4
|
|
|
5
|
+
_BiDirectionT = TypeVar("_BiDirectionT", bound="BiDirection")
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
|
|
8
|
+
class BiDirection(Generic[_BiDirectionT]):
|
|
7
9
|
def __init__(self, value: Any):
|
|
8
10
|
"""
|
|
9
11
|
Create a bi-directional linked node.
|
|
@@ -26,13 +28,13 @@ class BiDirection:
|
|
|
26
28
|
>>> node.next is node
|
|
27
29
|
True
|
|
28
30
|
"""
|
|
29
|
-
self._prev:
|
|
30
|
-
self._next:
|
|
31
|
+
self._prev: _BiDirectionT = cast(_BiDirectionT, self)
|
|
32
|
+
self._next: _BiDirectionT = cast(_BiDirectionT, self)
|
|
31
33
|
self._value: Any = value
|
|
32
34
|
self._id = uuid.uuid4().hex
|
|
33
35
|
|
|
34
36
|
@property
|
|
35
|
-
def prev(self) ->
|
|
37
|
+
def prev(self) -> _BiDirectionT:
|
|
36
38
|
"""
|
|
37
39
|
Get the previous node in the linked structure.
|
|
38
40
|
|
|
@@ -47,7 +49,7 @@ class BiDirection:
|
|
|
47
49
|
return self._prev
|
|
48
50
|
|
|
49
51
|
@property
|
|
50
|
-
def next(self) ->
|
|
52
|
+
def next(self) -> _BiDirectionT:
|
|
51
53
|
"""
|
|
52
54
|
Get the next node in the linked structure.
|
|
53
55
|
|
|
@@ -91,7 +93,7 @@ class BiDirection:
|
|
|
91
93
|
"""
|
|
92
94
|
return self._id
|
|
93
95
|
|
|
94
|
-
def insert_after(self, node:
|
|
96
|
+
def insert_after(self, node: _BiDirectionT) -> None:
|
|
95
97
|
"""
|
|
96
98
|
Insert a node immediately after the current node.
|
|
97
99
|
|
|
@@ -117,7 +119,7 @@ class BiDirection:
|
|
|
117
119
|
self._next._prev = node
|
|
118
120
|
self._next = node
|
|
119
121
|
|
|
120
|
-
def insert_before(self, node:
|
|
122
|
+
def insert_before(self, node: _BiDirectionT) -> None:
|
|
121
123
|
"""
|
|
122
124
|
Insert a node immediately before the current node.
|
|
123
125
|
|
|
@@ -163,10 +165,10 @@ class BiDirection:
|
|
|
163
165
|
"""
|
|
164
166
|
self._prev._next = self._next
|
|
165
167
|
self._next._prev = self._prev
|
|
166
|
-
self._prev = self
|
|
167
|
-
self._next = self
|
|
168
|
+
self._prev = cast(_BiDirectionT, self)
|
|
169
|
+
self._next = cast(_BiDirectionT, self)
|
|
168
170
|
|
|
169
|
-
def search(self, value: Any) -> Optional[
|
|
171
|
+
def search(self, value: Any) -> Optional[_BiDirectionT]:
|
|
170
172
|
"""
|
|
171
173
|
Search for a node with the specified value in the linked structure.
|
|
172
174
|
|
|
@@ -192,12 +194,12 @@ class BiDirection:
|
|
|
192
194
|
>>> not_found is None
|
|
193
195
|
True
|
|
194
196
|
"""
|
|
195
|
-
node = self
|
|
197
|
+
node: _BiDirectionT = cast(_BiDirectionT, self)
|
|
196
198
|
while node.value != value and node.next != self:
|
|
197
199
|
node = node.next
|
|
198
200
|
return node if node.value == value else None
|
|
199
201
|
|
|
200
|
-
def __eq__(self, other:
|
|
202
|
+
def __eq__(self, other: _BiDirectionT) -> bool:
|
|
201
203
|
"""
|
|
202
204
|
Check equality between two nodes based on their unique IDs.
|
|
203
205
|
|
|
@@ -246,7 +248,7 @@ class BiDirection:
|
|
|
246
248
|
return f"BiDirection({self.value})"
|
|
247
249
|
|
|
248
250
|
|
|
249
|
-
class NonCircularBiLink(BiDirection):
|
|
251
|
+
class NonCircularBiLink(BiDirection["NonCircularBiLink"]):
|
|
250
252
|
__slots__ = ("_prev", "_next", "_value")
|
|
251
253
|
|
|
252
254
|
def __init__(self, value: Any):
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
import uuid
|
|
3
|
-
from typing import Any,
|
|
3
|
+
from typing import Any, Iterator, Generic, TypeVar, cast
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
_TreeNodeT = TypeVar("_TreeNodeT", bound="TreeNode")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TreeNode(Generic[_TreeNodeT]):
|
|
7
10
|
def __init__(self, value: Any):
|
|
8
11
|
"""
|
|
9
12
|
Initialize a TreeNode instance.
|
|
@@ -15,22 +18,22 @@ class TreeNode:
|
|
|
15
18
|
None
|
|
16
19
|
|
|
17
20
|
Example:
|
|
18
|
-
>>> node =
|
|
21
|
+
>>> node = _TreeNodeT("root")
|
|
19
22
|
>>> node.value
|
|
20
23
|
'root'
|
|
21
24
|
"""
|
|
22
|
-
self._parent:
|
|
23
|
-
self._children:
|
|
25
|
+
self._parent: _TreeNodeT | None = None
|
|
26
|
+
self._children: dict[str, _TreeNodeT] = {}
|
|
24
27
|
self._value: Any = value
|
|
25
28
|
self._id = uuid.uuid4().hex
|
|
26
29
|
|
|
27
30
|
@property
|
|
28
|
-
def parent(self) ->
|
|
31
|
+
def parent(self) -> _TreeNodeT | None:
|
|
29
32
|
"""
|
|
30
33
|
Get the parent node of this TreeNode.
|
|
31
34
|
|
|
32
35
|
Returns:
|
|
33
|
-
Optional[
|
|
36
|
+
Optional[_TreeNodeT]: The parent node if it exists; otherwise, None.
|
|
34
37
|
|
|
35
38
|
Example:
|
|
36
39
|
>>> root = TreeNode("root")
|
|
@@ -42,12 +45,12 @@ class TreeNode:
|
|
|
42
45
|
return self._parent
|
|
43
46
|
|
|
44
47
|
@property
|
|
45
|
-
def children(self) ->
|
|
48
|
+
def children(self) -> dict[str, _TreeNodeT]:
|
|
46
49
|
"""
|
|
47
50
|
Get the dictionary of child nodes.
|
|
48
51
|
|
|
49
52
|
Returns:
|
|
50
|
-
|
|
53
|
+
dict[str, _TreeNodeT]: A dictionary mapping each child's unique ID to its TreeNode instance.
|
|
51
54
|
|
|
52
55
|
Example:
|
|
53
56
|
>>> root = TreeNode("root")
|
|
@@ -103,7 +106,7 @@ class TreeNode:
|
|
|
103
106
|
"""
|
|
104
107
|
return self._id
|
|
105
108
|
|
|
106
|
-
def add_child(self, child:
|
|
109
|
+
def add_child(self, child: _TreeNodeT):
|
|
107
110
|
"""
|
|
108
111
|
Add a child node to the current node.
|
|
109
112
|
|
|
@@ -123,7 +126,7 @@ class TreeNode:
|
|
|
123
126
|
>>> child.parent is root
|
|
124
127
|
True
|
|
125
128
|
"""
|
|
126
|
-
if child.id not in self.children
|
|
129
|
+
if child.id not in self.children:
|
|
127
130
|
self._children[child.id] = child
|
|
128
131
|
child.set_parent(self)
|
|
129
132
|
|
|
@@ -148,11 +151,11 @@ class TreeNode:
|
|
|
148
151
|
>>> child.parent is None
|
|
149
152
|
True
|
|
150
153
|
"""
|
|
151
|
-
if child.id in self.children
|
|
154
|
+
if child.id in self.children:
|
|
152
155
|
self._children.pop(child.id)
|
|
153
156
|
child.set_parent(None)
|
|
154
157
|
|
|
155
|
-
def set_parent(self, parent:
|
|
158
|
+
def set_parent(self, parent: _TreeNodeT | None):
|
|
156
159
|
"""
|
|
157
160
|
Set the parent of the current node.
|
|
158
161
|
|
|
@@ -160,7 +163,7 @@ class TreeNode:
|
|
|
160
163
|
the new parent.
|
|
161
164
|
|
|
162
165
|
Args:
|
|
163
|
-
parent (
|
|
166
|
+
parent (TreeNode | None): The new parent node. If None, the node will have no parent.
|
|
164
167
|
|
|
165
168
|
Returns:
|
|
166
169
|
None
|
|
@@ -199,7 +202,7 @@ class TreeNode:
|
|
|
199
202
|
yield current
|
|
200
203
|
current = current.parent
|
|
201
204
|
|
|
202
|
-
def forward_stack(self, **kwargs) ->
|
|
205
|
+
def forward_stack(self, **kwargs) -> list[list[Any]]:
|
|
203
206
|
"""
|
|
204
207
|
Get all forward paths from the current node to each leaf node.
|
|
205
208
|
|
|
@@ -211,7 +214,7 @@ class TreeNode:
|
|
|
211
214
|
attr (str, optional): The attribute name to extract from each node. Defaults to None.
|
|
212
215
|
|
|
213
216
|
Returns:
|
|
214
|
-
|
|
217
|
+
list[list[Any]]: A list of paths, where each path is a list of nodes or attribute values from the
|
|
215
218
|
current node to a leaf node.
|
|
216
219
|
|
|
217
220
|
Example:
|
|
@@ -225,10 +228,10 @@ class TreeNode:
|
|
|
225
228
|
[['child1', 'root'], ['child2', 'root']] # Order may vary
|
|
226
229
|
"""
|
|
227
230
|
all_paths = []
|
|
228
|
-
self._dfs(self, [], all_paths, **kwargs)
|
|
231
|
+
self._dfs(cast(_TreeNodeT, self), [], all_paths, **kwargs)
|
|
229
232
|
return all_paths
|
|
230
233
|
|
|
231
|
-
def _dfs(self, node:
|
|
234
|
+
def _dfs(self, node: _TreeNodeT, current_path: list, all_paths: list, **kwargs):
|
|
232
235
|
"""
|
|
233
236
|
Recursively perform depth-first search (DFS) to find all paths from the given node to leaf nodes.
|
|
234
237
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import logging
|
|
1
2
|
import os
|
|
2
3
|
import tempfile
|
|
3
|
-
from typing import List, Optional
|
|
4
4
|
|
|
5
|
+
logger = logging.getLogger(__name__)
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
|
|
8
|
+
def get_file_paths(directory: str) -> list[str]:
|
|
7
9
|
"""
|
|
8
10
|
Retrieve all file paths within the specified directory and its subdirectories.
|
|
9
11
|
|
|
@@ -14,7 +16,7 @@ def get_file_paths(directory: str) -> List[str]:
|
|
|
14
16
|
directory (str): The directory path to search in.
|
|
15
17
|
|
|
16
18
|
Returns:
|
|
17
|
-
|
|
19
|
+
list[str]: A list containing the absolute paths of all files found.
|
|
18
20
|
|
|
19
21
|
Example:
|
|
20
22
|
>>> paths = get_file_paths("/path/to/directory")
|
|
@@ -31,7 +33,7 @@ def get_file_paths(directory: str) -> List[str]:
|
|
|
31
33
|
return file_paths
|
|
32
34
|
|
|
33
35
|
|
|
34
|
-
def filter_files(part_file_name: str, directory: str, fuzz: bool = True) ->
|
|
36
|
+
def filter_files(part_file_name: str, directory: str, fuzz: bool = True) -> list[str]:
|
|
35
37
|
"""
|
|
36
38
|
Retrieve file paths in the specified directory that match a given file name pattern.
|
|
37
39
|
|
|
@@ -46,7 +48,7 @@ def filter_files(part_file_name: str, directory: str, fuzz: bool = True) -> List
|
|
|
46
48
|
returns only files with an exact name match. Defaults to True.
|
|
47
49
|
|
|
48
50
|
Returns:
|
|
49
|
-
|
|
51
|
+
list[str]: A list of file paths that match the search criteria.
|
|
50
52
|
|
|
51
53
|
Example:
|
|
52
54
|
>>> # Assuming "/tmp/test" contains files "example.txt" and "sample.txt"
|
|
@@ -69,7 +71,7 @@ def filter_files(part_file_name: str, directory: str, fuzz: bool = True) -> List
|
|
|
69
71
|
]
|
|
70
72
|
|
|
71
73
|
|
|
72
|
-
def list_directories(path: str) ->
|
|
74
|
+
def list_directories(path: str) -> list[str] | None:
|
|
73
75
|
"""
|
|
74
76
|
List all subdirectories in the specified path.
|
|
75
77
|
|
|
@@ -80,16 +82,15 @@ def list_directories(path: str) -> Optional[List[str]]:
|
|
|
80
82
|
path (str): The path where directories should be listed.
|
|
81
83
|
|
|
82
84
|
Returns:
|
|
83
|
-
|
|
85
|
+
list[str] | None: A list of directory names if the path exists; otherwise, None.
|
|
84
86
|
|
|
85
87
|
Example:
|
|
86
88
|
>>> dirs = list_directories("/tmp")
|
|
87
89
|
>>> isinstance(dirs, list) or dirs is None
|
|
88
90
|
True
|
|
89
91
|
"""
|
|
90
|
-
# Ensure the path exists.
|
|
91
92
|
if not os.path.exists(path):
|
|
92
|
-
|
|
93
|
+
logger.warning("The specified path does not exist: %s", path)
|
|
93
94
|
return None
|
|
94
95
|
|
|
95
96
|
# List all entries in the path.
|
|
@@ -186,7 +186,7 @@ class TypeNormalizationMiddleware(CitationMiddleware):
|
|
|
186
186
|
"""Normalize entry types (conference -> inproceedings, etc.)"""
|
|
187
187
|
|
|
188
188
|
def transform_entry(self, entry: Entry, *args, **kwargs) -> Entry:
|
|
189
|
-
new_type = self.rule_register.
|
|
189
|
+
new_type = self.rule_register.get_default_bib_type_mapping().get(
|
|
190
190
|
entry.entry_type.lower(), entry.entry_type
|
|
191
191
|
)
|
|
192
192
|
entry.entry_type = new_type
|
|
@@ -29,7 +29,7 @@ class BibRuleRegister:
|
|
|
29
29
|
"langid": "language",
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
def
|
|
32
|
+
def get_default_bib_type_mapping(self) -> Dict[str, str]:
|
|
33
33
|
return {
|
|
34
34
|
"conference": "inproceedings",
|
|
35
35
|
"incollection": "inproceedings", # Some publishers treat book chapters as conf papers
|
|
@@ -84,7 +84,8 @@ class Zettelkasten(MarkdownDocument):
|
|
|
84
84
|
|
|
85
85
|
_params = dict(post.metadata)
|
|
86
86
|
n_type = _params.get("type", None)
|
|
87
|
-
|
|
87
|
+
if n_type is not None:
|
|
88
|
+
del _params["type"]
|
|
88
89
|
_params["n_type"] = n_type
|
|
89
90
|
|
|
90
91
|
keywords = ["title", "n_type", "url", "tags", "aliases"]
|
|
@@ -39,7 +39,7 @@ def unique_id() -> str:
|
|
|
39
39
|
return uuid.uuid4().hex
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
def format_memory(nbytes: int) -> str:
|
|
42
|
+
def format_memory(nbytes: int | None) -> str:
|
|
43
43
|
"""
|
|
44
44
|
Format a memory size into a human-readable string.
|
|
45
45
|
|
|
@@ -47,7 +47,7 @@ def format_memory(nbytes: int) -> str:
|
|
|
47
47
|
with two decimal places of precision. If the provided value is None, it returns "0 bytes".
|
|
48
48
|
|
|
49
49
|
Args:
|
|
50
|
-
nbytes (int): The memory size in bytes.
|
|
50
|
+
nbytes (int | None): The memory size in bytes, or None for "0 bytes".
|
|
51
51
|
|
|
52
52
|
Returns:
|
|
53
53
|
str: The memory size in a human-readable format.
|
|
@@ -98,7 +98,7 @@ def capitalize_string(string: str, separator: str = " ") -> str:
|
|
|
98
98
|
return separator.join([item.capitalize() for item in string.split(separator)])
|
|
99
99
|
|
|
100
100
|
|
|
101
|
-
def string2date(date_string) -> dict[str, int | str | None]:
|
|
101
|
+
def string2date(date_string: str) -> dict[str, int | str | None]:
|
|
102
102
|
"""
|
|
103
103
|
Parses various date string formats ('YYYY', 'YYYY-MM', 'YYYY-MM-DD')
|
|
104
104
|
and returns a dictionary with the month as a three-letter abbreviation.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import datetime
|
|
2
|
+
import sys
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
def datetime_converter(
|
|
@@ -99,8 +100,6 @@ def time_now(iso8601: bool = True, format: str = "%Y%m%d-%H%M%S") -> str:
|
|
|
99
100
|
>>> time_now(iso8601=False, format="%H:%M:%S")
|
|
100
101
|
'14:35:22'
|
|
101
102
|
"""
|
|
102
|
-
import sys
|
|
103
|
-
|
|
104
103
|
if sys.version_info[:2] == (3, 10):
|
|
105
104
|
_time = datetime.datetime.now(datetime.timezone.utc)
|
|
106
105
|
else:
|
|
@@ -136,7 +136,7 @@ class EnumManipulator:
|
|
|
136
136
|
return member.value
|
|
137
137
|
return None
|
|
138
138
|
|
|
139
|
-
def filter_by(self, keyword: str, field: str = None) -> list:
|
|
139
|
+
def filter_by(self, keyword: str, field: str | None = None) -> list:
|
|
140
140
|
"""
|
|
141
141
|
Filter and return keys from the Enum where the specified keyword matches.
|
|
142
142
|
|
ures-2.3.0/PKG-INFO
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: ures
|
|
3
|
-
Version: 2.3.0
|
|
4
|
-
Summary: The project is designed to provide standard utilization functions for improving the reusability of frequently used functions.
|
|
5
|
-
License: MIT
|
|
6
|
-
Keywords: utilization,Research Tool,Python
|
|
7
|
-
Author: stone
|
|
8
|
-
Author-email: github@stone-bo.com
|
|
9
|
-
Requires-Python: >=3.11,<4.0
|
|
10
|
-
Classifier: Development Status :: 1 - Planning
|
|
11
|
-
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
-
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
18
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
-
Classifier: Topic :: Utilities
|
|
20
|
-
Requires-Dist: beautifulsoup4 (>=4.13.4,<5.0.0)
|
|
21
|
-
Requires-Dist: bibtexparser (>=2.0.0b8,<3.0.0)
|
|
22
|
-
Requires-Dist: docker (>=7.1.0,<8.0.0)
|
|
23
|
-
Requires-Dist: onepassword-sdk (>=0.3.1,<0.4.0)
|
|
24
|
-
Requires-Dist: pycountry (>=24.6.1,<25.0.0)
|
|
25
|
-
Requires-Dist: pydantic (>=2.10.6,<3.0.0)
|
|
26
|
-
Requires-Dist: pyperclip (>=1.9.0,<2.0.0)
|
|
27
|
-
Requires-Dist: python-frontmatter (>=1.1.0,<2.0.0)
|
|
28
|
-
Requires-Dist: requests (>=2.32.5,<3.0.0)
|
|
29
|
-
Requires-Dist: sortedcontainers (>=2.4.0,<3.0.0)
|
|
30
|
-
Requires-Dist: tqdm (>=4.67.1,<5.0.0)
|
|
31
|
-
Requires-Dist: unidecode (>=1.4.0,<2.0.0)
|
|
32
|
-
Project-URL: Repository, https://github.com/stone-home/Python-URes
|
|
33
|
-
Description-Content-Type: text/markdown
|
|
34
|
-
|
|
35
|
-
# Utility for Research (URes)
|
|
36
|
-
|
|
37
|
-
[](https://github.com/semantic-release/semantic-release)
|
|
38
|
-
[](https://github.com/pre-commit/pre-commit)
|
|
39
|
-
[](https://github.com/psf/black)
|
|
40
|
-
[](https://opensource.org/licenses/MIT)
|
|
41
|
-
[](https://github.com/stone-home/Python-URes/actions/workflows/linter.yaml)
|
|
42
|
-
[](https://github.com/stone-home/Python-URes/actions/workflows/secret-check.yaml)
|
|
43
|
-
[](https://github.com/stone-home/Python-URes/actions/workflows/test.yaml)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
## Overview
|
|
48
|
-
|
|
49
|
-
URes (Utility for Research) is a versatile Python library that simplifies common research and development tasks. It offers a wide range of modules to handle everything from Docker container management to advanced data visualization and file operations.
|
|
50
|
-
|
|
51
|
-
## Key Features
|
|
52
|
-
|
|
53
|
-
- **Docker Management**: Build, run, and manage Docker images and containers with an intuitive Python interface.
|
|
54
|
-
- **Markdown and Zettelkasten**: Create, manipulate, and organize Markdown documents, with support for the Zettelkasten note-taking method.
|
|
55
|
-
- **Data Structures**: Implement and use advanced data structures like Trees and Bi-Directional Links for complex data organization.
|
|
56
|
-
- **File and Network Utilities**: Simplify file system operations and network-related tasks with a collection of helper functions.
|
|
57
|
-
- **Time and Date Converters**: Easily convert between different time and date formats, including ISO 8601 and Unix timestamps.
|
|
58
|
-
- **String Manipulation**: A set of functions for common string operations, such as capitalization and unique ID generation.
|
|
59
|
-
- **Advanced Plotting**: A comprehensive, multi-backend visualization library for scientific research, data analysis, and machine learning.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
## Installation
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
pip install ures
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Modules
|
|
69
|
-
|
|
70
|
-
### Docker
|
|
71
|
-
|
|
72
|
-
The `ures.docker` module provides a high-level interface for managing Docker images and containers.
|
|
73
|
-
|
|
74
|
-
**Key Features**:
|
|
75
|
-
|
|
76
|
-
- Programmatically build Docker images from a `BuildConfig` object.
|
|
77
|
-
- Run containers with detailed runtime configurations using `RuntimeConfig`.
|
|
78
|
-
- Orchestrate the building of multiple images with dependencies using `ImageOrchestrator`.
|
|
79
|
-
|
|
80
|
-
**Example**:
|
|
81
|
-
|
|
82
|
-
```python
|
|
83
|
-
from ures.docker import Image, BuildConfig, Containers
|
|
84
|
-
|
|
85
|
-
# Define build configuration
|
|
86
|
-
build_config = BuildConfig(
|
|
87
|
-
base_image="python:3.10-slim",
|
|
88
|
-
python_dependencies=["flask", "gunicorn"],
|
|
89
|
-
copies=[{"src": "./app", "dest": "/app"}],
|
|
90
|
-
entrypoint=["gunicorn", "-b", "0.0.0.0:80", "app:app"]
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
# Build the image
|
|
94
|
-
image = Image("my-web-app")
|
|
95
|
-
image.build_image(build_config, dest=".")
|
|
96
|
-
|
|
97
|
-
# Run the container
|
|
98
|
-
containers = Containers(image)
|
|
99
|
-
container = containers.create()
|
|
100
|
-
containers.run()
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Markdown
|
|
104
|
-
|
|
105
|
-
The `ures.markdown` module offers tools for working with Markdown files, including those with YAML front matter. The `Zettelkasten` class extends this functionality for note-taking.
|
|
106
|
-
|
|
107
|
-
**Key Features**:
|
|
108
|
-
|
|
109
|
-
- Load, create, and manipulate Markdown files with `MarkdownDocument`.
|
|
110
|
-
- Manage YAML front matter with support for nested keys.
|
|
111
|
-
- Implement the Zettelkasten method with the `Zettelkasten` class, which includes mandatory metadata fields like `title`, `type`, and `tags`.
|
|
112
|
-
|
|
113
|
-
**Example**:
|
|
114
|
-
|
|
115
|
-
```python
|
|
116
|
-
from ures.markdown import Zettelkasten
|
|
117
|
-
|
|
118
|
-
# Create a new Zettelkasten note
|
|
119
|
-
note = Zettelkasten(
|
|
120
|
-
title="My Research Note",
|
|
121
|
-
n_type="permanent",
|
|
122
|
-
tags=["research", "python"],
|
|
123
|
-
aliases=["research-note"]
|
|
124
|
-
)
|
|
125
|
-
|
|
126
|
-
# Add content
|
|
127
|
-
note.add_content("This is a sample research note.")
|
|
128
|
-
|
|
129
|
-
# Save to file
|
|
130
|
-
note.save("my_note.md")
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### Data Structures
|
|
134
|
-
|
|
135
|
-
The `ures.data_structure` module provides implementations of advanced data structures.
|
|
136
|
-
|
|
137
|
-
- **TreeNode**: A tree data structure with methods for adding, removing, and traversing nodes.
|
|
138
|
-
- **BiDirectional**: A bi-directional linked list that allows for easy traversal in both forward and backward directions.
|
|
139
|
-
|
|
140
|
-
### File and Network Utilities
|
|
141
|
-
|
|
142
|
-
- **`ures.files`**: A collection of functions for file system operations, such as recursively getting file paths, filtering files, and managing temporary directories.
|
|
143
|
-
- **`ures.network`**: Helper functions for network-related tasks, including IP address validation and generation.
|
|
144
|
-
|
|
145
|
-
### Time and Date Converters
|
|
146
|
-
|
|
147
|
-
The `ures.timedate` module provides functions for converting between different time and date formats.
|
|
148
|
-
|
|
149
|
-
- `datetime_converter()`: Converts a `datetime` object to a formatted string (ISO 8601 or custom).
|
|
150
|
-
- `timestamp_converter()`: Converts a Unix timestamp to a formatted string.
|
|
151
|
-
- `time_now()`: Returns the current time as a formatted string.
|
|
152
|
-
|
|
153
|
-
### String Manipulation
|
|
154
|
-
|
|
155
|
-
The `ures.string` module offers a variety of string utility functions.
|
|
156
|
-
|
|
157
|
-
- `zettelkasten_id()`: Generates a unique ID suitable for Zettelkasten notes.
|
|
158
|
-
- `unique_id()`: Creates a standard unique identifier.
|
|
159
|
-
- `format_memory()`: Formats a memory size into a human-readable string.
|
|
160
|
-
- `capitalize_string()`: Capitalizes each word in a string.
|
|
161
|
-
|
|
162
|
-
## Development
|
|
163
|
-
|
|
164
|
-
To contribute to URes, please follow these steps:
|
|
165
|
-
|
|
166
|
-
1. Clone the repository:
|
|
167
|
-
```bash
|
|
168
|
-
git clone https://github.com/stone-home/Python-URes.git
|
|
169
|
-
```
|
|
170
|
-
2. Install the dependencies:
|
|
171
|
-
```bash
|
|
172
|
-
cd Python-URes
|
|
173
|
-
poetry install
|
|
174
|
-
```
|
|
175
|
-
3. Run the tests:
|
|
176
|
-
```bash
|
|
177
|
-
poetry run pytest
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
## License
|
|
181
|
-
|
|
182
|
-
This project is licensed under the MIT License - see the [LICENSE](https://www.google.com/search?q=LICENSE) file for details.
|
|
183
|
-
|
ures-2.3.0/docs/index.md
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
# Utility for Research (URes)
|
|
2
|
-
|
|
3
|
-
[](https://github.com/semantic-release/semantic-release)
|
|
4
|
-
[](https://github.com/pre-commit/pre-commit)
|
|
5
|
-
[](https://github.com/psf/black)
|
|
6
|
-
[](https://opensource.org/licenses/MIT)
|
|
7
|
-
[](https://github.com/stone-home/Python-URes/actions/workflows/linter.yaml)
|
|
8
|
-
[](https://github.com/stone-home/Python-URes/actions/workflows/secret-check.yaml)
|
|
9
|
-
[](https://github.com/stone-home/Python-URes/actions/workflows/test.yaml)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
## Overview
|
|
14
|
-
|
|
15
|
-
URes (Utility for Research) is a versatile Python library that simplifies common research and development tasks. It offers a wide range of modules to handle everything from Docker container management to advanced data visualization and file operations.
|
|
16
|
-
|
|
17
|
-
## Key Features
|
|
18
|
-
|
|
19
|
-
- **Docker Management**: Build, run, and manage Docker images and containers with an intuitive Python interface.
|
|
20
|
-
- **Markdown and Zettelkasten**: Create, manipulate, and organize Markdown documents, with support for the Zettelkasten note-taking method.
|
|
21
|
-
- **Data Structures**: Implement and use advanced data structures like Trees and Bi-Directional Links for complex data organization.
|
|
22
|
-
- **File and Network Utilities**: Simplify file system operations and network-related tasks with a collection of helper functions.
|
|
23
|
-
- **Time and Date Converters**: Easily convert between different time and date formats, including ISO 8601 and Unix timestamps.
|
|
24
|
-
- **String Manipulation**: A set of functions for common string operations, such as capitalization and unique ID generation.
|
|
25
|
-
- **Advanced Plotting**: A comprehensive, multi-backend visualization library for scientific research, data analysis, and machine learning.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
## Installation
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
pip install ures
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Modules
|
|
35
|
-
|
|
36
|
-
### Docker
|
|
37
|
-
|
|
38
|
-
The `ures.docker` module provides a high-level interface for managing Docker images and containers.
|
|
39
|
-
|
|
40
|
-
**Key Features**:
|
|
41
|
-
|
|
42
|
-
- Programmatically build Docker images from a `BuildConfig` object.
|
|
43
|
-
- Run containers with detailed runtime configurations using `RuntimeConfig`.
|
|
44
|
-
- Orchestrate the building of multiple images with dependencies using `ImageOrchestrator`.
|
|
45
|
-
|
|
46
|
-
**Example**:
|
|
47
|
-
|
|
48
|
-
```python
|
|
49
|
-
from ures.docker import Image, BuildConfig, Containers
|
|
50
|
-
|
|
51
|
-
# Define build configuration
|
|
52
|
-
build_config = BuildConfig(
|
|
53
|
-
base_image="python:3.10-slim",
|
|
54
|
-
python_dependencies=["flask", "gunicorn"],
|
|
55
|
-
copies=[{"src": "./app", "dest": "/app"}],
|
|
56
|
-
entrypoint=["gunicorn", "-b", "0.0.0.0:80", "app:app"]
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
# Build the image
|
|
60
|
-
image = Image("my-web-app")
|
|
61
|
-
image.build_image(build_config, dest=".")
|
|
62
|
-
|
|
63
|
-
# Run the container
|
|
64
|
-
containers = Containers(image)
|
|
65
|
-
container = containers.create()
|
|
66
|
-
containers.run()
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### Markdown
|
|
70
|
-
|
|
71
|
-
The `ures.markdown` module offers tools for working with Markdown files, including those with YAML front matter. The `Zettelkasten` class extends this functionality for note-taking.
|
|
72
|
-
|
|
73
|
-
**Key Features**:
|
|
74
|
-
|
|
75
|
-
- Load, create, and manipulate Markdown files with `MarkdownDocument`.
|
|
76
|
-
- Manage YAML front matter with support for nested keys.
|
|
77
|
-
- Implement the Zettelkasten method with the `Zettelkasten` class, which includes mandatory metadata fields like `title`, `type`, and `tags`.
|
|
78
|
-
|
|
79
|
-
**Example**:
|
|
80
|
-
|
|
81
|
-
```python
|
|
82
|
-
from ures.markdown import Zettelkasten
|
|
83
|
-
|
|
84
|
-
# Create a new Zettelkasten note
|
|
85
|
-
note = Zettelkasten(
|
|
86
|
-
title="My Research Note",
|
|
87
|
-
n_type="permanent",
|
|
88
|
-
tags=["research", "python"],
|
|
89
|
-
aliases=["research-note"]
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
# Add content
|
|
93
|
-
note.add_content("This is a sample research note.")
|
|
94
|
-
|
|
95
|
-
# Save to file
|
|
96
|
-
note.save("my_note.md")
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### Data Structures
|
|
100
|
-
|
|
101
|
-
The `ures.data_structure` module provides implementations of advanced data structures.
|
|
102
|
-
|
|
103
|
-
- **TreeNode**: A tree data structure with methods for adding, removing, and traversing nodes.
|
|
104
|
-
- **BiDirectional**: A bi-directional linked list that allows for easy traversal in both forward and backward directions.
|
|
105
|
-
|
|
106
|
-
### File and Network Utilities
|
|
107
|
-
|
|
108
|
-
- **`ures.files`**: A collection of functions for file system operations, such as recursively getting file paths, filtering files, and managing temporary directories.
|
|
109
|
-
- **`ures.network`**: Helper functions for network-related tasks, including IP address validation and generation.
|
|
110
|
-
|
|
111
|
-
### Time and Date Converters
|
|
112
|
-
|
|
113
|
-
The `ures.timedate` module provides functions for converting between different time and date formats.
|
|
114
|
-
|
|
115
|
-
- `datetime_converter()`: Converts a `datetime` object to a formatted string (ISO 8601 or custom).
|
|
116
|
-
- `timestamp_converter()`: Converts a Unix timestamp to a formatted string.
|
|
117
|
-
- `time_now()`: Returns the current time as a formatted string.
|
|
118
|
-
|
|
119
|
-
### String Manipulation
|
|
120
|
-
|
|
121
|
-
The `ures.string` module offers a variety of string utility functions.
|
|
122
|
-
|
|
123
|
-
- `zettelkasten_id()`: Generates a unique ID suitable for Zettelkasten notes.
|
|
124
|
-
- `unique_id()`: Creates a standard unique identifier.
|
|
125
|
-
- `format_memory()`: Formats a memory size into a human-readable string.
|
|
126
|
-
- `capitalize_string()`: Capitalizes each word in a string.
|
|
127
|
-
|
|
128
|
-
## Development
|
|
129
|
-
|
|
130
|
-
To contribute to URes, please follow these steps:
|
|
131
|
-
|
|
132
|
-
1. Clone the repository:
|
|
133
|
-
```bash
|
|
134
|
-
git clone https://github.com/stone-home/Python-URes.git
|
|
135
|
-
```
|
|
136
|
-
2. Install the dependencies:
|
|
137
|
-
```bash
|
|
138
|
-
cd Python-URes
|
|
139
|
-
poetry install
|
|
140
|
-
```
|
|
141
|
-
3. Run the tests:
|
|
142
|
-
```bash
|
|
143
|
-
poetry run pytest
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## License
|
|
147
|
-
|
|
148
|
-
This project is licensed under the MIT License - see the [LICENSE](https://www.google.com/search?q=LICENSE) file for details.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|