muppy


Namemuppy JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryMarkup Preprocessor for Python
upload_time2024-10-07 12:07:05
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseMIT License
keywords c markup preprocessor shell tex xml
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Logo](https://codeberg.org/screwery/muppy/raw/branch/main/logo.svg)

## Description

![PyPI - Version](https://img.shields.io/pypi/v/muppy?style=flat-square)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/muppy?style=flat-square)
![PyPI - Status](https://img.shields.io/pypi/status/muppy?style=flat-square)
![PyPI - Downloads](https://img.shields.io/pypi/dm/muppy?style=flat-square)
![PyPI - License](https://img.shields.io/pypi/l/muppy?style=flat-square)
![Gitea Issues](https://img.shields.io/gitea/issues/open/screwery/muppy?gitea_url=https%3A%2F%2Fcodeberg.org&style=flat-square)
![Gitea Last Commit](https://img.shields.io/gitea/last-commit/screwery/muppy?gitea_url=https%3A%2F%2Fcodeberg.org&style=flat-square)

**Muppy** means MarkUp Preprocessor for Python.
If you want some Python in markup, not some markup in Python—Muppy is probably the thing you need.

---

**WARNING:** This script is using `exec()`. Be careful when you execute Muppy with a file you get from strangers, and keep in mind that it can be harmful as any other Python script.
Use Muppy script standalone from the git repo if you have reasons not to trust the wheel.

## Installation

The script is pure Python and a part of [PyPI](https://pypi.org/project/muppy), so can be installed via *pip*:

```bash
python3 -m pip install muppy
```

## So, what does it do, exactly?

Technically, Muppy gets comments in various formats and executes them as Python code.
Any text between comment blocks is treated as string literals.

### Basic HTML example

Contents of `test.html`. Mind Python indentation after `<!-- (py):`, placeholders `?????`, and empty lines `<!-- (py):-->`:

```html
<!-- (py):print(?????)-->
<html>
	<head>
		<title>
			<!-- (py):if lang=="en":--><!-- (py):  print(?????)-->Hello world!<!-- (py):-->
			<!-- (py):if lang=="ru":--><!-- (py):  print(?????)-->Привет, мир!<!-- (py):-->
<!-- (py):print(?????)-->
		</title>
	</head>
	<body>
	</body>
</html>
```

Shell command:

```bash
muppy compile -s xml -i test.html -d 'lang="en"'
```

The preprocessor code to be executed:

```python
# string literals
MUPPY_657acc3e8ec943f4b25df555b97f6157 = ''
MUPPY_9dd9938c266b4cfb86ce9bccbfe33377 = '\n<html>\n\t<head>\n\t\t<title>\n\t\t\t'
MUPPY_b9df68b0daa54bbdb969b045b8996f14 = ''
MUPPY_8d278dc0965849c3a163a5427675b84a = 'Hello world!'
MUPPY_39639e4d3a5c4109a760b57bc8f1388e = '\n\t\t\t'
MUPPY_105fec3e43fa40c89d2cb39c6e5ee4cc = ''
MUPPY_e35ecf5319b8466f8c30ed50f48e96eb = 'Привет, мир!'
MUPPY_69b0bda88bba4562a765a73a6ba8caab = '\n'
MUPPY_918e6a4eb97149ff87eabad02d26c771 = '\n\t\t</title>\n\t</head>\n\t<body>\n\t</body>\n</html>\n'

# definitions
lang="en"

# your code
print(MUPPY_9dd9938c266b4cfb86ce9bccbfe33377)
if lang=="en":
  print(MUPPY_8d278dc0965849c3a163a5427675b84a)

if lang=="ru":
  print(MUPPY_e35ecf5319b8466f8c30ed50f48e96eb)

print(MUPPY_918e6a4eb97149ff87eabad02d26c771)
```

### Comment styles

For now, Muppy supports the following comment styles (`-s`):

| Style   | Start tag    | End tag | Description                          |
|---------|--------------|---------|--------------------------------------|
| `xml`   | `<!-- (py):` | `-->`   | Any XML format: HTML, SVG, FB2, etc. |
| `c`     | `/* (py):`   | `*/`    | C, C++, CSS, PHP, etc.               |
| `tex`   | `% (py):`    | Newline | TeX-compatible markup                |
| `shell` | `# (py):`    | Newline | Bash, Python, etc.                   |

### Definitions

You can define (`-d`) any variables as you do in common Python code:

```bash
muppy compile -s tex -i test.html -d 'var1 = 10' 'some_list = ["a", "b", "c"]'
```

## Bugs

Feel free to report bugs and request features [here](https://codeberg.org/screwery/muppy/issues).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "muppy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "c, markup, preprocessor, shell, tex, xml",
    "author": null,
    "author_email": "Ellie Viesn\u00e1 <snowboard_refinery@proton.me>",
    "download_url": "https://files.pythonhosted.org/packages/d7/48/5567cb25f5ba9661f471673d8795c315ebf41019e3036ea8c69d944d38dc/muppy-1.0.1.tar.gz",
    "platform": null,
    "description": "![Logo](https://codeberg.org/screwery/muppy/raw/branch/main/logo.svg)\n\n## Description\n\n![PyPI - Version](https://img.shields.io/pypi/v/muppy?style=flat-square)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/muppy?style=flat-square)\n![PyPI - Status](https://img.shields.io/pypi/status/muppy?style=flat-square)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/muppy?style=flat-square)\n![PyPI - License](https://img.shields.io/pypi/l/muppy?style=flat-square)\n![Gitea Issues](https://img.shields.io/gitea/issues/open/screwery/muppy?gitea_url=https%3A%2F%2Fcodeberg.org&style=flat-square)\n![Gitea Last Commit](https://img.shields.io/gitea/last-commit/screwery/muppy?gitea_url=https%3A%2F%2Fcodeberg.org&style=flat-square)\n\n**Muppy** means MarkUp Preprocessor for Python.\nIf you want some Python in markup, not some markup in Python&mdash;Muppy is probably the thing you need.\n\n---\n\n**WARNING:** This script is using `exec()`. Be careful when you execute Muppy with a file you get from strangers, and keep in mind that it can be harmful as any other Python script.\nUse Muppy script standalone from the git repo if you have reasons not to trust the wheel.\n\n## Installation\n\nThe script is pure Python and a part of [PyPI](https://pypi.org/project/muppy), so can be installed via *pip*:\n\n```bash\npython3 -m pip install muppy\n```\n\n## So, what does it do, exactly?\n\nTechnically, Muppy gets comments in various formats and executes them as Python code.\nAny text between comment blocks is treated as string literals.\n\n### Basic HTML example\n\nContents of `test.html`. Mind Python indentation after `<!-- (py):`, placeholders `?????`, and empty lines `<!-- (py):-->`:\n\n```html\n<!-- (py):print(?????)-->\n<html>\n\t<head>\n\t\t<title>\n\t\t\t<!-- (py):if lang==\"en\":--><!-- (py):  print(?????)-->Hello world!<!-- (py):-->\n\t\t\t<!-- (py):if lang==\"ru\":--><!-- (py):  print(?????)-->\u041f\u0440\u0438\u0432\u0435\u0442, \u043c\u0438\u0440!<!-- (py):-->\n<!-- (py):print(?????)-->\n\t\t</title>\n\t</head>\n\t<body>\n\t</body>\n</html>\n```\n\nShell command:\n\n```bash\nmuppy compile -s xml -i test.html -d 'lang=\"en\"'\n```\n\nThe preprocessor code to be executed:\n\n```python\n# string literals\nMUPPY_657acc3e8ec943f4b25df555b97f6157 = ''\nMUPPY_9dd9938c266b4cfb86ce9bccbfe33377 = '\\n<html>\\n\\t<head>\\n\\t\\t<title>\\n\\t\\t\\t'\nMUPPY_b9df68b0daa54bbdb969b045b8996f14 = ''\nMUPPY_8d278dc0965849c3a163a5427675b84a = 'Hello world!'\nMUPPY_39639e4d3a5c4109a760b57bc8f1388e = '\\n\\t\\t\\t'\nMUPPY_105fec3e43fa40c89d2cb39c6e5ee4cc = ''\nMUPPY_e35ecf5319b8466f8c30ed50f48e96eb = '\u041f\u0440\u0438\u0432\u0435\u0442, \u043c\u0438\u0440!'\nMUPPY_69b0bda88bba4562a765a73a6ba8caab = '\\n'\nMUPPY_918e6a4eb97149ff87eabad02d26c771 = '\\n\\t\\t</title>\\n\\t</head>\\n\\t<body>\\n\\t</body>\\n</html>\\n'\n\n# definitions\nlang=\"en\"\n\n# your code\nprint(MUPPY_9dd9938c266b4cfb86ce9bccbfe33377)\nif lang==\"en\":\n  print(MUPPY_8d278dc0965849c3a163a5427675b84a)\n\nif lang==\"ru\":\n  print(MUPPY_e35ecf5319b8466f8c30ed50f48e96eb)\n\nprint(MUPPY_918e6a4eb97149ff87eabad02d26c771)\n```\n\n### Comment styles\n\nFor now, Muppy supports the following comment styles (`-s`):\n\n| Style   | Start tag    | End tag | Description                          |\n|---------|--------------|---------|--------------------------------------|\n| `xml`   | `<!-- (py):` | `-->`   | Any XML format: HTML, SVG, FB2, etc. |\n| `c`     | `/* (py):`   | `*/`    | C, C++, CSS, PHP, etc.               |\n| `tex`   | `% (py):`    | Newline | TeX-compatible markup                |\n| `shell` | `# (py):`    | Newline | Bash, Python, etc.                   |\n\n### Definitions\n\nYou can define (`-d`) any variables as you do in common Python code:\n\n```bash\nmuppy compile -s tex -i test.html -d 'var1 = 10' 'some_list = [\"a\", \"b\", \"c\"]'\n```\n\n## Bugs\n\nFeel free to report bugs and request features [here](https://codeberg.org/screwery/muppy/issues).\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Markup Preprocessor for Python",
    "version": "1.0.1",
    "project_urls": {
        "Changelog": "https://codeberg.org/screwery/muppy/src/branch/main/CHANGELOG.md",
        "Issues": "https://codeberg.org/screwery/muppy/issues",
        "Repository": "https://codeberg.org/screwery/muppy"
    },
    "split_keywords": [
        "c",
        " markup",
        " preprocessor",
        " shell",
        " tex",
        " xml"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4912528f3f389d1e1744d99a095d62a0938d9584796547e71085f3e0c47c8f7f",
                "md5": "a624f48663747e79cf623d7dc6cc84ac",
                "sha256": "16fac5dccec5c65b7c80ab1247c6bdfcc3a7f15176ad6f932c88ef5447a18a8c"
            },
            "downloads": -1,
            "filename": "muppy-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a624f48663747e79cf623d7dc6cc84ac",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 5642,
            "upload_time": "2024-10-07T12:07:02",
            "upload_time_iso_8601": "2024-10-07T12:07:02.407325Z",
            "url": "https://files.pythonhosted.org/packages/49/12/528f3f389d1e1744d99a095d62a0938d9584796547e71085f3e0c47c8f7f/muppy-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d7485567cb25f5ba9661f471673d8795c315ebf41019e3036ea8c69d944d38dc",
                "md5": "52e483700db9b06835c60b20a20cf6c4",
                "sha256": "072fb2d4dacfdfe623340acab2794137cb2e987891951a14c8c2b2c2d8bb0d87"
            },
            "downloads": -1,
            "filename": "muppy-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "52e483700db9b06835c60b20a20cf6c4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 7292,
            "upload_time": "2024-10-07T12:07:05",
            "upload_time_iso_8601": "2024-10-07T12:07:05.448540Z",
            "url": "https://files.pythonhosted.org/packages/d7/48/5567cb25f5ba9661f471673d8795c315ebf41019e3036ea8c69d944d38dc/muppy-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-07 12:07:05",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": true,
    "codeberg_user": "screwery",
    "codeberg_project": "muppy",
    "lcname": "muppy"
}
        
Elapsed time: 1.31817s