Utilities for interacting with .jtf files.
Project description
jtf.py
Python utilities for interacting with .jtf files.
This package is a direct conversion of the main JTF utilities. While the functions within this package use Python wording (like list instead of array), the casing required by the JTF standard still applies when creating/parsing documents.
Requires Python 3.12 or newer.
Installation
pip install jtf
Usage
from jtf import JTF
document = JTF.parse("<document data>")
Reference
JTF Class
Import
from jtf import JTF
JTF.target_list_includes_cell(target, x, y)
Checks if a target list targets a specific coordinate.
Parameters:
- target (List<number|string>): The target list to check.
- x (number|string): The x-coordinate to check.
- y (number|string): The y-coordinate to check.
Returns True if the target list includes the specified coordinate, otherwise False.
JTF.parse(data)
Parses JTF data into a readable object.
Parameters:
- data (string|obj): The data to parse.
Returns an instance of the Document class based on the parsed data.
JTF.stringify(document)
Convert a Document object into a string.
- document (
Document): The document to stringify.
Returns a string of the document's source data.
Document Class
Generated by JTF class' parse method.
Document.get_cell(table, x, y)
Retrieves the content of a cell in a specified table.
Parameters:
- table: The index of the table.
- x: The x-coordinate of the cell.
- y: The y-coordinate of the cell.
Returns the content of the cell, or None if the cell does not exist.
Document.to_csv()
Converts each table in the document into CSV format.
Returns an object containing CSV strings for each table in the document.
Document.to_list()
Converts each table in the document into lists.
Returns an object containing lists for each table in the document.
Document.stringify()
Returns the data object represented by a JTF string.
Document.update_updated_at()
Updates the document's updatedAt value to be the current timestamp.
Document.set_table(index, value)
Set a table to a value. Will overwrite existing tables.
Parameters:
- index (string|number): The index of the table.
- data: The data to set.
Document.get_extra_processor_data(processor)
Parameters:
- processor (string): The unique identifier the data is stored under.
Returns a data object if found, or None if no object was found.
Document.set_extra_processor_data(processor, data, extend)
Overwrites or updates data objects defined in a document's metadata.extra object.
Parameters:
- processor (string): The unique identifier the data is stored under.
- data (obj): An object of extra data to set.
- extend (boolean): If
True, destructures the new data object into existing data instead of overwriting it. (defaultFalse)
Document.tables
An integer-string index of Table objects.
Document.source
The document's source object. This is the raw data that is parsed in JTF.parse().
Table Class
Generated by Document class and stored under Document.tables object.
Table.get_cell_styles(x, y)
Retrieves the styles that must be applied to a cell.
Parameters:
- x (string|number): The x-coordinate of the cell.
- y (string|number): The y-coordinate of the cell.
Returns an object containing the classes and styles to apply to this cell.
Table.get_cell(x, y)
Retrieves the content of a cell.
Parameters:
- x (string|number): The x-coordinate of the cell.
- y (string|number): The y-coordinate of the cell.
Returns the content of the cell, or None if the cell does not exist.
Table.set_cell(x, y, value)
Set the content of a cell.
Parameters:
- x (string|number): The x-coordinate of the cell.
- y (string|number): The y-coordinate of the cell.
- value (string|number|null|boolean): The value to set.
Table.to_csv()
Converts the data object into CSV format.
Returns the table data in CSV format.
Table.to_list()
Converts the table into a 2D list.
Returns the table as a 2D list.
Table.source
The table's source object. This is the raw data that is stored under the table's document parent's source.data.
Table.label
The table's label value. Can be used to set a Table instance's label. (myTable.label = "myNewLabel")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jtf-1.1.15.tar.gz.
File metadata
- Download URL: jtf-1.1.15.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
faf9848d07d3e98310fd29bea3c5322b9dfd33fe7a2c131bf042b1bbed6c1372
|
|
| MD5 |
4a022ed5165753e36044dd3ead212465
|
|
| BLAKE2b-256 |
d439a6c5f598cdf709ee2ec632202367ca0b75af6f7233e6b54b8d191de9ce38
|
File details
Details for the file jtf-1.1.15-py3-none-any.whl.
File metadata
- Download URL: jtf-1.1.15-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd8b09d8e86d0376ebe05a2bc205efa15f756014984794e642be4688fcb19b38
|
|
| MD5 |
58826520779ed45bc16724c2805dcbed
|
|
| BLAKE2b-256 |
865241d48dc6a5922d374f6a69c3a96916789ae10ea68e066608a9bc99319210
|