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.

You're prototyping the next big thing and definitely writing the perfect HTML file is not on the priority.

Woshi lets you create HTML documents on the go and inside your Python scripts. It is built on top of lxml.html plus with another level of abstraction, so you can code with no trouble of messing up with closing tags--it is so quick and easy!

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.9 or later.

pip install woshi -U

Usage

Import Package

from woshi import Woshi

Initialization

page = Woshi()

# initializing with a valid HTML text
page = Woshi("<!DOCTYPE html>...")

# 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

print(page["button"])

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.0.6.tar.gz (11.4 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.0.6-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: woshi-2.0.6.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for woshi-2.0.6.tar.gz
Algorithm Hash digest
SHA256 fe585439008b336cb1c2dfe1900cc3d8ae5e0db46e9c8cb59ee05c13c3459047
MD5 34d4c9841e1ade9f89068d3271288e72
BLAKE2b-256 1c50ef25301a889da69500e02e699752b679ca16221d2370fb8c70619c81bf46

See more details on using hashes here.

File details

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

File metadata

  • Download URL: woshi-2.0.6-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for woshi-2.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2121673bbfb7405b3bc7fa0ebf358124f93d164a40b5a14a2e77468c9212fe4d
MD5 e1d6e8308f404a31f158b930b6d7aad4
BLAKE2b-256 fa6836bfcc68c55b8c83fe2a1d9f6d8fd016f30b0630bd0e2ac81109ef3d932a

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