pysidtracker 0.1.0__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.
@@ -0,0 +1,50 @@
1
+ """Shared base for the pure-Python C64 SID tracker parsers.
2
+
3
+ Provides the one PSID/RSID container parser, the loaded-image model, the source
4
+ dispatch, the error hierarchy, and the packed/relocating playroutine detector
5
+ that the ``py*`` format packages (pygoattracker, pysidwizard, pydmcsid,
6
+ pyfuturecomposer, pymusicassembler, pydefmon, pyjch) build on for a consistent
7
+ API.
8
+ """
9
+
10
+ from .base import BaseSidParser
11
+ from .detect import (
12
+ Detection,
13
+ PlayroutineKind,
14
+ Recognizer,
15
+ detect_playroutine,
16
+ run_init,
17
+ )
18
+ from .errors import (
19
+ EmulatorUnavailable,
20
+ SidError,
21
+ SidFormatError,
22
+ SidParseError,
23
+ )
24
+ from .header import PSID_MAGIC, RSID_MAGIC, SidHeader, parse_sid_header
25
+ from .image import MEM_SIZE, SidImage
26
+ from .source import Source, read_bytes
27
+
28
+ __version__ = "0.1.0"
29
+
30
+ __all__ = [
31
+ "BaseSidParser",
32
+ "Detection",
33
+ "EmulatorUnavailable",
34
+ "MEM_SIZE",
35
+ "PSID_MAGIC",
36
+ "PlayroutineKind",
37
+ "RSID_MAGIC",
38
+ "Recognizer",
39
+ "SidError",
40
+ "SidFormatError",
41
+ "SidHeader",
42
+ "SidImage",
43
+ "SidParseError",
44
+ "Source",
45
+ "__version__",
46
+ "detect_playroutine",
47
+ "parse_sid_header",
48
+ "read_bytes",
49
+ "run_init",
50
+ ]
pysidtracker/_scan.py ADDED
@@ -0,0 +1,115 @@
1
+ """Fast searches over a 64 KiB C64 memory image.
2
+
3
+ The static playroutine-recognition step scans the loaded image for known byte
4
+ signatures and for anchor tables (a low half immediately followed by a matching
5
+ high half, e.g. the split note-frequency table many players embed). Both are
6
+ numpy-accelerated when numpy is importable and fall back to pure-stdlib
7
+ scanning otherwise, so the base install stays dependency-free.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from typing import List, Optional, Sequence
13
+
14
+ try: # numpy is an optional accelerator, never required.
15
+ import numpy as _np
16
+ except ImportError: # pragma: no cover - exercised only without numpy
17
+ _np = None
18
+
19
+
20
+ def find_all(mem: Sequence[int], needle: bytes, start: int = 0) -> List[int]:
21
+ """Return every index >= ``start`` where ``needle`` occurs in ``mem``."""
22
+ if not needle:
23
+ return []
24
+ buf = bytes(mem)
25
+ hits = []
26
+ pos = buf.find(needle, start)
27
+ while pos != -1:
28
+ hits.append(pos)
29
+ pos = buf.find(needle, pos + 1)
30
+ return hits
31
+
32
+
33
+ def find_first(mem: Sequence[int], needle: bytes, start: int = 0) -> int:
34
+ """Return the first index >= ``start`` of ``needle`` in ``mem``, or ``-1``."""
35
+ return bytes(mem).find(needle, start)
36
+
37
+
38
+ def find_split_table(
39
+ mem: Sequence[int],
40
+ lo: Sequence[int],
41
+ hi: Sequence[int],
42
+ *,
43
+ min_length: int = 8,
44
+ limit: int = 0x10000,
45
+ ) -> Optional[tuple]:
46
+ """Locate a split lo/hi table anchor in ``mem``.
47
+
48
+ Players commonly embed a two-column table as ``lo[first:first+n]`` directly
49
+ followed by ``hi[first:first+n]`` (a contiguous slice of a longer known
50
+ table, ``lo``/``hi``). Returns ``(addr, first, length)`` for the longest
51
+ such match with ``length >= min_length``, or ``None``. ``addr`` is the start
52
+ of the low column; the high column starts at ``addr + length``.
53
+ """
54
+ lo = bytes(lo)
55
+ hi = bytes(hi)
56
+ n = len(lo)
57
+ if n == 0 or len(hi) != n:
58
+ return None
59
+ limit = min(limit, len(mem))
60
+ if _np is not None:
61
+ return _find_split_table_np(mem, lo, hi, n, min_length, limit)
62
+ return _find_split_table_py(mem, lo, hi, n, min_length, limit)
63
+
64
+
65
+ def _find_split_table_py(mem, lo, hi, n, min_length, limit):
66
+ best = None
67
+ # A table needs 2*min_length bytes, so the last viable start is
68
+ # ``limit - 2 * min_length`` inclusive (a table ending exactly at ``limit``).
69
+ for addr in range(0, limit - 2 * min_length + 1):
70
+ first = mem[addr]
71
+ for fn in range(n):
72
+ if lo[fn] != first:
73
+ continue
74
+ length = 0
75
+ while (
76
+ fn + length < n
77
+ and addr + length < limit
78
+ and mem[addr + length] == lo[fn + length]
79
+ ):
80
+ length += 1
81
+ if length < min_length or addr + 2 * length > limit:
82
+ continue
83
+ if all(mem[addr + length + i] == hi[fn + i] for i in range(length)):
84
+ if best is None or length > best[2]:
85
+ best = (addr, fn, length)
86
+ return best
87
+
88
+
89
+ def _find_split_table_np(mem, lo, hi, n, min_length, limit):
90
+ arr = _np.frombuffer(bytes(mem)[:limit], dtype=_np.uint8)
91
+ lo_np = _np.frombuffer(lo, dtype=_np.uint8)
92
+ best = None
93
+ # For each possible table offset ``fn`` and run length, a match requires the
94
+ # lo slice at ``addr`` and the hi slice at ``addr+length`` to line up. We
95
+ # scan candidate start addresses cheaply by matching the first lo byte, then
96
+ # verify/extend in the (small) candidate set.
97
+ for fn in range(n):
98
+ starts = _np.nonzero(arr == lo_np[fn])[0]
99
+ for addr in starts.tolist():
100
+ length = 0
101
+ while (
102
+ fn + length < n
103
+ and addr + length < limit
104
+ and arr[addr + length] == lo[fn + length]
105
+ ):
106
+ length += 1
107
+ if length < min_length or addr + 2 * length > limit:
108
+ continue
109
+ if (
110
+ bytes(arr[addr + length : addr + 2 * length].tolist())
111
+ == hi[fn : fn + length]
112
+ ):
113
+ if best is None or length > best[2]:
114
+ best = (addr, fn, length)
115
+ return best
pysidtracker/base.py ADDED
@@ -0,0 +1,72 @@
1
+ """The base class every ``py*`` SID parser subclasses for a consistent API.
2
+
3
+ A concrete parser implements :meth:`BaseSidParser.parse` (bytes -> its own song
4
+ model) and, to gain packed/relocating detection for free, the cheap
5
+ :meth:`BaseSidParser.recognize` predicate. In return it inherits a uniform
6
+ ``read``/``parse``/``detect`` surface identical across every format.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import abc
12
+ from typing import Any
13
+
14
+ from .detect import Detection, detect_playroutine
15
+ from .errors import SidParseError
16
+ from .image import SidImage
17
+ from .source import Source, read_bytes
18
+
19
+
20
+ class BaseSidParser(abc.ABC):
21
+ """Abstract base giving every SID parser the same entry points.
22
+
23
+ Subclass responsibilities:
24
+ * :meth:`parse` -- decode raw container bytes into the format's song model.
25
+ * :meth:`recognize` (optional) -- return a truthy anchor when the format's
26
+ signature is present in a loaded image, enabling :meth:`detect`.
27
+
28
+ Inherited for free: :meth:`read` (path/bytes/file dispatch) and
29
+ :meth:`detect` (untrustworthy-header handling via
30
+ :func:`pysidtracker.detect.detect_playroutine`).
31
+ """
32
+
33
+ #: Exception type raised for parse failures; subclasses may narrow this to
34
+ #: their own :class:`~pysidtracker.errors.SidParseError` subclass.
35
+ error_class: type = SidParseError
36
+
37
+ @abc.abstractmethod
38
+ def parse(self, data: bytes, **kwargs: Any) -> Any:
39
+ """Decode raw ``.sid``/``.prg`` ``data`` into the format's song model."""
40
+
41
+ def read(self, src: Source, **kwargs: Any) -> Any:
42
+ """Read ``src`` (path, ``bytes``, or file-like) and :meth:`parse` it."""
43
+ return self.parse(read_bytes(src), **kwargs)
44
+
45
+ def load_image(self, data: bytes) -> SidImage:
46
+ """Load ``data`` into a :class:`~pysidtracker.image.SidImage`."""
47
+ return SidImage.from_bytes(data)
48
+
49
+ def recognize(self, image: SidImage) -> object: # pylint: disable=unused-argument
50
+ """Return a truthy anchor if this format is present in ``image``.
51
+
52
+ The default returns ``None`` (no static recogniser). Override to enable
53
+ :meth:`detect`.
54
+ """
55
+ return None
56
+
57
+ def detect(
58
+ self,
59
+ src: Source,
60
+ *,
61
+ init: bool = True,
62
+ subtune: int = 0,
63
+ ) -> Detection:
64
+ """Classify how ``src`` presents its playroutine data.
65
+
66
+ See :func:`pysidtracker.detect.detect_playroutine`. Uses
67
+ :meth:`recognize`; returns
68
+ :attr:`~pysidtracker.detect.PlayroutineKind.UNKNOWN` for parsers that do
69
+ not override it.
70
+ """
71
+ image = self.load_image(read_bytes(src))
72
+ return detect_playroutine(image, self.recognize, init=init, subtune=subtune)
pysidtracker/detect.py ADDED
@@ -0,0 +1,181 @@
1
+ """Detect compressed / packed / relocating playroutines in a first parse.
2
+
3
+ A ``.sid`` header advertises a load address, an init address and a subtune
4
+ count, but for many real tunes these describe a *loader* or *packer*, not the
5
+ playroutine: the actual song tables only exist after the init routine unpacks or
6
+ relocates them into memory. The header is therefore untrustworthy for locating
7
+ data.
8
+
9
+ The shared strategy (generalised from pygoattracker's ``.sid`` decompiler):
10
+
11
+ 1. **Static recognition.** Ask the format's ``recognize`` callback to find its
12
+ signature/anchor in the freshly loaded image. If it succeeds the tune is
13
+ :attr:`PlayroutineKind.DIRECT` -- a plain direct-load image.
14
+ 2. **Emulated init.** Otherwise the playroutine is packed/relocating: run its
15
+ init routine in a 6502 emulator so the data lands where it really goes, then
16
+ recognise again. Whether init had to *expand* memory (decompression) or only
17
+ *move*/rewrite the existing image classifies it as
18
+ :attr:`PlayroutineKind.PACKED` vs :attr:`PlayroutineKind.RELOCATED`.
19
+ 3. If recognition still fails, :attr:`PlayroutineKind.UNKNOWN`.
20
+
21
+ Each parser supplies only the cheap ``recognize`` predicate; this module owns
22
+ the untrustworthy-header handling so every format gets it identically.
23
+ """
24
+
25
+ from __future__ import annotations
26
+
27
+ import enum
28
+ from dataclasses import dataclass
29
+ from typing import Callable
30
+
31
+ from .errors import EmulatorUnavailable, SidParseError
32
+ from .image import MEM_SIZE, SidImage
33
+
34
+ # recognize(image) -> anchor (any truthy value) if the format is found, else None.
35
+ Recognizer = Callable[[SidImage], object]
36
+
37
+
38
+ class PlayroutineKind(enum.Enum):
39
+ """How a tune's playroutine presents its data in the loaded image."""
40
+
41
+ DIRECT = "direct" # data found statically, as loaded
42
+ RELOCATED = "relocated" # found only after init moved/rewrote the image
43
+ PACKED = "packed" # found only after init expanded (decompressed) memory
44
+ UNKNOWN = "unknown" # not recognised, even after running init
45
+
46
+
47
+ @dataclass
48
+ class Detection:
49
+ """Outcome of :func:`detect_playroutine`.
50
+
51
+ Attributes:
52
+ kind: the :class:`PlayroutineKind`.
53
+ ran_init: whether the init routine had to be emulated.
54
+ anchor: whatever the ``recognize`` callback returned (``None`` if
55
+ unrecognised) -- often the address/offset it found, reusable by the
56
+ caller's full parse.
57
+ changed_inside: bytes within the originally loaded region that init
58
+ altered (self-modifying / in-place unpacking).
59
+ written_outside: bytes outside the originally loaded region that init
60
+ wrote (relocation targets / decompression output).
61
+ """
62
+
63
+ kind: PlayroutineKind
64
+ ran_init: bool
65
+ anchor: object = None
66
+ changed_inside: int = 0
67
+ written_outside: int = 0
68
+
69
+ @property
70
+ def recognised(self) -> bool:
71
+ return self.kind is not PlayroutineKind.UNKNOWN
72
+
73
+ @property
74
+ def trustworthy_header(self) -> bool:
75
+ """True when the header described the data directly (no init needed)."""
76
+ return self.kind is PlayroutineKind.DIRECT
77
+
78
+
79
+ def detect_playroutine(
80
+ image: SidImage,
81
+ recognize: Recognizer,
82
+ *,
83
+ init: bool = True,
84
+ subtune: int = 0,
85
+ ) -> Detection:
86
+ """Classify how ``image`` presents its playroutine data.
87
+
88
+ ``recognize`` inspects the (possibly unpacked) image and returns a truthy
89
+ anchor when it finds the format, else ``None``. When static recognition
90
+ fails and ``init`` is true, the init routine is emulated (requires the
91
+ optional ``py65`` dependency) and recognition retried.
92
+
93
+ Raises :class:`EmulatorUnavailable` if emulation is needed but ``py65`` is
94
+ not installed.
95
+ """
96
+ anchor = recognize(image)
97
+ if anchor:
98
+ return Detection(PlayroutineKind.DIRECT, ran_init=False, anchor=anchor)
99
+ if not init:
100
+ return Detection(PlayroutineKind.UNKNOWN, ran_init=False)
101
+
102
+ orig_load, orig_end = image.load, image.end
103
+ snapshot = bytes(image.mem[orig_load:orig_end])
104
+ run_init(image, subtune=subtune)
105
+ image.end = MEM_SIZE # init may have scattered data anywhere
106
+
107
+ changed_inside = _count_changed(image.mem, orig_load, snapshot)
108
+ written_outside = _count_written_outside(image.mem, orig_load, orig_end)
109
+
110
+ anchor = recognize(image)
111
+ if not anchor:
112
+ kind = PlayroutineKind.UNKNOWN
113
+ elif written_outside > changed_inside:
114
+ kind = PlayroutineKind.PACKED
115
+ else:
116
+ kind = PlayroutineKind.RELOCATED
117
+ return Detection(
118
+ kind,
119
+ ran_init=True,
120
+ anchor=anchor,
121
+ changed_inside=changed_inside,
122
+ written_outside=written_outside,
123
+ )
124
+
125
+
126
+ # The 6502 stack page is scratch space the init run (and our return-address
127
+ # stub) churns; it is never song data, so it is excluded from the diff metrics.
128
+ _STACK_LO = 0x0100
129
+ _STACK_HI = 0x0200
130
+
131
+
132
+ def _count_changed(mem: bytearray, load: int, snapshot: bytes) -> int:
133
+ return sum(1 for i, b in enumerate(snapshot) if mem[load + i] != b)
134
+
135
+
136
+ def _count_written_outside(mem: bytearray, load: int, end: int) -> int:
137
+ written = 0
138
+ for addr, value in enumerate(mem):
139
+ if not value:
140
+ continue
141
+ if load <= addr < end:
142
+ continue
143
+ if _STACK_LO <= addr < _STACK_HI:
144
+ continue
145
+ written += 1
146
+ return written
147
+
148
+
149
+ def run_init(image: SidImage, subtune: int = 0, max_cycles: int = 8_000_000) -> None:
150
+ """Run the tune's init routine in a 6502 emulator so data lands in place.
151
+
152
+ Mutates ``image.mem`` directly. ``subtune`` is passed to init in the
153
+ accumulator (the SID calling convention). Requires the optional ``py65``
154
+ dependency; raises :class:`EmulatorUnavailable` if it is missing and
155
+ :class:`SidParseError` if the image has no init address to call.
156
+ """
157
+ if image.header is None:
158
+ raise SidParseError("cannot run init: image has no SID header")
159
+ init_address = image.header.init_address or image.header.real_load_address
160
+ try:
161
+ from py65.devices.mpu6502 import MPU
162
+ except ImportError as exc: # pragma: no cover - optional dependency
163
+ raise EmulatorUnavailable(
164
+ "py65 is required to unpack this tune (packed/relocating): "
165
+ "pip install pysidtracker[emu]"
166
+ ) from exc
167
+ mpu = MPU(memory=image.mem)
168
+ start_sp = mpu.sp
169
+ # Push a return address so the routine's final RTS lands back in our stub
170
+ # and the loop below (sp climbing back above start_sp) terminates.
171
+ image.mem[0x0100 + mpu.sp] = 0x00
172
+ mpu.sp = (mpu.sp - 1) & 0xFF
173
+ image.mem[0x0100 + mpu.sp] = 0x01
174
+ mpu.sp = (mpu.sp - 1) & 0xFF
175
+ mpu.a = subtune & 0xFF
176
+ mpu.pc = init_address
177
+ start_cycles = mpu.processorCycles
178
+ while mpu.sp < start_sp:
179
+ mpu.step()
180
+ if mpu.processorCycles - start_cycles > max_cycles:
181
+ break
pysidtracker/errors.py ADDED
@@ -0,0 +1,28 @@
1
+ """Exception hierarchy shared by the ``py*`` SID tracker parsers.
2
+
3
+ Every parser raises errors that derive from :class:`SidError`, so a caller can
4
+ ``except SidError`` across formats. Individual packages subclass these to keep
5
+ their own format-specific names (e.g. a GoatTracker ``SngParseError``) while
6
+ staying catchable through the shared base.
7
+ """
8
+
9
+
10
+ class SidError(Exception):
11
+ """Base class for all pysidtracker errors."""
12
+
13
+
14
+ class SidParseError(SidError):
15
+ """A ``.sid``/``.prg`` image could not be parsed."""
16
+
17
+
18
+ class SidFormatError(SidParseError):
19
+ """The container is not a recognised PSID/RSID/PRG, or is truncated."""
20
+
21
+
22
+ class EmulatorUnavailable(SidError):
23
+ """The optional 6502 emulator (``py65``) is needed but not installed.
24
+
25
+ Raised when detection has to run a packed/relocating tune's init routine to
26
+ materialise its data and :mod:`py65` is missing. Install the extra with
27
+ ``pip install pysidtracker[emu]``.
28
+ """
pysidtracker/header.py ADDED
@@ -0,0 +1,151 @@
1
+ """PSID/RSID (``.sid``) container-header parsing.
2
+
3
+ The outer SID *container* is a big-endian header (documented at
4
+ https://www.hvsc.c64.org/download/C64Music/DOCUMENTS/SID_file_format.txt)
5
+ wrapping a raw C64 memory image (player code + song data). Every parser in the
6
+ family unwraps this identically; :func:`parse_sid_header` is that one
7
+ implementation.
8
+
9
+ The header's advertised load/init/play addresses and subtune count are *not*
10
+ trustworthy for packed, relocating, or crunched tunes -- the real layout only
11
+ exists after the init routine runs. This module resolves the on-disk fields;
12
+ :mod:`pysidtracker.detect` handles the untrustworthy-header problem.
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ from dataclasses import dataclass
18
+
19
+ from .errors import SidFormatError
20
+
21
+ PSID_MAGIC = b"PSID"
22
+ RSID_MAGIC = b"RSID"
23
+
24
+ # Field offsets within the (big-endian) SID container header.
25
+ _MAGIC_POS = 0x00
26
+ _VERSION_POS = 0x04
27
+ _DATA_OFFSET_POS = 0x06
28
+ _LOAD_ADDRESS_POS = 0x08
29
+ _INIT_ADDRESS_POS = 0x0A
30
+ _PLAY_ADDRESS_POS = 0x0C
31
+ _SONGS_POS = 0x0E
32
+ _START_SONG_POS = 0x10
33
+ _NAME_POS = 0x16
34
+ _AUTHOR_POS = 0x36
35
+ _RELEASED_POS = 0x56
36
+ _STR_LEN = 0x20
37
+ _FLAGS_POS = 0x76
38
+ _SECOND_SID_POS = 0x7A # v3+: address byte of the 2nd SID (0 => single SID)
39
+ _THIRD_SID_POS = 0x7C # v4+: address byte of the 3rd SID
40
+
41
+
42
+ def _u16be(data: bytes, pos: int) -> int:
43
+ return (data[pos] << 8) | data[pos + 1]
44
+
45
+
46
+ def _decode_str(raw: bytes) -> str:
47
+ return raw.split(b"\0", 1)[0].decode("latin-1")
48
+
49
+
50
+ @dataclass
51
+ class SidHeader:
52
+ """Decoded SID-container header fields.
53
+
54
+ :attr:`load_address` is the raw header field (``0`` for the common
55
+ "load address lives in the first two bytes of the data" case);
56
+ :attr:`real_load_address` is the resolved C64 address the image loads at and
57
+ :attr:`data_start` is the file offset of the first byte of that image.
58
+ """
59
+
60
+ magic: bytes
61
+ version: int
62
+ data_offset: int
63
+ load_address: int
64
+ init_address: int
65
+ play_address: int
66
+ songs: int
67
+ start_song: int
68
+ name: str
69
+ author: str
70
+ released: str
71
+ flags: int
72
+ second_sid: int
73
+ third_sid: int
74
+ real_load_address: int
75
+ data_start: int
76
+
77
+ @property
78
+ def is_psid(self) -> bool:
79
+ return self.magic == PSID_MAGIC
80
+
81
+ @property
82
+ def is_rsid(self) -> bool:
83
+ return self.magic == RSID_MAGIC
84
+
85
+ @property
86
+ def is_multi_sid(self) -> bool:
87
+ """True if the header advertises a 2nd/3rd/4th SID chip."""
88
+ return self.version >= 3 and (self.second_sid != 0 or self.third_sid != 0)
89
+
90
+
91
+ def parse_sid_header(data: bytes) -> SidHeader:
92
+ """Decode the PSID/RSID container header at the start of ``data``.
93
+
94
+ Raises :class:`SidFormatError` if the magic is neither ``PSID`` nor ``RSID``
95
+ or the header is truncated. When the header ``loadAddress`` field is ``0``
96
+ the real load address is read from the first little-endian word of the data
97
+ area (and :attr:`SidHeader.data_start` skips it).
98
+ """
99
+ if len(data) < _START_SONG_POS + 2:
100
+ raise SidFormatError("input is too short to contain a SID header")
101
+ magic = bytes(data[_MAGIC_POS : _MAGIC_POS + 4])
102
+ if magic not in (PSID_MAGIC, RSID_MAGIC):
103
+ raise SidFormatError(
104
+ "not a SID file (expected 'PSID' or 'RSID' magic at offset 0, "
105
+ f"found {magic!r})"
106
+ )
107
+ version = _u16be(data, _VERSION_POS)
108
+ data_offset = _u16be(data, _DATA_OFFSET_POS)
109
+ load_address = _u16be(data, _LOAD_ADDRESS_POS)
110
+ init_address = _u16be(data, _INIT_ADDRESS_POS)
111
+ play_address = _u16be(data, _PLAY_ADDRESS_POS)
112
+ songs = _u16be(data, _SONGS_POS)
113
+ start_song = _u16be(data, _START_SONG_POS)
114
+ name = _decode_str(data[_NAME_POS : _NAME_POS + _STR_LEN])
115
+ author = _decode_str(data[_AUTHOR_POS : _AUTHOR_POS + _STR_LEN])
116
+ released = _decode_str(data[_RELEASED_POS : _RELEASED_POS + _STR_LEN])
117
+ flags = (
118
+ _u16be(data, _FLAGS_POS) if version >= 2 and len(data) >= _FLAGS_POS + 2 else 0
119
+ )
120
+ second_sid = data[_SECOND_SID_POS] if len(data) > _SECOND_SID_POS else 0
121
+ third_sid = data[_THIRD_SID_POS] if len(data) > _THIRD_SID_POS else 0
122
+
123
+ if load_address == 0:
124
+ if data_offset + 2 > len(data):
125
+ raise SidFormatError("SID dataOffset points past the end of the file")
126
+ real_load = data[data_offset] | (data[data_offset + 1] << 8)
127
+ data_start = data_offset + 2
128
+ else:
129
+ if data_offset > len(data):
130
+ raise SidFormatError("SID dataOffset points past the end of the file")
131
+ real_load = load_address
132
+ data_start = data_offset
133
+
134
+ return SidHeader(
135
+ magic=magic,
136
+ version=version,
137
+ data_offset=data_offset,
138
+ load_address=load_address,
139
+ init_address=init_address,
140
+ play_address=play_address,
141
+ songs=songs,
142
+ start_song=start_song,
143
+ name=name,
144
+ author=author,
145
+ released=released,
146
+ flags=flags,
147
+ second_sid=second_sid,
148
+ third_sid=third_sid,
149
+ real_load_address=real_load,
150
+ data_start=data_start,
151
+ )
pysidtracker/image.py ADDED
@@ -0,0 +1,128 @@
1
+ """The loaded C64 memory image a parser works against.
2
+
3
+ :class:`SidImage` unwraps a PSID/RSID container (or a bare ``.prg``) into a full
4
+ 64 KiB memory image with the tune placed at its load address, plus absolute-
5
+ addressed read accessors. This is the shared substitute for the per-parser
6
+ ``_Image`` / ``load_sid`` / ``_memory_accessors`` helpers.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from typing import List, Optional
12
+
13
+ from . import _scan
14
+ from .errors import SidParseError
15
+ from .header import SidHeader, parse_sid_header
16
+
17
+ MEM_SIZE = 0x10000
18
+
19
+
20
+ class SidImage:
21
+ """A 64 KiB C64 memory image with the tune loaded at its load address.
22
+
23
+ Attributes:
24
+ mem: ``bytearray`` of length ``0x10000`` (the C64 address space).
25
+ load: C64 address the image data starts at.
26
+ end: one past the last loaded byte (``0x10000`` after an init run, which
27
+ may have scattered data across memory).
28
+ header: the parsed :class:`SidHeader`, or ``None`` for a bare ``.prg``.
29
+ image: the raw C64 image bytes (player + data, without the container).
30
+ container: the container bytes preceding ``image`` (PSID/RSID header plus
31
+ any embedded 2-byte load address, or the ``.prg`` load-address prefix),
32
+ kept so a writer can re-emit a byte-identical container.
33
+ """
34
+
35
+ __slots__ = ("mem", "load", "end", "header", "image", "container")
36
+
37
+ def __init__(
38
+ self,
39
+ mem: bytearray,
40
+ load: int,
41
+ end: int,
42
+ header: Optional[SidHeader],
43
+ image: bytes,
44
+ container: bytes,
45
+ ):
46
+ self.mem = mem
47
+ self.load = load
48
+ self.end = end
49
+ self.header = header
50
+ self.image = image
51
+ self.container = container
52
+
53
+ @classmethod
54
+ def from_bytes(cls, data: bytes) -> "SidImage":
55
+ """Load a PSID/RSID ``.sid`` or a bare ``.prg`` image from ``data``."""
56
+ if data[:4] in (b"PSID", b"RSID"):
57
+ return cls.from_sid(data)
58
+ return cls.from_prg(data)
59
+
60
+ @classmethod
61
+ def from_sid(cls, data: bytes) -> "SidImage":
62
+ """Load a PSID/RSID container into a 64 KiB image."""
63
+ header = parse_sid_header(data)
64
+ image = bytes(data[header.data_start :])
65
+ container = bytes(data[: header.data_start])
66
+ load = header.real_load_address
67
+ return cls._place(image, load, header, container)
68
+
69
+ @classmethod
70
+ def from_prg(cls, data: bytes) -> "SidImage":
71
+ """Load a bare ``.prg`` (2-byte little-endian load address + image)."""
72
+ if len(data) < 2:
73
+ raise SidParseError("PRG too short for a load address")
74
+ load = data[0] | (data[1] << 8)
75
+ return cls._place(bytes(data[2:]), load, None, bytes(data[:2]))
76
+
77
+ @classmethod
78
+ def _place(cls, image: bytes, load: int, header, container) -> "SidImage":
79
+ end = load + len(image)
80
+ if end > MEM_SIZE:
81
+ raise SidParseError(
82
+ f"data overruns memory (load {load:#06x}, {len(image)} bytes)"
83
+ )
84
+ mem = bytearray(MEM_SIZE)
85
+ mem[load:end] = image
86
+ return cls(mem, load, end, header, image, container)
87
+
88
+ def byte(self, addr: int) -> int:
89
+ """Read one byte at C64 ``addr`` (raises out of ``0..0xFFFF``)."""
90
+ if not 0 <= addr < MEM_SIZE:
91
+ raise SidParseError(f"address {addr:#06x} out of range")
92
+ return self.mem[addr]
93
+
94
+ def peek(self, addr: int, default: int = 0) -> int:
95
+ """Read one byte at ``addr``, returning ``default`` if out of range."""
96
+ if 0 <= addr < MEM_SIZE:
97
+ return self.mem[addr]
98
+ return default
99
+
100
+ def word(self, addr: int) -> int:
101
+ """Read a little-endian 16-bit word at C64 ``addr``."""
102
+ return self.byte(addr) | (self.byte(addr + 1) << 8)
103
+
104
+ def slice(self, addr: int, length: int) -> bytes:
105
+ """Read ``length`` bytes starting at C64 ``addr`` (bounds-checked)."""
106
+ if addr < 0 or addr + length > MEM_SIZE:
107
+ raise SidParseError(f"slice at {addr:#06x}+{length} out of range")
108
+ return bytes(self.mem[addr : addr + length])
109
+
110
+ def ptr(self, lo_base: int, hi_base: int, index: int) -> int:
111
+ """Read a split-pointer-table entry (``lo[index]`` + ``hi[index]<<8``)."""
112
+ return self.peek(lo_base + index) | (self.peek(hi_base + index) << 8)
113
+
114
+ def find(self, needle: bytes, start: Optional[int] = None) -> int:
115
+ """First address of ``needle`` in the image, or ``-1``.
116
+
117
+ Search starts at ``start`` (defaulting to the load address, so the
118
+ container header is skipped).
119
+ """
120
+ return _scan.find_first(self.mem, needle, self.load if start is None else start)
121
+
122
+ def find_all(self, needle: bytes, start: Optional[int] = None) -> List[int]:
123
+ """Every address of ``needle`` in the image at or after ``start``."""
124
+ return _scan.find_all(self.mem, needle, self.load if start is None else start)
125
+
126
+ def find_split_table(self, lo, hi, *, min_length: int = 8) -> Optional[tuple]:
127
+ """Locate a split lo/hi table anchor (see :func:`_scan.find_split_table`)."""
128
+ return _scan.find_split_table(self.mem, lo, hi, min_length=min_length)
pysidtracker/source.py ADDED
@@ -0,0 +1,31 @@
1
+ """Normalise the many ways a caller can hand a tune to a parser.
2
+
3
+ Every parser in the family accepts a path, a ``bytes`` blob, or an open binary
4
+ file. :func:`read_bytes` is the single dispatch they share so ``read(...)``
5
+ behaves identically everywhere.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import io
11
+ import os
12
+ from pathlib import Path
13
+ from typing import Union
14
+
15
+ Source = Union[bytes, bytearray, str, "os.PathLike[str]", io.IOBase]
16
+
17
+
18
+ def read_bytes(src: Source) -> bytes:
19
+ """Return the raw bytes of ``src``.
20
+
21
+ ``src`` may be ``bytes``/``bytearray``, a filesystem path (``str`` or
22
+ :class:`os.PathLike`), or a binary file-like object with a ``read`` method.
23
+ Raises :class:`TypeError` for anything else.
24
+ """
25
+ if isinstance(src, (bytes, bytearray)):
26
+ return bytes(src)
27
+ if isinstance(src, (str, os.PathLike)):
28
+ return Path(src).read_bytes()
29
+ if isinstance(src, io.IOBase) or hasattr(src, "read"):
30
+ return src.read()
31
+ raise TypeError(f"cannot read a tune from {type(src).__name__}")
@@ -0,0 +1,290 @@
1
+ Metadata-Version: 2.4
2
+ Name: pysidtracker
3
+ Version: 0.1.0
4
+ Summary: Shared base for pure-Python C64 SID tracker parsers: PSID/RSID container, loaded-image model, and packed/relocating playroutine detection
5
+ Author: Josh Bailey
6
+ License: Apache License
7
+ Version 2.0, January 2004
8
+ http://www.apache.org/licenses/
9
+
10
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11
+
12
+ 1. Definitions.
13
+
14
+ "License" shall mean the terms and conditions for use, reproduction,
15
+ and distribution as defined by Sections 1 through 9 of this document.
16
+
17
+ "Licensor" shall mean the copyright owner or entity authorized by
18
+ the copyright owner that is granting the License.
19
+
20
+ "Legal Entity" shall mean the union of the acting entity and all
21
+ other entities that control, are controlled by, or are under common
22
+ control with that entity. For the purposes of this definition,
23
+ "control" means (i) the power, direct or indirect, to cause the
24
+ direction or management of such entity, whether by contract or
25
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
26
+ outstanding shares, or (iii) beneficial ownership of such entity.
27
+
28
+ "You" (or "Your") shall mean an individual or Legal Entity
29
+ exercising permissions granted by this License.
30
+
31
+ "Source" form shall mean the preferred form for making modifications,
32
+ including but not limited to software source code, documentation
33
+ source, and configuration files.
34
+
35
+ "Object" form shall mean any form resulting from mechanical
36
+ transformation or translation of a Source form, including but
37
+ not limited to compiled object code, generated documentation,
38
+ and conversions to other media types.
39
+
40
+ "Work" shall mean the work of authorship, whether in Source or
41
+ Object form, made available under the License, as indicated by a
42
+ copyright notice that is included in or attached to the work
43
+ (an example is provided in the Appendix below).
44
+
45
+ "Derivative Works" shall mean any work, whether in Source or Object
46
+ form, that is based on (or derived from) the Work and for which the
47
+ editorial revisions, annotations, elaborations, or other modifications
48
+ represent, as a whole, an original work of authorship. For the purposes
49
+ of this License, Derivative Works shall not include works that remain
50
+ separable from, or merely link (or bind by name) to the interfaces of,
51
+ the Work and Derivative Works thereof.
52
+
53
+ "Contribution" shall mean any work of authorship, including
54
+ the original version of the Work and any modifications or additions
55
+ to that Work or Derivative Works thereof, that is intentionally
56
+ submitted to Licensor for inclusion in the Work by the copyright owner
57
+ or by an individual or Legal Entity authorized to submit on behalf of
58
+ the copyright owner. For the purposes of this definition, "submitted"
59
+ means any form of electronic, verbal, or written communication sent
60
+ to the Licensor or its representatives, including but not limited to
61
+ communication on electronic mailing lists, source code control systems,
62
+ and issue tracking systems that are managed by, or on behalf of, the
63
+ Licensor for the purpose of discussing and improving the Work, but
64
+ excluding communication that is conspicuously marked or otherwise
65
+ designated in writing by the copyright owner as "Not a Contribution."
66
+
67
+ "Contributor" shall mean Licensor and any individual or Legal Entity
68
+ on behalf of whom a Contribution has been received by Licensor and
69
+ subsequently incorporated within the Work.
70
+
71
+ 2. Grant of Copyright License. Subject to the terms and conditions of
72
+ this License, each Contributor hereby grants to You a perpetual,
73
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
74
+ copyright license to reproduce, prepare Derivative Works of,
75
+ publicly display, publicly perform, sublicense, and distribute the
76
+ Work and such Derivative Works in Source or Object form.
77
+
78
+ 3. Grant of Patent License. Subject to the terms and conditions of
79
+ this License, each Contributor hereby grants to You a perpetual,
80
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
81
+ (except as stated in this section) patent license to make, have made,
82
+ use, offer to sell, sell, import, and otherwise transfer the Work,
83
+ where such license applies only to those patent claims licensable
84
+ by such Contributor that are necessarily infringed by their
85
+ Contribution(s) alone or by combination of their Contribution(s)
86
+ with the Work to which such Contribution(s) was submitted. If You
87
+ institute patent litigation against any entity (including a
88
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
89
+ or a Contribution incorporated within the Work constitutes direct
90
+ or contributory patent infringement, then any patent licenses
91
+ granted to You under this License for that Work shall terminate
92
+ as of the date such litigation is filed.
93
+
94
+ 4. Redistribution. You may reproduce and distribute copies of the
95
+ Work or Derivative Works thereof in any medium, with or without
96
+ modifications, and in Source or Object form, provided that You
97
+ meet the following conditions:
98
+
99
+ (a) You must give any other recipients of the Work or
100
+ Derivative Works a copy of this License; and
101
+
102
+ (b) You must cause any modified files to carry prominent notices
103
+ stating that You changed the files; and
104
+
105
+ (c) You must retain, in the Source form of any Derivative Works
106
+ that You distribute, all copyright, patent, trademark, and
107
+ attribution notices from the Source form of the Work,
108
+ excluding those notices that do not pertain to any part of
109
+ the Derivative Works; and
110
+
111
+ (d) If the Work includes a "NOTICE" text file as part of its
112
+ distribution, then any Derivative Works that You distribute must
113
+ include a readable copy of the attribution notices contained
114
+ within such NOTICE file, excluding those notices that do not
115
+ pertain to any part of the Derivative Works, in at least one
116
+ of the following places: within a NOTICE text file distributed
117
+ as part of the Derivative Works; within the Source form or
118
+ documentation, if provided along with the Derivative Works; or,
119
+ within a display generated by the Derivative Works, if and
120
+ wherever such third-party notices normally appear. The contents
121
+ of the NOTICE file are for informational purposes only and
122
+ do not modify the License. You may add Your own attribution
123
+ notices within Derivative Works that You distribute, alongside
124
+ or as an addendum to the NOTICE text from the Work, provided
125
+ that such additional attribution notices cannot be construed
126
+ as modifying the License.
127
+
128
+ You may add Your own copyright statement to Your modifications and
129
+ may provide additional or different license terms and conditions
130
+ for use, reproduction, or distribution of Your modifications, or
131
+ for any such Derivative Works as a whole, provided Your use,
132
+ reproduction, and distribution of the Work otherwise complies with
133
+ the conditions stated in this License.
134
+
135
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
136
+ any Contribution intentionally submitted for inclusion in the Work
137
+ by You to the Licensor shall be under the terms and conditions of
138
+ this License, without any additional terms or conditions.
139
+ Notwithstanding the above, nothing herein shall supersede or modify
140
+ the terms of any separate license agreement you may have executed
141
+ with Licensor regarding such Contributions.
142
+
143
+ 6. Trademarks. This License does not grant permission to use the trade
144
+ names, trademarks, service marks, or product names of the Licensor,
145
+ except as required for reasonable and customary use in describing the
146
+ origin of the Work and reproducing the content of the NOTICE file.
147
+
148
+ 7. Disclaimer of Warranty. Unless required by applicable law or
149
+ agreed to in writing, Licensor provides the Work (and each
150
+ Contributor provides its Contributions) on an "AS IS" BASIS,
151
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
152
+ implied, including, without limitation, any warranties or conditions
153
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
154
+ PARTICULAR PURPOSE. You are solely responsible for determining the
155
+ appropriateness of using or redistributing the Work and assume any
156
+ risks associated with Your exercise of permissions under this License.
157
+
158
+ 8. Limitation of Liability. In no event and under no legal theory,
159
+ whether in tort (including negligence), contract, or otherwise,
160
+ unless required by applicable law (such as deliberate and grossly
161
+ negligent acts) or agreed to in writing, shall any Contributor be
162
+ liable to You for damages, including any direct, indirect, special,
163
+ incidental, or consequential damages of any character arising as a
164
+ result of this License or out of the use or inability to use the
165
+ Work (including but not limited to damages for loss of goodwill,
166
+ work stoppage, computer failure or malfunction, or any and all
167
+ other commercial damages or losses), even if such Contributor
168
+ has been advised of the possibility of such damages.
169
+
170
+ 9. Accepting Warranty or Additional Liability. While redistributing
171
+ the Work or Derivative Works thereof, You may choose to offer,
172
+ and charge a fee for, acceptance of support, warranty, indemnity,
173
+ or other liability obligations and/or rights consistent with this
174
+ License. However, in accepting such obligations, You may act only
175
+ on Your own behalf and on Your sole responsibility, not on behalf
176
+ of any other Contributor, and only if You agree to indemnify,
177
+ defend, and hold each Contributor harmless for any liability
178
+ incurred by, or claims asserted against, such Contributor by reason
179
+ of your accepting any such warranty or additional liability.
180
+
181
+ END OF TERMS AND CONDITIONS
182
+
183
+ APPENDIX: How to apply the Apache License to your work.
184
+
185
+ To apply the Apache License to your work, attach the following
186
+ boilerplate notice, with the fields enclosed by brackets "[]"
187
+ replaced with your own identifying information. (Don't include
188
+ the brackets!) The text should be enclosed in the appropriate
189
+ comment syntax for the file format. We also recommend that a
190
+ file or class name and description of purpose be included on the
191
+ same "printed page" as the copyright notice for easier
192
+ identification within third-party archives.
193
+
194
+ Copyright [yyyy] [name of copyright owner]
195
+
196
+ Licensed under the Apache License, Version 2.0 (the "License");
197
+ you may not use this file except in compliance with the License.
198
+ You may obtain a copy of the License at
199
+
200
+ http://www.apache.org/licenses/LICENSE-2.0
201
+
202
+ Unless required by applicable law or agreed to in writing, software
203
+ distributed under the License is distributed on an "AS IS" BASIS,
204
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
205
+ See the License for the specific language governing permissions and
206
+ limitations under the License.
207
+
208
+ Project-URL: Homepage, https://github.com/anarkiwi/pysidtracker
209
+ Project-URL: Source, https://github.com/anarkiwi/pysidtracker
210
+ Project-URL: Issues, https://github.com/anarkiwi/pysidtracker/issues
211
+ Keywords: sid,c64,psid,rsid,tracker,chiptune
212
+ Classifier: License :: OSI Approved :: Apache Software License
213
+ Classifier: Programming Language :: Python :: 3
214
+ Classifier: Programming Language :: Python :: 3.10
215
+ Classifier: Programming Language :: Python :: 3.11
216
+ Classifier: Programming Language :: Python :: 3.12
217
+ Classifier: Programming Language :: Python :: 3.13
218
+ Classifier: Topic :: Multimedia :: Sound/Audio
219
+ Requires-Python: >=3.10
220
+ Description-Content-Type: text/markdown
221
+ License-File: LICENSE
222
+ Provides-Extra: emu
223
+ Requires-Dist: py65>=1.1; extra == "emu"
224
+ Provides-Extra: fast
225
+ Requires-Dist: numpy>=1.23; extra == "fast"
226
+ Provides-Extra: dev
227
+ Requires-Dist: black>=24; extra == "dev"
228
+ Requires-Dist: numpy>=1.23; extra == "dev"
229
+ Requires-Dist: py65>=1.1; extra == "dev"
230
+ Requires-Dist: pylint>=3; extra == "dev"
231
+ Requires-Dist: pytest>=7; extra == "dev"
232
+ Requires-Dist: pytest-cov>=4; extra == "dev"
233
+ Requires-Dist: pytest-xdist>=3; extra == "dev"
234
+ Dynamic: license-file
235
+
236
+ # pysidtracker
237
+
238
+ Shared base for the pure-Python C64 SID tracker parsers (pygoattracker,
239
+ pysidwizard, pydmcsid, pyfuturecomposer, pymusicassembler, pydefmon, pyjch).
240
+
241
+ Provides one implementation of the pieces every format parser duplicated:
242
+
243
+ - **`parse_sid_header` / `SidHeader`** — PSID/RSID container header parsing.
244
+ - **`SidImage`** — a loaded 64 KiB C64 memory image with absolute-addressed
245
+ accessors, from a `.sid` container or a bare `.prg`.
246
+ - **`read_bytes`** — path / `bytes` / file-like source dispatch.
247
+ - **`SidError` hierarchy** — `SidParseError`, `SidFormatError`,
248
+ `EmulatorUnavailable`.
249
+ - **`detect_playroutine` / `PlayroutineKind`** — the untrustworthy-header
250
+ detector: static signature recognition first, then an emulated init run to
251
+ classify `DIRECT` / `RELOCATED` / `PACKED` / `UNKNOWN` playroutines.
252
+ - **`BaseSidParser`** — the class each format subclasses for a consistent
253
+ `read` / `parse` / `detect` API.
254
+
255
+ ## Install
256
+
257
+ ```
258
+ pip install pysidtracker # core (stdlib only)
259
+ pip install pysidtracker[emu] # + py65, to unpack packed/relocating tunes
260
+ pip install pysidtracker[fast] # + numpy, to accelerate the image scan
261
+ ```
262
+
263
+ ## Usage
264
+
265
+ ```python
266
+ from pysidtracker import BaseSidParser, PlayroutineKind
267
+
268
+ class MyParser(BaseSidParser):
269
+ def recognize(self, image):
270
+ return image.find(b"MYSIG") # truthy anchor when found
271
+ def parse(self, data, **kw):
272
+ image = self.load_image(data)
273
+ ... # decode image.mem into a model
274
+
275
+ det = MyParser().detect("tune.sid")
276
+ if det.kind is PlayroutineKind.PACKED:
277
+ ... # header was not trustworthy
278
+ ```
279
+
280
+ See [docs/design.md](docs/design.md) for the detection model and how the
281
+ format packages consume this base.
282
+
283
+ ## Development
284
+
285
+ ```
286
+ pip install -e ".[dev]"
287
+ pytest --cov=pysidtracker
288
+ ```
289
+
290
+ Apache-2.0 licensed.
@@ -0,0 +1,13 @@
1
+ pysidtracker/__init__.py,sha256=Dt_ZWgzlgs8DAMCkteuPEhWDYF3-iKNRxS8Rt42bLaU,1182
2
+ pysidtracker/_scan.py,sha256=PRywY8_NkxfRz89yyiwooC7LCJS8_jH4uwxgUuoHG84,4213
3
+ pysidtracker/base.py,sha256=cl1NaGaSHGqoMbupz6wLNnrsZhD32DN4tAKMODKGuhg,2708
4
+ pysidtracker/detect.py,sha256=qAcdQ_xIBDf9kOJI6qCdlwwFF1IoBcAPXVCB0ATZftY,6785
5
+ pysidtracker/errors.py,sha256=J4Jk8ADpVG-LK7AkbR44E9IxcwCK9N-zgZ6jz0gA7rw,950
6
+ pysidtracker/header.py,sha256=Up4EGKTZG9iagB5PTRhEJWA-XXjOZyPF0bVNOoQHoYg,5025
7
+ pysidtracker/image.py,sha256=xBzYbIPeQwbgKFxvXScA0uRPjPpT9a5vqjzEAEW8rCI,5139
8
+ pysidtracker/source.py,sha256=CdES1CaNdce6i3f-iUQjNsy_mmcUw6YRRWjx2lShLoI,1032
9
+ pysidtracker-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
10
+ pysidtracker-0.1.0.dist-info/METADATA,sha256=m0OJcS3qc86leEV668os7opcqB-Ir5908GCabF9WLKk,16253
11
+ pysidtracker-0.1.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
12
+ pysidtracker-0.1.0.dist-info/top_level.txt,sha256=z2aVHwZ83jWSRKUY8ziwjK8_-itI4c6MMuLoqgE88tE,13
13
+ pysidtracker-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1 @@
1
+ pysidtracker