mycelium-client 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,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026-present PPPDUD <mojavesoft@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ Metadata-Version: 2.5
2
+ Name: mycelium-client
3
+ Version: 0.1.0
4
+ Summary: The official client for the Mycelium file-sharing protocol.
5
+ Author-email: PPPDUD <mojavesoft@gmail.com>
6
+ License-Expression: MIT
7
+ License-File: LICENSE.txt
8
+ Classifier: Development Status :: 2 - Pre-Alpha
9
+ Classifier: Programming Language :: Python
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: Implementation :: CPython
16
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
17
+ Requires-Python: >=3.8
18
+ Requires-Dist: click~=8.4
19
+ Requires-Dist: requests
20
+ Requires-Dist: tqdm
21
+ Description-Content-Type: text/markdown
22
+
23
+ # mycelium-client
24
+
25
+ [![PyPI - Version](https://img.shields.io/pypi/v/mycelium-client.svg)](https://pypi.org/project/mycelium-client)
26
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mycelium-client.svg)](https://pypi.org/project/mycelium-client)
27
+
28
+ -----
29
+
30
+ ## Table of Contents
31
+
32
+ - [Installation](#installation)
33
+ - [License](#license)
34
+
35
+ ## Installation
36
+
37
+ ```console
38
+ pip install mycelium-client
39
+ ```
40
+
41
+ ## License
42
+
43
+ `mycelium-client` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,21 @@
1
+ # mycelium-client
2
+
3
+ [![PyPI - Version](https://img.shields.io/pypi/v/mycelium-client.svg)](https://pypi.org/project/mycelium-client)
4
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mycelium-client.svg)](https://pypi.org/project/mycelium-client)
5
+
6
+ -----
7
+
8
+ ## Table of Contents
9
+
10
+ - [Installation](#installation)
11
+ - [License](#license)
12
+
13
+ ## Installation
14
+
15
+ ```console
16
+ pip install mycelium-client
17
+ ```
18
+
19
+ ## License
20
+
21
+ `mycelium-client` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,68 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "mycelium-client"
7
+ dynamic = ["version"]
8
+ description = 'The official client for the Mycelium file-sharing protocol.'
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = "MIT"
12
+ keywords = []
13
+ authors = [
14
+ { name = "PPPDUD", email = "mojavesoft@gmail.com" },
15
+ ]
16
+ classifiers = [
17
+ "Development Status :: 2 - Pre-Alpha",
18
+ "Programming Language :: Python",
19
+ "Programming Language :: Python :: 3.8",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: Implementation :: CPython",
25
+ "Programming Language :: Python :: Implementation :: PyPy",
26
+ ]
27
+ dependencies = [
28
+ "click~=8.4",
29
+ "requests",
30
+ "tqdm"
31
+ ]
32
+
33
+ [project.urls]
34
+ #Documentation = "https://github.com/PPPDUD/mycelium-client#readme"
35
+ #Issues = "https://github.com/PPPDUD/mycelium-client/issues"
36
+ #Source = "https://github.com/PPPDUD/mycelium-client"
37
+
38
+ [project.scripts]
39
+ mycelium-client = "mycelium_client.cli:mycelium_client"
40
+
41
+ [tool.hatch.version]
42
+ path = "src/mycelium_client/__about__.py"
43
+
44
+ [tool.hatch.envs.types]
45
+ extra-dependencies = [
46
+ "mypy>=1.0.0",
47
+ ]
48
+ [tool.hatch.envs.types.scripts]
49
+ check = "mypy --install-types --non-interactive {args:src/mycelium_client tests}"
50
+
51
+ [tool.coverage.run]
52
+ source_pkgs = ["mycelium_client", "tests"]
53
+ branch = true
54
+ parallel = true
55
+ omit = [
56
+ "src/mycelium_client/__about__.py",
57
+ ]
58
+
59
+ [tool.coverage.paths]
60
+ mycelium_client = ["src/mycelium_client", "*/mycelium-client/src/mycelium_client"]
61
+ tests = ["tests", "*/mycelium-client/tests"]
62
+
63
+ [tool.coverage.report]
64
+ exclude_lines = [
65
+ "no cov",
66
+ "if __name__ == .__main__.:",
67
+ "if TYPE_CHECKING:",
68
+ ]
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
File without changes
@@ -0,0 +1,6 @@
1
+ import sys
2
+
3
+ if __name__ == "__main__":
4
+ from mycelium_client.cli import mycelium_client
5
+
6
+ sys.exit(mycelium_client())
@@ -0,0 +1,80 @@
1
+ import click
2
+ from os import environ
3
+ from requests import get
4
+ from json import loads
5
+ from urllib import parse
6
+ from random import shuffle
7
+ from tqdm import tqdm
8
+ from hashlib import sha256
9
+ from mycelium_client.__about__ import __version__
10
+
11
+ default_oak = environ.get("MYCELIUM_OAK", None)
12
+ oak_option_help = "Oak to fetch listings from. (Defaults to value of environment variable MYCELIUM_OAK if not specified; errors out if neither are specified.)"
13
+
14
+
15
+ @click.group(
16
+ context_settings={"help_option_names": ["-h", "--help"]},
17
+ invoke_without_command=True,
18
+ )
19
+ @click.version_option(version=__version__, prog_name="mycelium-client")
20
+ def mycelium_client():
21
+ pass
22
+
23
+
24
+ @click.command(name="show")
25
+ @click.option("--filter-hash", default=None, help="Hash to show listings for.")
26
+ @click.option("--oak", default=None, help=oak_option_help)
27
+ def show_hashes(filter_hash: str, oak: str):
28
+ if oak:
29
+ hashes = loads(get(oak).content)
30
+ elif default_oak:
31
+ hashes = loads(get(default_oak).content)
32
+ else:
33
+ raise click.ClickException("No Oak specified.")
34
+ if filter_hash:
35
+ if hashes.get(filter_hash):
36
+ click.echo(f"Hash: {filter_hash}")
37
+ for server, timestamp in hashes[filter_hash].items():
38
+ click.echo(f"* {server} (last submitted at {timestamp})")
39
+ else:
40
+ raise click.ClickException("No such hash.")
41
+ else:
42
+ for key, value in hashes.items():
43
+ click.echo(f"## Hash: {key}")
44
+ for server, timestamp in value.items():
45
+ click.echo(f"* {server} (last submitted at {timestamp})")
46
+
47
+
48
+ @click.command(name="fetch")
49
+ @click.argument("asset_hash")
50
+ @click.argument("output_file", default="output")
51
+ @click.option("--oak", default=None, help=oak_option_help)
52
+ def fetch_hash(asset_hash: str, output_file: str):
53
+ if oak:
54
+ hashes = loads(get(oak).content)
55
+ elif default_oak:
56
+ hashes = loads(get(default_oak).content)
57
+ else:
58
+ raise click.ClickException("No Oak specified.")
59
+ if hashes.get(asset_hash):
60
+ servers = list(hashes[
61
+ asset_hash
62
+ ].keys()) # This might be using memory referencing under the hood, but doesn't matter. hashes will exit scope soon anyway.
63
+ shuffle(servers)
64
+
65
+ for i in tqdm(servers):
66
+ req = get(i).content
67
+ m = sha256()
68
+ m.update(req)
69
+ if m.hexdigest() == asset_hash:
70
+ click.echo("File located! Writing to disk...")
71
+ with open(output_file, "wb") as f:
72
+ f.write(req)
73
+ click.echo("Written!")
74
+ break
75
+ else:
76
+ raise click.ClickException("Hash not found.")
77
+
78
+
79
+ mycelium_client.add_command(show_hashes)
80
+ mycelium_client.add_command(fetch_hash)
File without changes