Skip to main content

Python beautifier tcp server

Project description

PyBeautifier

Python beautifier tcp server based on autopep8, yapf, isort.
Only suport Unix-like system and python3.3+ currently.

Why

Before this, I use atom-beautify to format my code, but it's too slow(about 3 seconds) because every format operation will create a new python process.

So I write the beautifier server in python and beautifier client in node.js, they communicate by tcp socket. It's performance is much better(about 300 ms).

Install

$ pip install pybeautifier

Besides, you should install one or more of autopep8, yapf, isort based on your needs.

Usage

$ pybeautifier       # front ground process
$ pybeautifier -d    # daemon process, logging to /tmp/pybeautifier.log

It will start listening to tcp://${BEAUTIFIER_HOST}:${BEAUTIFIER_PORT}.

Env variables:

BEAUTIFIER_HOST - IP address or hostname (Default: 127.0.0.1)
BEAUTIFIER_PORT - Port number (Default: 36805)

Start at boot via systemd(Ubuntu16 or Arch Linux):

$ wget https://raw.githubusercontent.com/guyskk/pybeautifier/master/pybeautifier.service
$ cp pybeautifier.service /usr/lib/systemd/system/
$ systemctl start pybeautifier
$ systemctl enable pybeautifier

Protocol

Request(JSON):

{
    'data': 'text_need_format',
    'formaters': [
        {
            'name': 'formater_name',
            'config': {}  # None or dict
        },
        ... # formaters
    ]
}

Response(JSON):

{
    'error': 'error message',
    'data': 'formated text'
}

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

pybeautifier-0.1.3.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file pybeautifier-0.1.3.tar.gz.

File metadata

  • Download URL: pybeautifier-0.1.3.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.9

File hashes

Hashes for pybeautifier-0.1.3.tar.gz
Algorithm Hash digest
SHA256 733783f07ca4b074137086c166bb349c8e8ee7e738676b5ed1573352840b71ad
MD5 d1445fb5bc0d67b162bbea5123f55ea4
BLAKE2b-256 45879043ae3d5185f8e89ae9adad91d891d6205df20a1833adaf240fc8708824

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page