Skip to main content

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

Project description

[*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.


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

html2py-1.0.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

html2py-1.0.1-py2.py3-none-any.whl (9.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file html2py-1.0.1.tar.gz.

File metadata

  • Download URL: html2py-1.0.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for html2py-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6829ecaf8b3f9db1226d0dea2b691ef3711c4947848b171e0fb4a5399eb98450
MD5 df76e85147854132a41f2f4feb439e15
BLAKE2b-256 6e506bb5eec37c27eab5f0620ab1af8f18636d1be78197a8e747d649675d5f13

See more details on using hashes here.

File details

Details for the file html2py-1.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: html2py-1.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using 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

File hashes

Hashes for html2py-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 49b79e7b2541da58b582ecb9a268cb3617b7d0f8f1fcf25a51ae46ed1610be3a
MD5 41ca74ab4c010a8f223d1fe2c7945400
BLAKE2b-256 fd28839226bcffc891bc295305a483945b3c5325c237a4175762428277c2a2a2

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