Skip to main content

On-the-go HTML Abstraction and Generator for Python

Project description

woshi

On-the-go HTML Abstraction and Generator for Python.

Woshi is simple, it abstracts XML nesting and leverages CSS3 selectors to append elements into the HTML document!

Version 2.0 is a breaking upgrade, which means the general usage and the internal algorithms were change to make it more flexible and lighter. The package lxml was removed in favor of a custom-made builder function. Only simple CSS3 selectors are supported, but will add support in the upcoming versions.

Here's a sample syntax:

page["tag#id"] = "tag #id.class property='10' > inner text"

And scroll down below for more examples.

Official Release

Current version is 2.0, but more updates are coming soon. Compatible with Python 3.10 or later.

pip install woshi

Usage

Import Package

from woshi import Woshi

Initialization

page = Woshi()

# initializing with a valid HTML text
page = Woshi("<div></div>")

# setting up filename
page = Woshi(filepath="home.html")

Creating elements with an inner text

page["head"] = "title > Woshi v1.0"

Creating other elements Basically, you set the parent selector to append the new element.

# create container box
page["body"] = "div #content"
page["#content"] = "div #box.container.light"

# create the popup text
page["#box"] = "div #title.header > Woshi"
page["#box"] = "div .message data-default='Lorem ipsum...' > Hello, world!"

# populate the action buttons
page["#box"] = "div #action.btn-list"
page["#action"] = "button #btn1.btn.btn-no style='background-color:#b22222;color:#fff;' > CLOSE"
page["#action"] = "button #btn2.btn.btn-maybe > LATER"

Setting Properties

page["html"] = "lang=en"
page["body"] = "#canvas"

Yield all matches

for match in page["button"]:
    print(match)

Save to HTML file

page.save()
page.save("newFile.html")

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

woshi-2.1.4.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

woshi-2.1.4-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file woshi-2.1.4.tar.gz.

File metadata

  • Download URL: woshi-2.1.4.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for woshi-2.1.4.tar.gz
Algorithm Hash digest
SHA256 e5146958732ff932889970d8c1938b5a5d223ed8a91de6d8c58632c8b1294757
MD5 319ae129f56e8cba7f8d697674511015
BLAKE2b-256 58ed1c59c5a9130b6d5c9ffc9a125203f931e472460ad9554215d68e2cfcf9d1

See more details on using hashes here.

File details

Details for the file woshi-2.1.4-py3-none-any.whl.

File metadata

  • Download URL: woshi-2.1.4-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for woshi-2.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 00f01976b570f6b30ffa5ce23a724967fb3203a26308afdee5b4fb8345f99135
MD5 79d8df75785741ea8e80c4d12fee806e
BLAKE2b-256 cba394a41f82b357f81ef5ab7f9326d913df4133faf127180d5dd23a71777d9e

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