Skip to main content
[*view Italian version*](README_it.md)

# *html*2*py*

html2py is a tool for converting an html file in python language and viceversa.

## Features

- create a pythonic html page.

- wrap python code in a function and add imports.

- A command line interface for generating script.

- Also an API for extend functionalities, see module documenation for more details.

## Dependencies

- lxml

- yattag (for running generated scripts)

#### For testing:

- hypothesis

- pytest (or something that fetch test cases in modules)

- xmldiff

## Usage

#### Command line tool

```
usage: html2py.py [-h] -o OUTPUT [-e | -f | -c] [-s] file

Convert html file to yattag based python script.

parameters:
file Html file to convert (required).
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
Output file. By default in output there is python
header with imports and a function with code (required).
-e, --no-head Do not insert header and imports.
-f, --no-function Do not insert code into function
-c, --only-code Write only code into output. Do not insert header or
functions.
```

#### APIs

(see module documentation for more informations)

Html2py backend lib is composed with 4 module:

- parser

Parse an input file and transform it into something pythonic.
Currently it supported html and xml.
- output

It provides 2 feature:
- some extensible objects to represent python instructions
- An extensible interface to write your code
- yattag

Using parsed data and output module for writing your code.
- converter

Essentially a connector between cli tool and the other 3 modules.

## TODO

#### Proposing for future:

Now this tool works enough, but it not working in all cases; we need lots of document for testing purposes and for finding unhandled errors.

Html2py can potentially pythonize also xml documents and xml based documents, but also other types of file, such as json or yaml.

In addition add supports to other xml tree library and not just lxml (currently supported).

#### Improve test suite:

At the moment there is a very poor test suite (only a case) and this tool, though there is very small in lines of code, need lots of cases, samples and, why not, a random html generator.

#### Add wiki or website for documentation

Describe APIs and tools with a structured doc page instead of this readme.


Release files for html2py 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for html2py 1.0.1
File Size Uploaded
html2py-1.0.1.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for html2py 1.0.1
File Interpreter ABI Platform
html2py-1.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 15.9 kB

Release files / html2py-1.0.1.tar.gz

Download URL html2py-1.0.1.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6829ecaf8b3f9db1226d0dea2b691ef3711c4947848b171e0fb4a5399eb98450
BLAKE2b-256 checksum
How to use checksums
6e506bb5eec37c27eab5f0620ab1af8f18636d1be78197a8e747d649675d5f13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.10.0 pkginfo/1.2.1 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.6

Release files / html2py-1.0.1-py2.py3-none-any.whl

Download URL html2py-1.0.1-py2.py3-none-any.whl
Size 9.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
49b79e7b2541da58b582ecb9a268cb3617b7d0f8f1fcf25a51ae46ed1610be3a
BLAKE2b-256 checksum
How to use checksums
fd28839226bcffc891bc295305a483945b3c5325c237a4175762428277c2a2a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.10.0 pkginfo/1.2.1 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.6

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page