gselib 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.
@@ -0,0 +1,29 @@
1
+ # SPDX-License-Identifier: MIT
2
+
3
+ name: Docs
4
+
5
+ on:
6
+ push:
7
+ branches:
8
+ - main
9
+
10
+ permissions:
11
+ contents: write
12
+
13
+ jobs:
14
+ deploy:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v5
18
+ with:
19
+ fetch-depth: 0
20
+
21
+ - uses: astral-sh/setup-uv@v6
22
+ with:
23
+ python-version: "3.14"
24
+
25
+ - run: uv sync --group docs
26
+
27
+ - run: uv run sphinx-build -b html docs docs/_build/html
28
+
29
+ - run: uv run ghp-import -n -p -f docs/_build/html
@@ -0,0 +1,28 @@
1
+ # SPDX-License-Identifier: MIT
2
+
3
+ name: Publish
4
+
5
+ on:
6
+ push:
7
+ tags:
8
+ - "v*"
9
+
10
+ permissions:
11
+ id-token: write
12
+
13
+ jobs:
14
+ publish:
15
+ runs-on: ubuntu-latest
16
+ environment: pypi
17
+ steps:
18
+ - uses: actions/checkout@v5
19
+ with:
20
+ fetch-depth: 0
21
+
22
+ - uses: astral-sh/setup-uv@v6
23
+ with:
24
+ python-version: "3.14"
25
+
26
+ - run: uv build
27
+
28
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,30 @@
1
+ # SPDX-License-Identifier: MIT
2
+
3
+ name: Tests
4
+
5
+ on:
6
+ push:
7
+ branches:
8
+ - main
9
+ pull_request:
10
+ branches:
11
+ - main
12
+
13
+ jobs:
14
+ test:
15
+ strategy:
16
+ matrix:
17
+ os: [ubuntu-latest, macos-latest, windows-latest]
18
+ runs-on: ${{ matrix.os }}
19
+ steps:
20
+ - uses: actions/checkout@v5
21
+ with:
22
+ fetch-depth: 0
23
+
24
+ - uses: astral-sh/setup-uv@v6
25
+ with:
26
+ python-version: "3.14"
27
+
28
+ - run: uv sync --group dev --extra cloud
29
+
30
+ - run: uv run pytest
@@ -0,0 +1,28 @@
1
+ # SPDX-License-Identifier: MIT
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[cod]
6
+
7
+ # Distribution / packaging
8
+ *.egg-info/
9
+ dist/
10
+ build/
11
+ wheels/
12
+
13
+ # Virtual environments
14
+ .venv/
15
+
16
+ # OS generated files
17
+ .DS_Store
18
+ ._*
19
+ Thumbs.db
20
+ Desktop.ini
21
+ *~
22
+
23
+ # Tools
24
+ .ruff_cache/
25
+ .pytest_cache/
26
+
27
+ # Docs build output
28
+ docs/_build/
@@ -0,0 +1,9 @@
1
+ # SPDX-License-Identifier: MIT
2
+
3
+ repos:
4
+ - repo: https://github.com/astral-sh/ruff-pre-commit
5
+ rev: v0.16.7
6
+ hooks:
7
+ - id: ruff-check
8
+ args: [--fix]
9
+ - id: ruff-format
@@ -0,0 +1,3 @@
1
+ # SPDX-License-Identifier: MIT
2
+
3
+ 3.14
@@ -0,0 +1,48 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2026-09-30
11
+
12
+ ### Changed
13
+
14
+ - LICENSE to License.txt
15
+ - Switched to packaging with Hatchling, uv, and versions from git tags
16
+ - Updated pre-commit hooks for Ruff
17
+ - Updated README
18
+ - Updated .gitignore
19
+ - Optional dependencies restructured: base install is now empty, `gselib[cloud]` installs Nextcloud support, `gselib[all]` installs everything
20
+ - `NextcloudClient` constants converted to plain lowercase class attributes (e.g. `perm_read`, `share_type_user`)
21
+ - pytest configured with `--import-mode=importlib` to support identically named test files across subdirectories
22
+
23
+ ### Added
24
+
25
+ - GitHub Actions to run pytest on push and pull requests to the main branch, with mock cli test
26
+ - Contribution guide
27
+ - Changelog file
28
+ - Added deps.py as a way to check for installed dependency groups
29
+ - Cloud module with Nextcloud support (`gselib[cloud]`) — REST API client (`NextcloudClient`) and `occ` runner (`NextcloudOCC`) for managing external storage and shares
30
+ - CLI subcommand `gselib cloud nextcloud` for storage and share management via flags or environment variables
31
+ - Tests for the cloud module (client, OCC runner, and CLI dispatch)
32
+ - CI matrix extended to macOS and Windows
33
+ - Sphinx documentation with PyData Sphinx Theme, auto-API generation via sphinx-autoapi, and Markdown support via myst-parser
34
+ - GitHub Actions workflow to deploy docs to GitHub Pages on push to main
35
+ - `docs` dependency group with Sphinx, PyData theme, sphinx-autobuild, sphinx-design, and ghp-import
36
+
37
+ ### Fixed
38
+
39
+ - `NextcloudOCC.__exit__` missing required exception arguments
40
+ - Version removed from CLI arguments and shown in the description instead
41
+
42
+ ### Removed
43
+
44
+ - maps.py (no longer supported)
45
+ - paths.py (no longer supported)
46
+ - trajectory.py (no longer supported)
47
+ - version.py (no longer supported)
48
+ - .static-version (no longer supported)
@@ -0,0 +1,8 @@
1
+ All contributions to the GSELib project are welcome! Here are some ways you can help:
2
+
3
+ - Report a bug by opening a [GitHub](https://github.com/gsecars/gselib/issues) or a [GitLab](https://gitlab.com/gsecars/gselib/-/boards) issue.
4
+ - Add new features, fix bugs or improve documentation by submitting a [GitHub](https://github.com/gsecars/gselib/pulls) or a [GitLab](https://gitlab.com/gsecars/gselib/-/merge_requests) pull request.
5
+
6
+ Please adhere to the [GitHub flow](https://docs.github.com/en/get-started/quickstart/github-flow) model when making your contributions! This means creating a new branch for each feature of bug fix, and submitting your changes as a pull request against the main branch. If you're not sure how to contribute, please open an issue and we'll be happy to help you out.
7
+
8
+ By contributing to the GSELib project, you agree that your contributions will be licensed under the MIT License.
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 GSECARS, University of Chicago, USA
4
+ Copyright (c) 2024-2026 Christofanis Skordas
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
gselib-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,57 @@
1
+ Metadata-Version: 2.5
2
+ Name: gselib
3
+ Version: 0.1.0
4
+ Summary: A collection of tools for GSECARS.
5
+ Project-URL: Homepage, https://github.com/gsecars/gselib
6
+ Project-URL: Issues, https://github.com/gsecars/gselib/issues
7
+ Author-email: Christofanis Skordas <skordasc@uchicago.edu>
8
+ Maintainer-email: Christofanis Skordas <skordasc@uchicago.edu>
9
+ License-Expression: MIT
10
+ License-File: LICENSE.txt
11
+ Classifier: Intended Audience :: Education
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Topic :: Scientific/Engineering
18
+ Classifier: Topic :: Utilities
19
+ Requires-Python: ==3.14.*
20
+ Provides-Extra: all
21
+ Requires-Dist: paramiko>=3.0; extra == 'all'
22
+ Requires-Dist: requests>=2.32; extra == 'all'
23
+ Provides-Extra: cloud
24
+ Requires-Dist: paramiko>=3.0; extra == 'cloud'
25
+ Requires-Dist: requests>=2.32; extra == 'cloud'
26
+ Description-Content-Type: text/markdown
27
+
28
+ <h1 align="center">
29
+ &nbsp;GSELib
30
+ </h1>
31
+
32
+
33
+ [![License](https://img.shields.io/badge/License-MIT-teal.svg)](LICENSE.txt) [![Python](https://img.shields.io/badge/Python-3.14-22558a.svg?logo=python&color=22558a)](https://www.python.org/)
34
+ [![Tests](https://github.com/gsecars/gselib/actions/workflows/tests.yml/badge.svg)](https://github.com/gsecars/gselib/actions/workflows/tests.yml)
35
+ [![Docs](https://github.com/gsecars/gselib/actions/workflows/docs.yml/badge.svg)](https://github.com/gsecars/gselib/actions/workflows/docs.yml)
36
+
37
+ A collection of tools for GSECARS.
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pip install gselib # base (no extras)
43
+ pip install 'gselib[cloud]' # with Nextcloud support
44
+ pip install 'gselib[all]' # everything
45
+ ```
46
+
47
+ ## Modules
48
+
49
+ | Module | Extras | Documentation |
50
+ |---|---|---|
51
+ | `gselib.cloud` | `gselib[cloud]` | [Cloud](https://gsecars.github.io/gselib/cloud/) |
52
+
53
+ ## Contribution
54
+ Read more [here](CONTRIBUTING.md) for contribution guidance.
55
+
56
+ ## License
57
+ GSELib is distributed under the MIT License. You should have received a [copy](LICENSE.txt) of the MIT License along with this program. If not, see https://mit-license.org/ for additional details.
gselib-0.1.0/README.md ADDED
@@ -0,0 +1,30 @@
1
+ <h1 align="center">
2
+ &nbsp;GSELib
3
+ </h1>
4
+
5
+
6
+ [![License](https://img.shields.io/badge/License-MIT-teal.svg)](LICENSE.txt) [![Python](https://img.shields.io/badge/Python-3.14-22558a.svg?logo=python&color=22558a)](https://www.python.org/)
7
+ [![Tests](https://github.com/gsecars/gselib/actions/workflows/tests.yml/badge.svg)](https://github.com/gsecars/gselib/actions/workflows/tests.yml)
8
+ [![Docs](https://github.com/gsecars/gselib/actions/workflows/docs.yml/badge.svg)](https://github.com/gsecars/gselib/actions/workflows/docs.yml)
9
+
10
+ A collection of tools for GSECARS.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ pip install gselib # base (no extras)
16
+ pip install 'gselib[cloud]' # with Nextcloud support
17
+ pip install 'gselib[all]' # everything
18
+ ```
19
+
20
+ ## Modules
21
+
22
+ | Module | Extras | Documentation |
23
+ |---|---|---|
24
+ | `gselib.cloud` | `gselib[cloud]` | [Cloud](https://gsecars.github.io/gselib/cloud/) |
25
+
26
+ ## Contribution
27
+ Read more [here](CONTRIBUTING.md) for contribution guidance.
28
+
29
+ ## License
30
+ GSELib is distributed under the MIT License. You should have received a [copy](LICENSE.txt) of the MIT License along with this program. If not, see https://mit-license.org/ for additional details.
@@ -0,0 +1,35 @@
1
+ # SPDX-License-Identifier: MIT
2
+
3
+ import os
4
+ from pathlib import Path
5
+
6
+ from gselib.cloud import NextcloudOCC
7
+
8
+
9
+ def load_env(path: str = ".env") -> None:
10
+ env_path = Path(path)
11
+ if not env_path.exists():
12
+ return
13
+ for line in env_path.read_text().splitlines():
14
+ line = line.strip()
15
+ if line and not line.startswith("#") and "=" in line:
16
+ key, _, value = line.partition("=")
17
+ os.environ.setdefault(key.strip(), value.strip())
18
+
19
+
20
+ load_env()
21
+
22
+ host = os.environ["NEXTCLOUD_SSH_HOST"]
23
+ user = os.environ["NEXTCLOUD_SSH_USER"]
24
+ password = os.environ.get("NEXTCLOUD_SSH_PASSWORD") or None
25
+ key = os.environ.get("NEXTCLOUD_SSH_KEY") or None
26
+ occ_cmd = os.environ.get("NEXTCLOUD_OCC_CMD", "php /var/www/html/occ")
27
+
28
+ with NextcloudOCC(host=host, user=user, password=password, key_path=key, occ_cmd=occ_cmd) as occ:
29
+ print("Creating storage...")
30
+ mount = occ.create_local_storage("test3", "/var/www/html")
31
+ print(f"Created: id={mount['id']} mount={mount['mount_point']}")
32
+
33
+ print("\nAll storages:")
34
+ for m in occ.list_storages():
35
+ print(f" id={str(m.get('mount_id') or m.get('id', '?')):<4} {m.get('mount_point') or m.get('mountPoint', '?')}")
@@ -0,0 +1,4 @@
1
+ <p class="copyright">
2
+ &copy; 2024-2026 GSECARS, University of Chicago, USA<br>
3
+ &copy; 2024-2026 Christofanis Skordas
4
+ </p>
@@ -0,0 +1,136 @@
1
+ # Cloud
2
+
3
+ The `cloud` module provides storage and share management for cloud services. Currently supported: **Nextcloud**.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install 'gselib[cloud]'
9
+ ```
10
+
11
+ ## Nextcloud CLI
12
+
13
+ All commands are available under `gselib cloud nextcloud`. Storage commands (create, list, delete) run `occ` on the server; share commands use the Nextcloud REST API.
14
+
15
+ ### Configuration
16
+
17
+ **Storage management** runs `occ` locally or over SSH. Configure via flags or environment variables:
18
+
19
+ | Flag | Environment variable | Description |
20
+ |---|---|---|
21
+ | `--occ-cmd` | `NEXTCLOUD_OCC_CMD` | Full `occ` invocation (required) |
22
+ | `--ssh-host` | `NEXTCLOUD_SSH_HOST` | SSH host (omit to run locally) |
23
+ | `--ssh-user` | `NEXTCLOUD_SSH_USER` | SSH username |
24
+ | `--ssh-key` | `NEXTCLOUD_SSH_KEY` | Path to private key (prompts for password if omitted) |
25
+
26
+ **Share management** uses the OCS REST API. Configure via flags or environment variables:
27
+
28
+ | Flag | Environment variable | Description |
29
+ |---|---|---|
30
+ | `--url` | `NEXTCLOUD_URL` | Nextcloud base URL |
31
+ | `--user` | `NEXTCLOUD_USER` | Admin username |
32
+ | `--password` | `NEXTCLOUD_PASSWORD` | Admin password (prompted if omitted) |
33
+
34
+ ### External storage
35
+
36
+ Local (no SSH):
37
+
38
+ ```bash
39
+ gselib cloud nextcloud --occ-cmd "php occ" create-storage --mount MyData --path /srv/data
40
+ ```
41
+
42
+ Via SSH with key:
43
+
44
+ ```bash
45
+ gselib cloud nextcloud \
46
+ --occ-cmd "php occ" \
47
+ --ssh-host myserver --ssh-user admin --ssh-key ~/.ssh/id_ed25519 \
48
+ create-storage --mount MyData --path /srv/data
49
+ ```
50
+
51
+ Nextcloud AIO (Docker over SSH):
52
+
53
+ ```bash
54
+ gselib cloud nextcloud \
55
+ --occ-cmd "docker exec --user www-data nextcloud-aio-nextcloud php occ" \
56
+ --ssh-host myserver --ssh-user admin --ssh-key ~/.ssh/id_ed25519 \
57
+ create-storage --mount MyData --path /srv/data --users alice bob
58
+ ```
59
+
60
+ With groups:
61
+
62
+ ```bash
63
+ gselib cloud nextcloud --occ-cmd "php occ" \
64
+ create-storage --mount Shared --path /srv/shared --groups scientists
65
+ ```
66
+
67
+ List storages:
68
+
69
+ ```bash
70
+ gselib cloud nextcloud --occ-cmd "php occ" list-storages
71
+ ```
72
+
73
+ Delete a storage:
74
+
75
+ ```bash
76
+ gselib cloud nextcloud --occ-cmd "php occ" delete-storage --id 3
77
+ ```
78
+
79
+ ### Shares
80
+
81
+ Share a path:
82
+
83
+ ```bash
84
+ gselib cloud nextcloud \
85
+ --url https://nextcloud.example.org --user admin \
86
+ share --nc-path /MyData --recipients alice bob@external.org \
87
+ --permissions read update
88
+ ```
89
+
90
+ Available permissions: `read`, `update`, `create`, `delete`, `share`, `all`.
91
+
92
+ List shares:
93
+
94
+ ```bash
95
+ gselib cloud nextcloud --url https://nextcloud.example.org --user admin \
96
+ list-shares --nc-path /MyData
97
+ ```
98
+
99
+ Delete a share:
100
+
101
+ ```bash
102
+ gselib cloud nextcloud --url https://nextcloud.example.org --user admin \
103
+ delete-share --id 7
104
+ ```
105
+
106
+ ## Nextcloud library
107
+
108
+ ```python
109
+ from gselib.cloud import NextcloudClient, NextcloudOCC
110
+
111
+ # External storage via occ (local)
112
+ with NextcloudOCC(occ_cmd="php occ") as occ:
113
+ mount = occ.create_local_storage("MyData", "/srv/data", applicable_users=["alice"])
114
+ print(mount["id"])
115
+ mounts = occ.list_storages()
116
+ occ.delete_storage(mount["id"])
117
+
118
+ # External storage via SSH
119
+ with NextcloudOCC(host="myserver", user="admin", key_path="~/.ssh/id_ed25519", occ_cmd="php occ") as occ:
120
+ occ.create_local_storage("MyData", "/srv/data")
121
+
122
+ # Nextcloud AIO (Docker over SSH)
123
+ with NextcloudOCC(
124
+ host="myserver",
125
+ user="admin",
126
+ key_path="~/.ssh/id_ed25519",
127
+ occ_cmd="docker exec --user www-data nextcloud-aio-nextcloud php occ",
128
+ ) as occ:
129
+ occ.create_local_storage("MyData", "/srv/data")
130
+
131
+ # Shares via REST API
132
+ client = NextcloudClient("https://nextcloud.example.org", "admin", "password")
133
+ client.share_with_many("/MyData", ["alice", "bob@external.org"], permissions=NextcloudClient.perm_read)
134
+ shares = client.list_shares(path="/MyData")
135
+ client.delete_share(shares[0]["id"])
136
+ ```
@@ -0,0 +1,36 @@
1
+ # SPDX-License-Identifier: MIT
2
+
3
+ project = "GSELib"
4
+ author = "Christofanis Skordas"
5
+ copyright = "2024-2026 GSECARS, University of Chicago, USA"
6
+
7
+ extensions = [
8
+ "autoapi.extension",
9
+ "myst_parser",
10
+ "sphinx_design",
11
+ ]
12
+
13
+ myst_enable_extensions = ["colon_fence"]
14
+ myst_heading_anchors = 3
15
+
16
+ autoapi_dirs = ["../gselib"]
17
+ autoapi_type = "python"
18
+ autoapi_options = ["members", "undoc-members", "show-inheritance", "show-module-summary"]
19
+
20
+ html_theme = "pydata_sphinx_theme"
21
+ html_theme_options = {
22
+ "github_url": "https://github.com/gsecars/gselib",
23
+ "navigation_with_keys": True,
24
+ "show_toc_level": 2,
25
+ "footer_start": ["gselib-copyright"],
26
+ "footer_center": [],
27
+ "footer_end": [],
28
+ }
29
+
30
+ html_sidebars = {
31
+ "index": [],
32
+ }
33
+
34
+ templates_path = ["_templates"]
35
+
36
+ exclude_patterns = ["_build"]
@@ -0,0 +1,40 @@
1
+ # GSELib
2
+
3
+ A collection of tools for GSECARS.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install gselib # base (no extras)
9
+ pip install 'gselib[cloud]' # with Nextcloud support
10
+ pip install 'gselib[all]' # everything
11
+ ```
12
+
13
+ ## Modules
14
+
15
+ ::::{grid} 1 2 2 2
16
+ :gutter: 3
17
+
18
+ :::{grid-item-card} Cloud
19
+ :link: cloud
20
+ :link-type: doc
21
+
22
+ Storage and share management for cloud services. Currently supports Nextcloud via REST API and `occ`.
23
+ :::
24
+
25
+ :::{grid-item-card} API Reference
26
+ :link: autoapi/index
27
+ :link-type: doc
28
+
29
+ Auto-generated reference for all public classes and functions.
30
+ :::
31
+
32
+ ::::
33
+
34
+ ```{toctree}
35
+ :maxdepth: 2
36
+ :hidden:
37
+
38
+ cloud
39
+ API Reference <autoapi/index>
40
+ ```