sciop-cli 0.1.1__py3-none-any.whl

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.
sciop_cli/__init__.py ADDED
File without changes
sciop_cli/__main__.py ADDED
@@ -0,0 +1,3 @@
1
+ from sciop_cli.cli.main import cli
2
+
3
+ cli()
File without changes
sciop_cli/cli/main.py ADDED
@@ -0,0 +1,23 @@
1
+ import logging
2
+
3
+ import click
4
+
5
+ from sciop_cli.cli.manifest import manifest
6
+ from sciop_cli.cli.torrent import torrent
7
+
8
+
9
+ @click.group()
10
+ @click.version_option(package_name="sciop_cli")
11
+ @click.option(
12
+ "--debug/--no-debug", type=bool, default=False, help="Whether to enable debug logging."
13
+ )
14
+ def cli(debug: bool) -> None:
15
+ """SciOp, the CLI!!!"""
16
+ if debug:
17
+ logging.basicConfig(level=logging.DEBUG)
18
+ else:
19
+ logging.basicConfig(level=logging.INFO)
20
+
21
+
22
+ cli.add_command(torrent)
23
+ cli.add_command(manifest)
@@ -0,0 +1,125 @@
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+ import warnings
5
+ from pathlib import Path
6
+ from typing import BinaryIO, Iterable, TextIO
7
+
8
+ import click
9
+ from click_option_group import RequiredMutuallyExclusiveOptionGroup, optgroup
10
+
11
+ from sciop_cli.schema import (
12
+ EmptyDir,
13
+ IgnorePattern,
14
+ Manifest,
15
+ SingleFileManifest,
16
+ UnstableManifest,
17
+ )
18
+
19
+ logger = logging.getLogger(__name__)
20
+
21
+
22
+ @click.group()
23
+ def manifest() -> None:
24
+ """
25
+ Create and manage dataset manifests.
26
+ """
27
+
28
+
29
+ @manifest.command()
30
+ @optgroup.group(
31
+ "Dataset source",
32
+ cls=RequiredMutuallyExclusiveOptionGroup,
33
+ help="The file(s) making up the dataset to create a manifest from.",
34
+ )
35
+ @optgroup.option("-f", "--file", type=click.File("rb"), help="Path to single-file dataset.")
36
+ @optgroup.option(
37
+ "-d",
38
+ "--dir",
39
+ type=click.Path(exists=True, file_okay=False, path_type=Path),
40
+ help="Path to directory dataset.",
41
+ )
42
+ @optgroup.group("Manifest generation", help="How to generate the manifest.")
43
+ @optgroup.option(
44
+ "-o", "--output", type=click.File(mode="w"), default="-", help="Where to write the manifest."
45
+ )
46
+ @optgroup.option(
47
+ "-i",
48
+ "--ignore",
49
+ type=str,
50
+ multiple=True,
51
+ default=[],
52
+ help="Glob strings to ignore when scanning a directory.",
53
+ )
54
+ def create(file: BinaryIO | None, dir: Path | None, output: TextIO, ignore: Iterable[str]) -> None:
55
+ """
56
+ Create a manifest from a dataset on the local filesystem.
57
+ """
58
+ if file is not None:
59
+ assert dir is None, dir
60
+ if ignore:
61
+ warnings.warn(
62
+ "ignore strings are not processed for single-file datasets.", stacklevel=1
63
+ )
64
+ manifest = UnstableManifest.generate_from_file(file)
65
+ else:
66
+ assert dir is not None
67
+ ignores = [IgnorePattern.compile(i) for i in ignore]
68
+ try:
69
+ manifest = UnstableManifest.generate_from_directory(dir, ignores=ignores)
70
+ except EmptyDir as e:
71
+ raise ValueError(f"metadata could not be generated: directory {dir} was empty.") from e
72
+ output.write(manifest.model_dump_json())
73
+
74
+
75
+ @manifest.command()
76
+ @optgroup.group("Manifest analysis", help="How to interpret the manifest.")
77
+ @optgroup.option(
78
+ "-m", "--manifest", type=click.File("rb"), required=True, help="Manifest file to analyze."
79
+ )
80
+ @optgroup.option(
81
+ "--allow-extra-files/--no-allow-extra-files",
82
+ type=bool,
83
+ default=True,
84
+ help="Whether to allow files in a directory dataset that are not specified in the manifest.",
85
+ )
86
+ @optgroup.group(
87
+ "Dataset source",
88
+ cls=RequiredMutuallyExclusiveOptionGroup,
89
+ help="The file(s) making up the dataset to verify the manifest against.",
90
+ )
91
+ @optgroup.option("-f", "--file", type=click.File("rb"), help="Path to single-file dataset.")
92
+ @optgroup.option(
93
+ "-d",
94
+ "--dir",
95
+ type=click.Path(exists=True, file_okay=False, path_type=Path),
96
+ help="Path to directory dataset.",
97
+ )
98
+ def verify(
99
+ manifest: BinaryIO, allow_extra_files: bool, file: BinaryIO | None, dir: Path | None
100
+ ) -> None:
101
+ """
102
+ Validate a manifest against a local copy of the dataset.
103
+ """
104
+ parsed_manifest = Manifest.model_validate_json(manifest.read())
105
+
106
+ if isinstance(parsed_manifest.contents, SingleFileManifest):
107
+ if file is None:
108
+ raise ValueError(
109
+ "manifest was for a single-file dataset, but input was not a single file."
110
+ )
111
+ parsed_manifest.contents.verify(file)
112
+ else:
113
+ if dir is None:
114
+ raise ValueError("manifest was for a directory dataset, but input was not a directory.")
115
+ if allow_extra_files:
116
+ parsed_manifest.contents.verify_inexact(dir)
117
+ else:
118
+ try:
119
+ parsed_manifest.contents.verify_exact(dir)
120
+ except EmptyDir as e:
121
+ raise ValueError(
122
+ f"metadata could not be generated: directory {dir} was empty."
123
+ ) from e
124
+
125
+ logger.debug("verification succeeded!")
@@ -0,0 +1,141 @@
1
+ from pathlib import Path
2
+ from typing import cast
3
+
4
+ import click
5
+
6
+ from sciop_cli.const import DEFAULT_TORRENT_CREATOR
7
+ from sciop_cli.data import get_default_trackers
8
+ from sciop_cli.torrent import create_torrent
9
+ from sciop_cli.types import PieceSize
10
+
11
+
12
+ @click.group()
13
+ def torrent() -> None:
14
+ """
15
+ Create and manage torrents
16
+ """
17
+
18
+
19
+ @torrent.command()
20
+ def pack() -> None:
21
+ """
22
+ Pack a directory to prepare it for torrent creation
23
+
24
+ - Generate a manifest for the directory
25
+ - Archive small files
26
+ - Emit a .packmap.json description of the packing operation
27
+ """
28
+ raise NotImplementedError()
29
+
30
+
31
+ @torrent.command()
32
+ @click.option(
33
+ "-p",
34
+ "--path",
35
+ required=True,
36
+ help="Path to a directory or file to create .torrent from",
37
+ type=click.Path(exists=True),
38
+ )
39
+ @click.option(
40
+ "-t",
41
+ "--tracker",
42
+ required=False,
43
+ default=None,
44
+ multiple=True,
45
+ help="Trackers to add to the torrent. can be used multiple times for multiple trackers. "
46
+ "If not present, use the default trackers from https://sciop.net/docs/uploading/default_trackers.txt",
47
+ )
48
+ @click.option(
49
+ "--no-default-trackers",
50
+ is_flag=True,
51
+ default=False,
52
+ help="Do not use the default trackers if no trackers are provided",
53
+ )
54
+ @click.option(
55
+ "-s",
56
+ "--piece-size",
57
+ default=512 * (2**10),
58
+ help="Piece size, in bytes",
59
+ show_default=True,
60
+ )
61
+ @click.option(
62
+ "--comment",
63
+ default=None,
64
+ required=False,
65
+ help="Optional comment field for torrent",
66
+ )
67
+ @click.option(
68
+ "--creator",
69
+ default=DEFAULT_TORRENT_CREATOR,
70
+ show_default=True,
71
+ required=False,
72
+ help="Optional creator field for torrent",
73
+ )
74
+ @click.option(
75
+ "-w",
76
+ "--webseed",
77
+ required=False,
78
+ default=None,
79
+ multiple=True,
80
+ help="Add HTTP webseeds as additional sources for torrent. Can be used multiple times. "
81
+ "See https://www.bittorrent.org/beps/bep_0019.html",
82
+ )
83
+ @click.option(
84
+ "--similar",
85
+ required=False,
86
+ default=None,
87
+ multiple=True,
88
+ help="Add infohash of a similar torrent. "
89
+ "Similar torrents are torrents who have files in common with this torrent, "
90
+ "clients are able to reuse files from the other torrents if they already have them downloaded.",
91
+ )
92
+ @click.option("--progress/--no-progress", default=True, help="Enable progress bar (default True)")
93
+ @click.option(
94
+ "-o",
95
+ "--output",
96
+ required=False,
97
+ default=None,
98
+ type=click.Path(exists=False),
99
+ help=".torrent file to write to. Otherwise to stdout",
100
+ )
101
+ def create(
102
+ path: Path,
103
+ tracker: list[str] | None = None,
104
+ no_default_trackers: bool = False,
105
+ piece_size: PieceSize = 512 * (2**10),
106
+ comment: str | None = None,
107
+ creator: str = DEFAULT_TORRENT_CREATOR,
108
+ webseed: list[str] | None = None,
109
+ similar: list[str] | None = None,
110
+ progress: bool = True,
111
+ output: Path | None = None,
112
+ ) -> None:
113
+ """
114
+ Create a torrent from a file or directory.
115
+
116
+ Uses libtorrent to create standard torrent files.
117
+ Will create a hybrid v1/v2 torrent file.
118
+
119
+ See https://www.libtorrent.org/reference-Create_Torrents.html
120
+ form details on fields, all input here is passed through to
121
+ libtorrent's creation methods.
122
+ """
123
+ if tracker is None and not no_default_trackers:
124
+ tracker = get_default_trackers()
125
+ result = create_torrent(
126
+ path,
127
+ trackers=tracker,
128
+ piece_size=piece_size,
129
+ comment=comment,
130
+ creator=creator,
131
+ webseeds=webseed,
132
+ similar=similar,
133
+ pbar=progress,
134
+ bencode=True,
135
+ )
136
+ result = cast(bytes, result)
137
+ if output:
138
+ with open(output, "wb") as f:
139
+ f.write(result)
140
+ else:
141
+ click.echo(result)
sciop_cli/const.py ADDED
@@ -0,0 +1,4 @@
1
+ from importlib.metadata import version
2
+
3
+ DEFAULT_TORRENT_CREATOR = f"sciop-cli {version('sciop-cli')}"
4
+ EXCLUDE_FILES = ".DS_Store"
sciop_cli/data.py ADDED
@@ -0,0 +1,27 @@
1
+ """
2
+ Data that is used by sciop-cli that may need to be downloaded before being used
3
+ """
4
+
5
+ from pathlib import Path
6
+
7
+ import requests
8
+ from platformdirs import PlatformDirs
9
+
10
+ _dirs = PlatformDirs("sciop-cli", "sciop")
11
+
12
+ DATA_DIR = Path(_dirs.user_data_dir)
13
+ DEFAULT_TRACKERS = DATA_DIR / "trackers.txt"
14
+ DEFAULT_TRACKER_SOURCE = "https://sciop.net/docs/uploading/default_trackers.txt"
15
+
16
+
17
+ def get_default_trackers(tracker_source: str = DEFAULT_TRACKER_SOURCE) -> list[str]:
18
+ if not DEFAULT_TRACKERS.exists():
19
+ res = requests.get(tracker_source)
20
+ res.raise_for_status()
21
+ with open(DEFAULT_TRACKERS, "w") as f:
22
+ f.write(res.text)
23
+ trackers = res.text.splitlines()
24
+ else:
25
+ trackers = DEFAULT_TRACKERS.read_text().splitlines()
26
+ trackers = [t.strip() for t in trackers if t.strip()]
27
+ return trackers
sciop_cli/file.py ADDED
@@ -0,0 +1,40 @@
1
+ from pathlib import Path
2
+
3
+ import pandera as pa
4
+ from pandera.typing import DataFrame, Series
5
+
6
+
7
+ class Files(pa.DataFrameModel):
8
+ filename: Series[str]
9
+ directory: Series[str]
10
+ size: Series[int]
11
+
12
+
13
+ @pa.check_types
14
+ def read_directory(directory: Path) -> DataFrame[Files]:
15
+ names = []
16
+ dirs = []
17
+ sizes = []
18
+ for f in directory.glob("**/*"):
19
+ if not f.is_file():
20
+ continue
21
+ names.append(f.name)
22
+ dirs.append(str(f.parent))
23
+ sizes.append(f.stat().st_size)
24
+ return DataFrame[Files]({"filename": names, "directory": dirs, "size": sizes})
25
+
26
+
27
+ def directory_size(directory: Path) -> int:
28
+ """Recursive directoy size, in bytes"""
29
+ return sum(f.stat().st_size for f in directory.glob("**/*") if f.is_file())
30
+
31
+
32
+ # def should_zip(directory: Path, piece_size: int, n_file_threshold:int = 20) -> bool:
33
+ # """
34
+ # FIXME: nvm just load all the files into pandas and do it vectorized
35
+ # """
36
+ # pass
37
+ # # n_small_files = 0
38
+ # # for f in directory.glob("*"):
39
+ # # if f.is_file() and f.stat().st_size < n_file_threshold:
40
+ # # n_small_files += 1
File without changes
sciop_cli/schema.py ADDED
@@ -0,0 +1,343 @@
1
+ from __future__ import annotations
2
+
3
+ import fnmatch
4
+ import io
5
+ import logging
6
+ import re
7
+ from collections import OrderedDict
8
+ from dataclasses import dataclass
9
+ from hashlib import sha256
10
+ from pathlib import Path
11
+ from textwrap import dedent
12
+ from typing import Annotated, Any, BinaryIO, Iterable, Iterator, Literal, Mapping, Self
13
+
14
+ from pydantic import BaseModel, BeforeValidator, Field, RootModel
15
+
16
+ from sciop_cli.types import PieceSize
17
+
18
+ logger = logging.getLogger(__name__)
19
+
20
+
21
+ FileLength = Annotated[int, Field(ge=0)]
22
+ SHA_256_DIGEST_LEN = 64
23
+ HEX_PATTERN = re.compile(r"^[0-9a-f]+$")
24
+ Sha256Hash = Annotated[
25
+ str, Field(min_length=SHA_256_DIGEST_LEN, max_length=SHA_256_DIGEST_LEN, pattern=HEX_PATTERN)
26
+ ]
27
+
28
+
29
+ class Sha256Checksum(BaseModel):
30
+ algorithm: Literal["sha256"] = "sha256"
31
+ value: Sha256Hash
32
+
33
+
34
+ def chunk_file(file: BinaryIO, chunk_size: int) -> Iterator[bytes]:
35
+ assert chunk_size > 0, chunk_size
36
+ while chunk := file.read(chunk_size):
37
+ yield chunk
38
+
39
+
40
+ class Digest(BaseModel):
41
+ length: FileLength
42
+ checksum: Sha256Checksum = Field(discriminator="algorithm")
43
+
44
+ @classmethod
45
+ def chunks(cls, chunks: Iterable[bytes]) -> Self:
46
+ count = 0
47
+ hasher = sha256()
48
+
49
+ for chunk in chunks:
50
+ count += len(chunk)
51
+ hasher.update(chunk)
52
+
53
+ return cls(length=count, checksum=Sha256Checksum(value=hasher.hexdigest()))
54
+
55
+ @classmethod
56
+ def en_masse(cls, chunk: bytes) -> Self:
57
+ return cls.chunks([chunk])
58
+
59
+ @classmethod
60
+ def file(cls, file: BinaryIO, *, chunk_size: int = io.DEFAULT_BUFFER_SIZE) -> Self:
61
+ return cls.chunks(chunk_file(file, chunk_size))
62
+
63
+
64
+ class VerificationFailed(Exception):
65
+ pass
66
+
67
+
68
+ class FileVerificationFailed(VerificationFailed):
69
+ def __init__(self, prev: SingleFileManifest, cur: SingleFileManifest) -> None:
70
+ self.prev = prev
71
+ self.cur = cur
72
+ super().__init__(
73
+ dedent(
74
+ """\
75
+ file manifest failed to match file input:
76
+ manifest:
77
+ {prev}
78
+
79
+ input:
80
+ {cur}
81
+ """
82
+ ).format(prev=prev.model_dump_json(indent=2), cur=cur.model_dump_json(indent=2))
83
+ )
84
+
85
+
86
+ class SingleFileManifest(BaseModel):
87
+ manifest_kind: Literal["file"] = "file"
88
+ digest: Digest
89
+
90
+ @classmethod
91
+ def generate_from_file(cls, file: BinaryIO) -> Self:
92
+ return cls(digest=Digest.file(file))
93
+
94
+ def verify(self, file: BinaryIO) -> None:
95
+ cmp = type(self).generate_from_file(file)
96
+ if cmp != self:
97
+ raise FileVerificationFailed(self, cmp)
98
+
99
+
100
+ def _validate_file_tree_node_name(component: Any) -> Any:
101
+ if isinstance(component, str):
102
+ component_str = component
103
+ elif isinstance(component, (bytes, bytearray)):
104
+ try:
105
+ component_str = component.decode("utf-8")
106
+ except UnicodeDecodeError as e:
107
+ raise ValueError(
108
+ f"file entry path component {component!r} is not a UTF-8 encoded string"
109
+ ) from e
110
+ else:
111
+ raise ValueError(f"file entry path component {component!r} is not a string or bytes")
112
+
113
+ for banned in ["\\", "/"]:
114
+ if banned in component_str:
115
+ raise ValueError(f"component {component_str} contained the banned character '{banned}'")
116
+ for banned_component in [".", ".."]:
117
+ if banned_component == component_str:
118
+ raise ValueError(
119
+ f"component {component_str} was equal to the banned string '{banned_component}'"
120
+ )
121
+
122
+ return component_str
123
+
124
+
125
+ FileEntryPathComponent = Annotated[str, BeforeValidator(_validate_file_tree_node_name)]
126
+
127
+
128
+ class FileEntry(BaseModel):
129
+ entry_kind: Literal["file"] = "file"
130
+ digest: Digest
131
+
132
+ @classmethod
133
+ def generate_from_file(cls, file: BinaryIO) -> Self:
134
+ return cls(digest=Digest.file(file))
135
+
136
+
137
+ DirEntry = Annotated["FileEntry | SubdirEntry", Field(discriminator="entry_kind")]
138
+
139
+
140
+ @dataclass(frozen=True)
141
+ class IgnorePattern:
142
+ glob: str
143
+ rx: re.Pattern[str]
144
+
145
+ @classmethod
146
+ def compile(cls, glob: str) -> Self:
147
+ return cls(glob=glob, rx=re.compile(fnmatch.translate(glob)))
148
+
149
+
150
+ class EmptyDir(Exception):
151
+ pass
152
+
153
+
154
+ class DirEntries(RootModel[Mapping[FileEntryPathComponent, DirEntry]]):
155
+ # FIXME: formulate this as a coroutine so that ignores can be computed on demand and it can be
156
+ # computed in parallel across threads.
157
+ @classmethod
158
+ def generate_from_directory(
159
+ cls, directory: Path, root: Path, ignores: Iterable[IgnorePattern]
160
+ ) -> Self:
161
+ assert directory.is_relative_to(root), (directory, root)
162
+
163
+ # Iterate through entries, recursing as necessary.
164
+ sub_entries: dict[str, DirEntry] = {}
165
+ for sub_entry in directory.iterdir():
166
+ assert sub_entry.name not in sub_entries, (sub_entry, sub_entries)
167
+
168
+ relative_path = sub_entry.relative_to(root)
169
+ matched_ignore = False
170
+ for pat in ignores:
171
+ if pat.rx.search(str(relative_path)):
172
+ logger.debug("entry %s was ignored by glob pattern '%s'", sub_entry, pat.glob)
173
+ matched_ignore = True
174
+ break
175
+ if matched_ignore:
176
+ continue
177
+
178
+ # TODO: checking file type will follow symlinks by default. We don't currently support
179
+ # symlinks within this metadata schema, so we will end up with duplicate copies of
180
+ # entries available via symlink. This is intentional, as bittorrent also does not
181
+ # support symlinks, but may be worth expanding in the future, as symlinks can be
182
+ # stored wholly in the metadata schema separate from the torrent data itself.
183
+ if sub_entry.is_file():
184
+ with sub_entry.open(mode="rb") as file:
185
+ sub_entries[sub_entry.name] = FileEntry.generate_from_file(file)
186
+ elif sub_entry.is_dir():
187
+ try:
188
+ sub_entries[sub_entry.name] = SubdirEntry.generate_from_directory(
189
+ sub_entry, root, ignores
190
+ )
191
+ except EmptyDir:
192
+ logger.debug("subdir %s was empty", sub_entry)
193
+ continue
194
+ else:
195
+ logger.debug(
196
+ "directory entry is neither file, directory, nor symlink to such: %s", sub_entry
197
+ )
198
+
199
+ # If the directory was empty (either for having no valid entries, or having them all
200
+ # filtered out by ignore patterns), raise an internal exception. We can't represent these in
201
+ # bittorrent, so we can't use them in our metadata protocol yet either.
202
+ # TODO: we could very well support empty directories external to the torrent itself, by
203
+ # re-inserting them upon download like we propose for symlinks above.
204
+ if not sub_entries:
205
+ raise EmptyDir
206
+
207
+ # Sort the entries by key. This is almost definitely going to be the case already just by
208
+ # using the filesystem native iteration order and relying on insertion order sorting for
209
+ # dict in python 3.7+, but this ensures that result, allowing us to produce reproducible
210
+ # json serialization which we can checksum.
211
+ sorted_entries = OrderedDict((k, sub_entries[k]) for k in sorted(sub_entries.keys()))
212
+ return cls(sorted_entries)
213
+
214
+ def generate_all_entries(self) -> Iterator[tuple[Path, FileEntry]]:
215
+ """Walk the recursive directory contents and produce complete file paths and digests."""
216
+ for component, sub_entry in self.root.items():
217
+ # If this is a file entry, then return just this last component as its path.
218
+ if isinstance(sub_entry, FileEntry):
219
+ yield (Path(component), sub_entry)
220
+ else:
221
+ # Otherwise, prepend this component to the paths generated by this subdirectory.
222
+ for sub_component, file_entry in sub_entry.sub_entries.generate_all_entries():
223
+ yield (Path(component) / sub_component, file_entry)
224
+
225
+ def verify_inexact(self, directory: Path) -> None:
226
+ """Match the contents of this manifest against a specific directory.
227
+
228
+ This method allows for other files not specified in the manifest to exist."""
229
+ for relpath, file_entry in self.generate_all_entries():
230
+ cur_path = directory / relpath
231
+ try:
232
+ with cur_path.open("rb") as f:
233
+ # Create a single-file manifest object, and delegate to its verify method.
234
+ try:
235
+ prev_entry = SingleFileManifest(digest=file_entry.digest)
236
+ prev_entry.verify(f)
237
+ except FileVerificationFailed as e:
238
+ raise InexactDirectoryVerificationFailed(
239
+ prev=DirectoryManifest(entries=self),
240
+ entry_path=relpath,
241
+ reason=f"file from input dir {directory} failed to match manifest",
242
+ ) from e
243
+ except (FileNotFoundError, NotADirectoryError) as e:
244
+ # NB: NotADirectoryError occurs if something that was a directory in the manifest is
245
+ # a file path in the input directory.
246
+ raise InexactDirectoryVerificationFailed(
247
+ prev=DirectoryManifest(entries=self),
248
+ entry_path=relpath,
249
+ reason=f"file path was not found within input dir {directory}",
250
+ ) from e
251
+
252
+
253
+ class SubdirEntry(BaseModel):
254
+ entry_kind: Literal["subdir"] = "subdir"
255
+ sub_entries: DirEntries
256
+
257
+ @classmethod
258
+ def generate_from_directory(
259
+ cls, directory: Path, root: Path, ignores: Iterable[IgnorePattern]
260
+ ) -> Self:
261
+ return cls(sub_entries=DirEntries.generate_from_directory(directory, root, ignores))
262
+
263
+
264
+ class ExactDirectoryVerificationFailed(VerificationFailed):
265
+ def __init__(self, prev: DirectoryManifest, cur: DirectoryManifest):
266
+ self.prev = prev
267
+ self.cur = cur
268
+ super().__init__(
269
+ dedent(
270
+ """\
271
+ directory manifest failed to exactly match directory input:
272
+ manifest:
273
+ {prev}
274
+
275
+ input:
276
+ {cur}
277
+ """
278
+ ).format(prev=prev.model_dump_json(indent=2), cur=cur.model_dump_json(indent=2))
279
+ )
280
+
281
+
282
+ class InexactDirectoryVerificationFailed(VerificationFailed):
283
+ def __init__(self, prev: DirectoryManifest, entry_path: Path, reason: str) -> None:
284
+ self.prev = prev
285
+ self.entry_path = entry_path
286
+ self.reason = reason
287
+ super().__init__(
288
+ dedent(
289
+ """\
290
+ directory manifest failed to match directory input:
291
+ manifest:
292
+ {prev}
293
+
294
+ failed entry was: {entry_path}
295
+ reason: {reason}
296
+ """
297
+ ).format(prev=prev.model_dump_json(indent=2), entry_path=entry_path, reason=reason)
298
+ )
299
+
300
+
301
+ class DirectoryManifest(BaseModel):
302
+ manifest_kind: Literal["directory"] = "directory"
303
+ entries: DirEntries
304
+
305
+ @classmethod
306
+ def generate_from_directory(cls, directory: Path, ignores: Iterable[IgnorePattern]) -> Self:
307
+ return cls(entries=DirEntries.generate_from_directory(directory, directory, ignores))
308
+
309
+ def verify_exact(self, directory: Path) -> None:
310
+ cmp = type(self).generate_from_directory(directory, ignores=[])
311
+ if cmp != self:
312
+ raise ExactDirectoryVerificationFailed(self, cmp)
313
+
314
+ def verify_inexact(self, directory: Path) -> None:
315
+ self.entries.verify_inexact(directory)
316
+
317
+
318
+ class UnstableManifest(BaseModel):
319
+ schema_version: Literal["unstable"] = "unstable"
320
+ contents: SingleFileManifest | DirectoryManifest = Field(discriminator="manifest_kind")
321
+
322
+ @classmethod
323
+ def generate_from_file(cls, file: BinaryIO) -> Self:
324
+ return cls(contents=SingleFileManifest.generate_from_file(file))
325
+
326
+ @classmethod
327
+ def generate_from_directory(
328
+ cls, directory: Path, *, ignores: Iterable[IgnorePattern] = []
329
+ ) -> Self:
330
+ return cls(contents=DirectoryManifest.generate_from_directory(directory, ignores))
331
+
332
+
333
+ Manifest = Annotated[UnstableManifest, Field(discriminator="schema_version")]
334
+
335
+
336
+ class PackMap(BaseModel):
337
+ """
338
+ Summary of a directory packing operation,
339
+ contains information for creating a torrent from a packed directory
340
+ """
341
+
342
+ piece_size: PieceSize
343
+ files: list[Path]
sciop_cli/torrent.py ADDED
@@ -0,0 +1,102 @@
1
+ from math import floor
2
+ from pathlib import Path
3
+
4
+ import bencode_rs
5
+ import libtorrent
6
+ from pydantic import TypeAdapter
7
+ from tqdm import tqdm
8
+
9
+ from sciop_cli.const import DEFAULT_TORRENT_CREATOR, EXCLUDE_FILES
10
+ from sciop_cli.types import PieceSize
11
+
12
+
13
+ def estimate_piece_size(
14
+ data_size: int, min_pieces: int = 2000, min_piece_size: int = 256 * (2**10)
15
+ ) -> int:
16
+ """
17
+ Estimate the best piece size given some total size (in bytes) of a torrent
18
+
19
+ Largest piece size that still gives us min_pieces.
20
+ Files smaller than the piece size will be packed together into archives,
21
+ so padding files are not much of an overhead concern here.
22
+
23
+ pieces = ceil(size / (multiplier * 16KiB))
24
+ pieces * (multiplier * 16KiB) = size
25
+ multiplier = floor(size / (pieces * 16KiB))
26
+
27
+ """
28
+ block = 16 * (2**10)
29
+ multiplier = floor(data_size / (min_pieces * block))
30
+ piece_size = round(multiplier * block)
31
+ return max(piece_size, min_piece_size)
32
+
33
+
34
+ def create_torrent(
35
+ path: Path,
36
+ trackers: list[str] | None = None,
37
+ comment: str | None = None,
38
+ creator: str = DEFAULT_TORRENT_CREATOR,
39
+ webseeds: list[str] | None = None,
40
+ similar: list[str] | None = None,
41
+ bencode: bool = True,
42
+ piece_size: PieceSize = 512 * (2**10),
43
+ pbar: bool = False,
44
+ ) -> dict | bytes:
45
+ path = Path(path)
46
+ fs = libtorrent.file_storage()
47
+
48
+ if path.is_dir():
49
+ # get paths and sort
50
+ paths = []
51
+ for _path in path.rglob("*"):
52
+ if _path.name not in EXCLUDE_FILES and _path.is_file():
53
+ # no absolute paths in the torrent plz
54
+ rel_path = _path.relative_to(path)
55
+ # add the parent again as the root
56
+ rel_path = Path(path.name) / rel_path
57
+ paths.append((str(rel_path), _path.stat().st_size))
58
+ paths = sorted(paths, key=lambda x: x[0])
59
+ for p, size in paths:
60
+ fs.add_file(p, size)
61
+
62
+ else:
63
+ fs.add_file(path.name, path.stat().st_size)
64
+
65
+ piece_size = TypeAdapter(PieceSize).validate_python(piece_size)
66
+
67
+ torrent = libtorrent.create_torrent(fs, piece_size=piece_size)
68
+
69
+ if trackers:
70
+ for tracker in trackers:
71
+ torrent.add_tracker(tracker)
72
+
73
+ if webseeds:
74
+ for webseed in webseeds:
75
+ torrent.add_url_seed(webseed)
76
+
77
+ if similar:
78
+ for s in similar:
79
+ torrent.add_similar_torrent(s)
80
+
81
+ if comment:
82
+ torrent.set_comment(comment)
83
+
84
+ torrent.set_creator(creator)
85
+
86
+ _pbar = None
87
+ if pbar:
88
+ _pbar = tqdm(desc="hashing pieces...", total=torrent.num_pieces())
89
+
90
+ def _pbar_callback(piece_index: int) -> None:
91
+ _pbar.update()
92
+
93
+ libtorrent.set_piece_hashes(torrent, str(path.parent.resolve()), _pbar_callback)
94
+ _pbar.close()
95
+ else:
96
+ libtorrent.set_piece_hashes(torrent, str(path.parent.resolve()))
97
+
98
+ ret = torrent.generate()
99
+ if bencode:
100
+ return bencode_rs.bencode(ret)
101
+ else:
102
+ return ret
sciop_cli/types.py ADDED
@@ -0,0 +1,17 @@
1
+ from typing import Annotated
2
+
3
+ from pydantic import AfterValidator
4
+
5
+
6
+ def _divisible_by_16kib(size: int) -> bool:
7
+ if size < 0:
8
+ return False
9
+ return size % (16 * (2**10)) == 0
10
+
11
+
12
+ def _validate_size(size: int) -> int:
13
+ assert _divisible_by_16kib(size), "Piece size must be divisible by 16kib and positive"
14
+ return size
15
+
16
+
17
+ PieceSize = Annotated[int, AfterValidator(_validate_size)]
@@ -0,0 +1,32 @@
1
+ Metadata-Version: 2.1
2
+ Name: sciop-cli
3
+ Version: 0.1.1
4
+ Summary: A CLI for sciop
5
+ Author-Email: cosmicexplorer <dmcC2@hypnicjerk.ai>, sneakers-the-rat <sneakers-the-rat@protonmail.com>
6
+ License: EUPL-1.2
7
+ Requires-Python: >=3.11
8
+ Requires-Dist: libtorrent>=2.0.11
9
+ Requires-Dist: click>=8.1.8
10
+ Requires-Dist: click-option-group>=0.5.6
11
+ Requires-Dist: pydantic>=2.10.6
12
+ Requires-Dist: pandera[mypy]>=0.23.1
13
+ Requires-Dist: bencode-rs>=0.0.7
14
+ Requires-Dist: platformdirs>=4.3.7
15
+ Requires-Dist: requests>=2.32.3
16
+ Requires-Dist: tqdm>=4.67.1
17
+ Requires-Dist: rich>=14.0.0
18
+ Provides-Extra: test
19
+ Requires-Dist: pytest>=8.3.4; extra == "test"
20
+ Provides-Extra: mypy
21
+ Requires-Dist: mypy>=1.15; extra == "mypy"
22
+ Requires-Dist: types-tqdm>=4.67.0.20250401; extra == "mypy"
23
+ Requires-Dist: types-requests>=2.32.0.20250328; extra == "mypy"
24
+ Provides-Extra: dev
25
+ Requires-Dist: sciop-cli[mypy,test]; extra == "dev"
26
+ Requires-Dist: ruff>=0.9.7; extra == "dev"
27
+ Requires-Dist: black>=25.1.0; extra == "dev"
28
+ Description-Content-Type: text/markdown
29
+
30
+ # sciop-cli
31
+
32
+ a CLI for sciop!
@@ -0,0 +1,18 @@
1
+ sciop_cli-0.1.1.dist-info/METADATA,sha256=5KFv0H2__rV6exw5Kzcr66cZsOoFJuzH1szJoRKL9Lw,1036
2
+ sciop_cli-0.1.1.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
+ sciop_cli-0.1.1.dist-info/entry_points.txt,sha256=GYVsnqE1Pmh6A5N0BQ36QYwYhbdJejFHNfs1QmXcXys,69
4
+ sciop_cli-0.1.1.dist-info/licenses/LICENSE,sha256=V_tC-80LA3zlKO2PcvHsCV1nvGgl7PFEj_Ob4f5opLQ,13792
5
+ sciop_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ sciop_cli/__main__.py,sha256=nJQrX6ZaDCsvLNRO2oXoqLnxghfDXQZkO38YU_iuSJw,42
7
+ sciop_cli/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ sciop_cli/cli/main.py,sha256=yPP7Hi0Qs9Ah5FhuhJt4kTZyaL5QD7urnLsV0lZn_hI,522
9
+ sciop_cli/cli/manifest.py,sha256=JFuitLE4jcihiR0XAIqDK2MBSrkJtA_g9eBjNIWr8TE,3975
10
+ sciop_cli/cli/torrent.py,sha256=vgdqu6MppHnnrroTllbIcENECVF601PAaPDnFpfGjPU,3700
11
+ sciop_cli/const.py,sha256=nsmSU_ZvC9mBbemCcBkonyRrQXmfSFhDZZlU6houaqs,130
12
+ sciop_cli/data.py,sha256=kFGSJhicH33mMFx6C2hl650ziK1s9Btd6plndA39ocI,843
13
+ sciop_cli/file.py,sha256=B_DpPe1LfmnTPGy-e-ge0DJDCfcKbFwo32Kq-gfuMIw,1123
14
+ sciop_cli/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
+ sciop_cli/schema.py,sha256=Db6YqnRAmtEdwfSkSq4C8IP5vEWetYtV8waHPW7Aqu0,12625
16
+ sciop_cli/torrent.py,sha256=DPovEJJp0G4TlER0T5HSjhJXINPy0GjZ4A7R2hn-Iqk,2984
17
+ sciop_cli/types.py,sha256=wk_IbltoMXKxQ1VoqtDqdMoU3PWfzSiYYkhZ-bX5zoU,396
18
+ sciop_cli-0.1.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: pdm-backend (2.4.3)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,5 @@
1
+ [console_scripts]
2
+ sciop-cli = sciop_cli.cli.main:cli
3
+
4
+ [gui_scripts]
5
+
@@ -0,0 +1,190 @@
1
+ EUROPEAN UNION PUBLIC LICENCE v. 1.2
2
+ EUPL © the European Union 2007, 2016
3
+
4
+ This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined below) which is provided under the
5
+ terms of this Licence. Any use of the Work, other than as authorised under this Licence is prohibited (to the extent such
6
+ use is covered by a right of the copyright holder of the Work).
7
+ The Work is provided under the terms of this Licence when the Licensor (as defined below) has placed the following
8
+ notice immediately following the copyright notice for the Work:
9
+ Licensed under the EUPL
10
+ or has expressed by any other means his willingness to license under the EUPL.
11
+
12
+ 1.Definitions
13
+ In this Licence, the following terms have the following meaning:
14
+ — ‘The Licence’:this Licence.
15
+ — ‘The Original Work’:the work or software distributed or communicated by the Licensor under this Licence, available
16
+ as Source Code and also as Executable Code as the case may be.
17
+ — ‘Derivative Works’:the works or software that could be created by the Licensee, based upon the Original Work or
18
+ modifications thereof. This Licence does not define the extent of modification or dependence on the Original Work
19
+ required in order to classify a work as a Derivative Work; this extent is determined by copyright law applicable in
20
+ the country mentioned in Article 15.
21
+ — ‘The Work’:the Original Work or its Derivative Works.
22
+ — ‘The Source Code’:the human-readable form of the Work which is the most convenient for people to study and
23
+ modify.
24
+ — ‘The Executable Code’:any code which has generally been compiled and which is meant to be interpreted by
25
+ a computer as a program.
26
+ — ‘The Licensor’:the natural or legal person that distributes or communicates the Work under the Licence.
27
+ — ‘Contributor(s)’:any natural or legal person who modifies the Work under the Licence, or otherwise contributes to
28
+ the creation of a Derivative Work.
29
+ — ‘The Licensee’ or ‘You’:any natural or legal person who makes any usage of the Work under the terms of the
30
+ Licence.
31
+ — ‘Distribution’ or ‘Communication’:any act of selling, giving, lending, renting, distributing, communicating,
32
+ transmitting, or otherwise making available, online or offline, copies of the Work or providing access to its essential
33
+ functionalities at the disposal of any other natural or legal person.
34
+
35
+ 2.Scope of the rights granted by the Licence
36
+ The Licensor hereby grants You a worldwide, royalty-free, non-exclusive, sublicensable licence to do the following, for
37
+ the duration of copyright vested in the Original Work:
38
+ — use the Work in any circumstance and for all usage,
39
+ — reproduce the Work,
40
+ — modify the Work, and make Derivative Works based upon the Work,
41
+ — communicate to the public, including the right to make available or display the Work or copies thereof to the public
42
+ and perform publicly, as the case may be, the Work,
43
+ — distribute the Work or copies thereof,
44
+ — lend and rent the Work or copies thereof,
45
+ — sublicense rights in the Work or copies thereof.
46
+ Those rights can be exercised on any media, supports and formats, whether now known or later invented, as far as the
47
+ applicable law permits so.
48
+ In the countries where moral rights apply, the Licensor waives his right to exercise his moral right to the extent allowed
49
+ by law in order to make effective the licence of the economic rights here above listed.
50
+ The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to any patents held by the Licensor, to the
51
+ extent necessary to make use of the rights granted on the Work under this Licence.
52
+
53
+ 3.Communication of the Source Code
54
+ The Licensor may provide the Work either in its Source Code form, or as Executable Code. If the Work is provided as
55
+ Executable Code, the Licensor provides in addition a machine-readable copy of the Source Code of the Work along with
56
+ each copy of the Work that the Licensor distributes or indicates, in a notice following the copyright notice attached to
57
+ the Work, a repository where the Source Code is easily and freely accessible for as long as the Licensor continues to
58
+ distribute or communicate the Work.
59
+
60
+ 4.Limitations on copyright
61
+ Nothing in this Licence is intended to deprive the Licensee of the benefits from any exception or limitation to the
62
+ exclusive rights of the rights owners in the Work, of the exhaustion of those rights or of other applicable limitations
63
+ thereto.
64
+
65
+ 5.Obligations of the Licensee
66
+ The grant of the rights mentioned above is subject to some restrictions and obligations imposed on the Licensee. Those
67
+ obligations are the following:
68
+
69
+ Attribution right: The Licensee shall keep intact all copyright, patent or trademarks notices and all notices that refer to
70
+ the Licence and to the disclaimer of warranties. The Licensee must include a copy of such notices and a copy of the
71
+ Licence with every copy of the Work he/she distributes or communicates. The Licensee must cause any Derivative Work
72
+ to carry prominent notices stating that the Work has been modified and the date of modification.
73
+
74
+ Copyleft clause: If the Licensee distributes or communicates copies of the Original Works or Derivative Works, this
75
+ Distribution or Communication will be done under the terms of this Licence or of a later version of this Licence unless
76
+ the Original Work is expressly distributed only under this version of the Licence — for example by communicating
77
+ ‘EUPL v. 1.2 only’. The Licensee (becoming Licensor) cannot offer or impose any additional terms or conditions on the
78
+ Work or Derivative Work that alter or restrict the terms of the Licence.
79
+
80
+ Compatibility clause: If the Licensee Distributes or Communicates Derivative Works or copies thereof based upon both
81
+ the Work and another work licensed under a Compatible Licence, this Distribution or Communication can be done
82
+ under the terms of this Compatible Licence. For the sake of this clause, ‘Compatible Licence’ refers to the licences listed
83
+ in the appendix attached to this Licence. Should the Licensee's obligations under the Compatible Licence conflict with
84
+ his/her obligations under this Licence, the obligations of the Compatible Licence shall prevail.
85
+
86
+ Provision of Source Code: When distributing or communicating copies of the Work, the Licensee will provide
87
+ a machine-readable copy of the Source Code or indicate a repository where this Source will be easily and freely available
88
+ for as long as the Licensee continues to distribute or communicate the Work.
89
+ Legal Protection: This Licence does not grant permission to use the trade names, trademarks, service marks, or names
90
+ of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and
91
+ reproducing the content of the copyright notice.
92
+
93
+ 6.Chain of Authorship
94
+ The original Licensor warrants that the copyright in the Original Work granted hereunder is owned by him/her or
95
+ licensed to him/her and that he/she has the power and authority to grant the Licence.
96
+ Each Contributor warrants that the copyright in the modifications he/she brings to the Work are owned by him/her or
97
+ licensed to him/her and that he/she has the power and authority to grant the Licence.
98
+ Each time You accept the Licence, the original Licensor and subsequent Contributors grant You a licence to their contributions
99
+ to the Work, under the terms of this Licence.
100
+
101
+ 7.Disclaimer of Warranty
102
+ The Work is a work in progress, which is continuously improved by numerous Contributors. It is not a finished work
103
+ and may therefore contain defects or ‘bugs’ inherent to this type of development.
104
+ For the above reason, the Work is provided under the Licence on an ‘as is’ basis and without warranties of any kind
105
+ concerning the Work, including without limitation merchantability, fitness for a particular purpose, absence of defects or
106
+ errors, accuracy, non-infringement of intellectual property rights other than copyright as stated in Article 6 of this
107
+ Licence.
108
+ This disclaimer of warranty is an essential part of the Licence and a condition for the grant of any rights to the Work.
109
+
110
+ 8.Disclaimer of Liability
111
+ Except in the cases of wilful misconduct or damages directly caused to natural persons, the Licensor will in no event be
112
+ liable for any direct or indirect, material or moral, damages of any kind, arising out of the Licence or of the use of the
113
+ Work, including without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, loss
114
+ of data or any commercial damage, even if the Licensor has been advised of the possibility of such damage. However,
115
+ the Licensor will be liable under statutory product liability laws as far such laws apply to the Work.
116
+
117
+ 9.Additional agreements
118
+ While distributing the Work, You may choose to conclude an additional agreement, defining obligations or services
119
+ consistent with this Licence. However, if accepting obligations, You may act only on your own behalf and on your sole
120
+ responsibility, not on behalf of the original Licensor or any other Contributor, and only if You agree to indemnify,
121
+ defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against such Contributor by
122
+ the fact You have accepted any warranty or additional liability.
123
+
124
+ 10.Acceptance of the Licence
125
+ The provisions of this Licence can be accepted by clicking on an icon ‘I agree’ placed under the bottom of a window
126
+ displaying the text of this Licence or by affirming consent in any other similar way, in accordance with the rules of
127
+ applicable law. Clicking on that icon indicates your clear and irrevocable acceptance of this Licence and all of its terms
128
+ and conditions.
129
+ Similarly, you irrevocably accept this Licence and all of its terms and conditions by exercising any rights granted to You
130
+ by Article 2 of this Licence, such as the use of the Work, the creation by You of a Derivative Work or the Distribution
131
+ or Communication by You of the Work or copies thereof.
132
+
133
+ 11.Information to the public
134
+ In case of any Distribution or Communication of the Work by means of electronic communication by You (for example,
135
+ by offering to download the Work from a remote location) the distribution channel or media (for example, a website)
136
+ must at least provide to the public the information requested by the applicable law regarding the Licensor, the Licence
137
+ and the way it may be accessible, concluded, stored and reproduced by the Licensee.
138
+
139
+ 12.Termination of the Licence
140
+ The Licence and the rights granted hereunder will terminate automatically upon any breach by the Licensee of the terms
141
+ of the Licence.
142
+ Such a termination will not terminate the licences of any person who has received the Work from the Licensee under
143
+ the Licence, provided such persons remain in full compliance with the Licence.
144
+
145
+ 13.Miscellaneous
146
+ Without prejudice of Article 9 above, the Licence represents the complete agreement between the Parties as to the
147
+ Work.
148
+ If any provision of the Licence is invalid or unenforceable under applicable law, this will not affect the validity or
149
+ enforceability of the Licence as a whole. Such provision will be construed or reformed so as necessary to make it valid
150
+ and enforceable.
151
+ The European Commission may publish other linguistic versions or new versions of this Licence or updated versions of
152
+ the Appendix, so far this is required and reasonable, without reducing the scope of the rights granted by the Licence.
153
+ New versions of the Licence will be published with a unique version number.
154
+ All linguistic versions of this Licence, approved by the European Commission, have identical value. Parties can take
155
+ advantage of the linguistic version of their choice.
156
+
157
+ 14.Jurisdiction
158
+ Without prejudice to specific agreement between parties,
159
+ — any litigation resulting from the interpretation of this License, arising between the European Union institutions,
160
+ bodies, offices or agencies, as a Licensor, and any Licensee, will be subject to the jurisdiction of the Court of Justice
161
+ of the European Union, as laid down in article 272 of the Treaty on the Functioning of the European Union,
162
+ — any litigation arising between other parties and resulting from the interpretation of this License, will be subject to
163
+ the exclusive jurisdiction of the competent court where the Licensor resides or conducts its primary business.
164
+
165
+ 15.Applicable Law
166
+ Without prejudice to specific agreement between parties,
167
+ — this Licence shall be governed by the law of the European Union Member State where the Licensor has his seat,
168
+ resides or has his registered office,
169
+ — this licence shall be governed by Belgian law if the Licensor has no seat, residence or registered office inside
170
+ a European Union Member State.
171
+
172
+
173
+ Appendix
174
+
175
+ ‘Compatible Licences’ according to Article 5 EUPL are:
176
+ — GNU General Public License (GPL) v. 2, v. 3
177
+ — GNU Affero General Public License (AGPL) v. 3
178
+ — Open Software License (OSL) v. 2.1, v. 3.0
179
+ — Eclipse Public License (EPL) v. 1.0
180
+ — CeCILL v. 2.0, v. 2.1
181
+ — Mozilla Public Licence (MPL) v. 2
182
+ — GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
183
+ — Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for works other than software
184
+ — European Union Public Licence (EUPL) v. 1.1, v. 1.2
185
+ — Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong Reciprocity (LiLiQ-R+).
186
+
187
+ The European Commission may update this Appendix to later versions of the above licences without producing
188
+ a new version of the EUPL, as long as they provide the rights granted in Article 2 of this Licence and protect the
189
+ covered Source Code from exclusive appropriation.
190
+ All other changes or additions to this Appendix require the production of a new EUPL version.