Skip to main content

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

Project description

[*view Italian version*](

# *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: [-h] -o OUTPUT [-e | -f | -c] [-s] file

Convert html file to yattag based python script.

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

#### 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.


#### 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.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for html2py, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size html2py-1.0.1-py2.py3-none-any.whl (9.8 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size html2py-1.0.1.tar.gz (6.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page