| | |
- builtins.object
-
- DiskImage
- TextLine
class DiskImage(builtins.object) |
| |
DiskImage(imagePath: pathlib.Path)
|
| |
Methods defined here:
- __init__(self, imagePath: pathlib.Path)
- Initialize self. See help(type(self)) for accurate signature.
- close(self)
- convertSector(self, sector: bytearray, convertType: d64py.Constants.ConvertType) -> bytearray
- Convert a sector buffer from PETSCII to ASCII or vice versa.
:param sector: The sector buffer.
:param convertType: Which conversion to do.
:return: The sector buffer.
- findDirEntry(self, fileName: str, charSet: d64py.Constants.CharSet)
- Find the directory entry for a given file name. If the charset
is specified as PETSCII, it's translated to ASCII first.
:param fileName: The name of the file to find (trimmed ASCII).
:param charSet: The charset of the name (PETSCII or ASCII).
:return: The directory entry for the file.
- followChain(self, ts: d64py.TrackSector.TrackSector) -> d64py.Chain.Chain
- Get the chain of sectors starting at a given track and sector. If an
invalid track/sector or circular reference is encountered, an
PartialChainException is raised, and the incomplete chain can be
retrieved from the exception with getPartialChain().
:param ts: The track and sector that starts the chain.
:return: A Chain.
- getBlocksFree(self) -> int
- getChain(self, dirEntry: d64py.DirEntry.DirEntry) -> d64py.Chain.Chain
- Get the chain of tracks and sectors used by a file on disk.
To get the list of chains in a VLIR file, call getVlirChains().
:param dirEntry: The directory entry of the file.
:return: A Chain object, which will be empty if the chain cannot
be read or incomplete in the case of a PartialChainException.
- getDirHeader(self)
- Get the directory header of this disk image.
:return: The directory header.
- getDirectory(self) -> list[d64py.DirEntry.DirEntry]
- Get the directory of a Commodore disk image. NOTE: assumes that
the directory is contained within a single track, and that the first
directory sector is the lowest numbered one of the directory.
If the directory contains an invalid sector or circular reference,
an exception is raised; the available entries are contained within
the exception and can be retrieved with getPartialDirectory().
:return: A list of directory entries.
- getFileAsText(self, dirEntry: d64py.DirEntry.DirEntry, charSet: d64py.Constants.CharSet, shifted=False, translate=False) -> list['TextLine']
- Read a sequential file into lines of text split on carriage
returns. For PETSCII, Characters are converted to Unicode in
the 0xe000 range (0xe100 if shifted) to use Style's TrueType
CBM font.
:param dirEntry: The directory entry of the file.
:param charSet: The CharSet to use (ASCII or PETSCII).
:param shifted: For PETSCII, whether to use the shifted
Commodore character set. Optional parameter.
:param translate: If PETSCII, whether to translate to ASCII
(e.g. to save a C= SEQ file). Optional parameter.
:return: A list of TextLines representing the lines of text.
- getFreeSectorsOnTrack(self, track: int)
- getGeoWriteFileAsLines(self, dirEntry: d64py.DirEntry.DirEntry) -> list[list['TextLine']]
- Read a geoWrite file and parse into pages of lines. Escape
sequences are stripped. Both geoWrite 2.0 page format (records
0-60 are text pages and 61-63 are header/footer data) and
earlier (0-63 are text pages) are supported, as well as the
earlier type of ruler escape.
:param dirEntry: The directory entry of the geoWrite file.
:return: A list of lists of TextLines, each representing the lines of a page.
- getGeosFileHeader(self, dirEntry: d64py.DirEntry.DirEntry) -> d64py.GeosFileHeader.GeosFileHeader
- Get the GEOS file header for a given directory entry.
:param dirEntry: The directory entry.
:return: The file's GEOS header.
- getGeosVlirIndex(self, dirEntry: d64py.DirEntry.DirEntry) -> bytearray
- Get the VLIR index of a file.
:param dirEntry: The file's directory entry.
:return: The VLIR index.
- getMegaFontPointSize(self, dirEntry: d64py.DirEntry.DirEntry, fileHeader: d64py.GeosFileHeader.GeosFileHeader)
- Get the true point size of a mega font. If the font headers contain more
than one character height, only the first is returned, and a warning is
written to the log.
:param dirEntry: The directory entry of the font file.
:param fileHeader: The GEOS file header of the font file.
:return: The true point size (character height in pixels) of the mega font.
- getSectorErrorCode(self, ts: d64py.TrackSector.TrackSector)
- getSectorErrorDescription(self, code: int) -> str
- getSectorErrorMap(self) -> dict
- For a D64 error image, get the map of sectors and their reported errors.
:return: A dictionary of TrackSector objects to FDC error codes.
- getTextAlbumAsPages(self, dirEntry: d64py.DirEntry.DirEntry) -> list[list['TextLine']]
- getTextScrapAsText(self, dirEntry: d64py.DirEntry.DirEntry) -> list['TextLine']
- Read a text scrap and parse into lines. Escape sequences are
stripped.
:param dirEntry: The directory entry of the text scrap.
:return: A list of lists of TextLines, each representing the lines of a page.
- getVlirChains(self, dirEntry: d64py.DirEntry.DirEntry) -> dict
- Get the list of track and sector chains for a VLIR file.
:param dirEntry: The file's directory entry.
:return: A dictionary: VLIR record no. --> sector chain
- isGeosImage(self) -> bool
- Determine whether this image is a GEOS disk by looking for the
signature "GEOS" at bytes 173-176 in the header. Note that many
disks with GEOS files on them are not actually GEOS disks.
:return: True if the image is of a GEOS disk, false otherwise.
- isMegaFont(self, dirEntry: d64py.DirEntry.DirEntry, fileHeader: d64py.GeosFileHeader.GeosFileHeader) -> bool
- Determine whether a GEOS font is a mega font. Both the existence of the
expected point sizes and the lack of a bitstream in record 54 are
checked for.
:param dirEntry: The directory entry of the font file.
:param fileHeader: The GEOS file header of the font file.
:return: True if a GEOS mega font, false otherwise.
- isSectorAllocated(self, ts: d64py.TrackSector.TrackSector) -> bool
- makeGeosDisk(self)
- Make this a GEOS disk: allocate off-page directory sector (the
"border"), add GEOS format string. Note that this method reads the
BAM and flushes it afterward if no exception is thrown. It's
assumed that this would not be called during other operations that
keep a BAM cache.
:return: nothing
- readBam(self)
- Read the BAM (block availability map) of this disk image. Note
that only the BAM itself is returned (not the rest of the
directory header). The BAM is cached at self.bam; writeBam()
must be called to flush it.
:return: Nothing.
- readChain(self, ts: d64py.TrackSector.TrackSector) -> bytearray
- Read the data in a chain of sectors given the starting track and sector.
:param ts: The first track/sector in the chain.
:return: The data in the chain as a bytearray.
- readMegaFontData(self, dirEntry: d64py.DirEntry.DirEntry) -> dict
- Read the VLIR records of a GEOS mega font.
:param dirEntry: The file's directory entry.
:return: A dictionary of record numbers to VLIR records.
- readSector(self, ts: d64py.TrackSector.TrackSector) -> bytearray
- Read a given track and sector from disk image.
:param ts: The track and sector to be read.
:return: The sector data as a bytearray.
- readVlirRecord(self, record: int, dirEntry: d64py.DirEntry.DirEntry) -> bytearray
- Read a record from a GEOS VLIR file.
:param record: The record number to read.
:param dirEntry: The file's directory entry.
:return: The VLIR record's data.
- writeBam(self)
- Write the cached BAM (block availability map) back to a disk image.
:return: Nothing.
- writeSector(self, ts: d64py.TrackSector.TrackSector, sectorBuffer: bytearray)
- Write a given track and sector from a buffer.
:param ts: The track and sector to be written.
:param sectorBuffer: The buffer to write.
:return: Nothing.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class TextLine(builtins.object) |
| |
TextLine(text: str, errorLine: bool)
|
| |
Methods defined here:
- __init__(self, text: str, errorLine: bool)
- Initialize self. See help(type(self)) for accurate signature.
- isErrorLine(self) -> bool
- text(self)
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |