ticfile


Nameticfile JSON
Version 0.1 PyPI version JSON
download
home_pagehttps://github.com/gasman/ticfile
SummaryA library for reading and writing TIC-80 .tic cartridge files
upload_time2022-12-06 00:59:15
maintainer
docs_urlNone
authorMatt Westcott
requires_python>=3.7
licenseBSD
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ticfile

A library for reading and writing TIC-80 .tic cartridge files.

See https://github.com/nesbox/TIC-80/wiki/.tic-File-Format for the file format description.

## Installation

```sh
pip install ticfile
```

## Usage

```python
from ticfile import TICFile, ChunkType

duck_jam = TICFile.open("duckjam.tic")
code_chunks = [chunk for chunk in duck_jam.chunks if chunk.type == ChunkType.CODE]
code_lines = code_chunks[0].data.decode("ascii").split("\n")
print(code_lines[0])
```

## API

The `ticfile` module provides the following definitions:

### TICFile

Represents a complete .tic file.

#### Class methods

* `TICFile(chunks)` - construct a `TICFile` from a list of `Chunk` objects
* `TICFile.open(filename)` - open a `TICFile` from the given filename
* `TICFile.from_file(f)` - open a `TICFile` from the given file handle

#### Instance methods / attributes

* `chunks` - the list of `Chunk` objects making up this file
* `save(filename)` - write this file to the given filename

### ChunkType

An enum defining the available chunk types:

```python
ChunkType.TILES = 1
ChunkType.SPRITES = 2
ChunkType.MAP = 4
ChunkType.CODE = 5
ChunkType.FLAGS = 6
ChunkType.SAMPLES = 9
ChunkType.WAVEFORM = 10
ChunkType.PALETTE = 12
ChunkType.MUSIC = 14
ChunkType.PATTERNS = 15
ChunkType.DEFAULT = 17
ChunkType.SCREEN = 18
ChunkType.BINARY = 19
ChunkType.COVER_DEP = 3
ChunkType.PATTERNS_DEP = 13
ChunkType.CODE_ZIP = 16
```

### Chunk

Represents an individual chunk within a .tic file.

#### Class methods

* `Chunk(chunk_type, bank, data)` - construct a `Chunk` object
** `chunk_type` - one of the enum values defined in `ChunkType`
** `bank` - the bank number (0..7) for this chunk
** `data` - the binary data of this chunk, excluding the header, as a `bytes` object

### Instance methods / attributes

* `type` - the type of this chunk, given as one of the enum values defined in `ChunkType`
* `bank` - the bank number (0..7) for this chunk
* `data` - the binary data of this chunk, excluding the header, as a `bytes` object
* `write(f)` - write this chunk to the given file handle

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gasman/ticfile",
    "name": "ticfile",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Matt Westcott",
    "author_email": "matt@west.co.tt",
    "download_url": "https://files.pythonhosted.org/packages/90/53/b1d585bdb1991d9770e67c886c1ab22c4f5dc0bd6b45fa49b8f127b6b6bb/ticfile-0.1.tar.gz",
    "platform": null,
    "description": "# ticfile\n\nA library for reading and writing TIC-80 .tic cartridge files.\n\nSee https://github.com/nesbox/TIC-80/wiki/.tic-File-Format for the file format description.\n\n## Installation\n\n```sh\npip install ticfile\n```\n\n## Usage\n\n```python\nfrom ticfile import TICFile, ChunkType\n\nduck_jam = TICFile.open(\"duckjam.tic\")\ncode_chunks = [chunk for chunk in duck_jam.chunks if chunk.type == ChunkType.CODE]\ncode_lines = code_chunks[0].data.decode(\"ascii\").split(\"\\n\")\nprint(code_lines[0])\n```\n\n## API\n\nThe `ticfile` module provides the following definitions:\n\n### TICFile\n\nRepresents a complete .tic file.\n\n#### Class methods\n\n* `TICFile(chunks)` - construct a `TICFile` from a list of `Chunk` objects\n* `TICFile.open(filename)` - open a `TICFile` from the given filename\n* `TICFile.from_file(f)` - open a `TICFile` from the given file handle\n\n#### Instance methods / attributes\n\n* `chunks` - the list of `Chunk` objects making up this file\n* `save(filename)` - write this file to the given filename\n\n### ChunkType\n\nAn enum defining the available chunk types:\n\n```python\nChunkType.TILES = 1\nChunkType.SPRITES = 2\nChunkType.MAP = 4\nChunkType.CODE = 5\nChunkType.FLAGS = 6\nChunkType.SAMPLES = 9\nChunkType.WAVEFORM = 10\nChunkType.PALETTE = 12\nChunkType.MUSIC = 14\nChunkType.PATTERNS = 15\nChunkType.DEFAULT = 17\nChunkType.SCREEN = 18\nChunkType.BINARY = 19\nChunkType.COVER_DEP = 3\nChunkType.PATTERNS_DEP = 13\nChunkType.CODE_ZIP = 16\n```\n\n### Chunk\n\nRepresents an individual chunk within a .tic file.\n\n#### Class methods\n\n* `Chunk(chunk_type, bank, data)` - construct a `Chunk` object\n** `chunk_type` - one of the enum values defined in `ChunkType`\n** `bank` - the bank number (0..7) for this chunk\n** `data` - the binary data of this chunk, excluding the header, as a `bytes` object\n\n### Instance methods / attributes\n\n* `type` - the type of this chunk, given as one of the enum values defined in `ChunkType`\n* `bank` - the bank number (0..7) for this chunk\n* `data` - the binary data of this chunk, excluding the header, as a `bytes` object\n* `write(f)` - write this chunk to the given file handle\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "A library for reading and writing TIC-80 .tic cartridge files",
    "version": "0.1",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "c95082fa01d83c801487f78092af7947",
                "sha256": "1ab24577250711bbf272a3fbf426e8e8d6167e67772cd60ea0a6dfedd101c34a"
            },
            "downloads": -1,
            "filename": "ticfile-0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c95082fa01d83c801487f78092af7947",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 3980,
            "upload_time": "2022-12-06T00:59:14",
            "upload_time_iso_8601": "2022-12-06T00:59:14.361036Z",
            "url": "https://files.pythonhosted.org/packages/30/fe/d23ab6cfef2a580ce4de7bf0a7e639f00e3ed61cd9980e1b03e66ba3b7c9/ticfile-0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "c7142c369222540619dbc4b311566e63",
                "sha256": "0e2a6a52ccfb10187f852c6c508c215d92ed5e718eb823751ea2b995abd9ca75"
            },
            "downloads": -1,
            "filename": "ticfile-0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "c7142c369222540619dbc4b311566e63",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 3771,
            "upload_time": "2022-12-06T00:59:15",
            "upload_time_iso_8601": "2022-12-06T00:59:15.738730Z",
            "url": "https://files.pythonhosted.org/packages/90/53/b1d585bdb1991d9770e67c886c1ab22c4f5dc0bd6b45fa49b8f127b6b6bb/ticfile-0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-06 00:59:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "gasman",
    "github_project": "ticfile",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ticfile"
}
        
Elapsed time: 0.03293s