Skip to main content

A Pyhon parser for sff files.

Project description

sfflib

sfflib is an opensource, miltiplatform Scanlation File Format (sff) parser made for CanScanlate.

.sff files are basically xml files with some custom tags.

Below is the basic sff file:

<Document>
    <Metadata>
        <Script>Scanlation Script File v0.1.0</Script>
        <App></App>
        <Info>Made by NandeMD.</Info>
        <TLLength>0</TLLength>
        <PRLength>0</PRLength>
        <CMLength>0</CMLength>
        <BalloonCount>0</BalloonCount>
        <LineCount>0</LineCount>
    </Metadata>
    <Baloon type="Square" has_image="No">
        <text>
            şşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşş
        </text>
        <text>
            şşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşşş
        </text>
  </Baloon>
</Document>

Installing

Python 3.8 or higher is required!

# Linux/MacOS
python3 -m pip install -U libssf

# Windows
py -m pip install -U libsff

Example

from libsff import Document, Balloon, Out
from random import randint

# open a test image
with open("testimg.jpg", "rb") as file:
    imagefile = file.read()

# Create a blank document object
doc = Document.create_blank()

# Generate random 100 balloons
for _ in range(100):
    # Randomize imge
    has_image = randint(0, 1)

    # Add a Balloon object to our document
    docasd.add_balloon(
        Balloon(
            tl_content=[
                "Hi, this is tl line 1",
                "Hi, this is tl line 2"
            ],
            btype=randint(0, 4),
            has_img=has_image, # Yes, this is int
            balloon_img=imagefile if has_image else b"",
            img_type="jpg"
        )
    )

# Save as raw xml:
doc.save_sff("test", Out.RAW)

# Save as gzip compressed xml:
doc.save_sff("test", Out.GZIP)

# Save as lzma compressed xml:
doc.save_sff("test", Out.LZMA)

# Save as formatted text:
doc.save_sff("test", Out.TXT)

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

libsff-0.1.3.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

libsff-0.1.3-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file libsff-0.1.3.tar.gz.

File metadata

  • Download URL: libsff-0.1.3.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6

File hashes

Hashes for libsff-0.1.3.tar.gz
Algorithm Hash digest
SHA256 abcb0d3240e13ed0089f09bf7b40fc59a06967c90f034725469ee1c8d530adda
MD5 cdb792b905c0b2d5b5c61802b54c3b99
BLAKE2b-256 208d98b3bd9fcc305802a91714141a39824fd615cfe3cfd5226f23b9610bf778

See more details on using hashes here.

File details

Details for the file libsff-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: libsff-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6

File hashes

Hashes for libsff-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4ae705a93f1e0b77a193eeee667a3089971ae4ba264682e8b3199038c8bfc4f2
MD5 06148222879b1396230aa1528c9eb821
BLAKE2b-256 340b56835393626b1c3baf1fb948d77705ce9c0eeca83388faa9d0691bbcff6e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page