librep


Namelibrep JSON
Version 0.0.5 PyPI version JSON
download
home_pagehttps://github.com/umami-hep/librep
SummaryPython-based command line tool to replace text/code in files
upload_time2022-05-16 08:23:55
maintainer
docs_urlNone
author
requires_python>=3.8
license
keywords tools
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # librep - LIne Block REPlacement

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![PyPI version](https://badge.fury.io/py/librep.svg)](https://badge.fury.io/py/librep)

![Testing workflow](https://github.com/umami-hep/librep/actions/workflows/testing.yml/badge.svg)
![Linting workflow](https://github.com/umami-hep/librep/actions/workflows/linting.yml/badge.svg)

`librep` is a python-based command-line tools allows to render file placeholders.
It replaces a placeholder of a given syntax with the content of the file that is
specified in the placeholder.

The tool is independent of the document type, since it is assumed that the chosen
syntax does not interfere with the syntax of any (especially markup) language.

The indentation of the placeholder is used for the whole inserted code/text block.

## Usage

Insert a placeholder of the following syntax inside a file:

```md
§§§<filename>:<start>:<end>§§§
```

Afterwards, you can render the placeholder by running

```bash
$ librep -i "file_with_placeholder.md"
```

This will replace the original line in the file `file_with_placeholder.md` with
the content of the file `<filename>` from line `<start>` to line `<end>`.
The `filename` has to either be absolute or relative to the file you specify the
placeholder in.

**Using a URL instead of a file from the repository**

If you want to link a file that is not present on your machine, but you have a URL
to that exact file, you can use the following syntax:

```md
§§§url="<url>":<start>:<end>§§§
```

_Note that this requires `wget` to be installed on your machine_

## Example

This file `file_with_placeholders.md`

````md
# Heading

Check out this awesome python code!

```py
§§§./code.py§§§
```
````

Can be processed with `librep` by doing

```bash
$ librep -i "file_with_placeholder.md"
```

Which results in

````md
# Heading

Check out this awesome python code!

```py
def calc_sum(a, b):
    """Calculates the sum of a+b
    Parameters
    ----------
    a : float, int
        First number
    b : float, int
        Second number
    Returns
    -------
    sum : float
        Sum of a and b
    """

    return a + b
```
````

## Examples

Below you can find different versions for inserting different parts of the file
`examples/plotting/plot_rocs.py` into your markdown file.

| Placeholder                    | Result                  |
| ------------------------------ | ----------------------- |
| `§§§examples/file.py§§§`       | whole file              |
| `§§§examples/file.py::§§§`     | whole file              |
| `§§§examples/file.py:10:20§§§` | from line 10 to line 20 |
| `§§§examples/file.py::10§§§`   | from top to line 10     |
| `§§§examples/file.py:10§§§`    | from line 10 to bottom  |
| `§§§examples/file.py:10:§§§`   | from line 10 to bottom  |

## Installation

`librep` can simply be installed using `pip install`:

```bash
pip install librep
# or
pip install https://github.com/umami-hep/librep/archive/master.tar.gz
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/umami-hep/librep",
    "name": "librep",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "tools",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/ef/97/2fbabe2efae965206f5f628a905d5ba4297a1dca19118a7c12a57780e8eb/librep-0.0.5.tar.gz",
    "platform": null,
    "description": "# librep - LIne Block REPlacement\n\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![PyPI version](https://badge.fury.io/py/librep.svg)](https://badge.fury.io/py/librep)\n\n![Testing workflow](https://github.com/umami-hep/librep/actions/workflows/testing.yml/badge.svg)\n![Linting workflow](https://github.com/umami-hep/librep/actions/workflows/linting.yml/badge.svg)\n\n`librep` is a python-based command-line tools allows to render file placeholders.\nIt replaces a placeholder of a given syntax with the content of the file that is\nspecified in the placeholder.\n\nThe tool is independent of the document type, since it is assumed that the chosen\nsyntax does not interfere with the syntax of any (especially markup) language.\n\nThe indentation of the placeholder is used for the whole inserted code/text block.\n\n## Usage\n\nInsert a placeholder of the following syntax inside a file:\n\n```md\n\u00a7\u00a7\u00a7<filename>:<start>:<end>\u00a7\u00a7\u00a7\n```\n\nAfterwards, you can render the placeholder by running\n\n```bash\n$ librep -i \"file_with_placeholder.md\"\n```\n\nThis will replace the original line in the file `file_with_placeholder.md` with\nthe content of the file `<filename>` from line `<start>` to line `<end>`.\nThe `filename` has to either be absolute or relative to the file you specify the\nplaceholder in.\n\n**Using a URL instead of a file from the repository**\n\nIf you want to link a file that is not present on your machine, but you have a URL\nto that exact file, you can use the following syntax:\n\n```md\n\u00a7\u00a7\u00a7url=\"<url>\":<start>:<end>\u00a7\u00a7\u00a7\n```\n\n_Note that this requires `wget` to be installed on your machine_\n\n## Example\n\nThis file `file_with_placeholders.md`\n\n````md\n# Heading\n\nCheck out this awesome python code!\n\n```py\n\u00a7\u00a7\u00a7./code.py\u00a7\u00a7\u00a7\n```\n````\n\nCan be processed with `librep` by doing\n\n```bash\n$ librep -i \"file_with_placeholder.md\"\n```\n\nWhich results in\n\n````md\n# Heading\n\nCheck out this awesome python code!\n\n```py\ndef calc_sum(a, b):\n    \"\"\"Calculates the sum of a+b\n    Parameters\n    ----------\n    a : float, int\n        First number\n    b : float, int\n        Second number\n    Returns\n    -------\n    sum : float\n        Sum of a and b\n    \"\"\"\n\n    return a + b\n```\n````\n\n## Examples\n\nBelow you can find different versions for inserting different parts of the file\n`examples/plotting/plot_rocs.py` into your markdown file.\n\n| Placeholder                    | Result                  |\n| ------------------------------ | ----------------------- |\n| `\u00a7\u00a7\u00a7examples/file.py\u00a7\u00a7\u00a7`       | whole file              |\n| `\u00a7\u00a7\u00a7examples/file.py::\u00a7\u00a7\u00a7`     | whole file              |\n| `\u00a7\u00a7\u00a7examples/file.py:10:20\u00a7\u00a7\u00a7` | from line 10 to line 20 |\n| `\u00a7\u00a7\u00a7examples/file.py::10\u00a7\u00a7\u00a7`   | from top to line 10     |\n| `\u00a7\u00a7\u00a7examples/file.py:10\u00a7\u00a7\u00a7`    | from line 10 to bottom  |\n| `\u00a7\u00a7\u00a7examples/file.py:10:\u00a7\u00a7\u00a7`   | from line 10 to bottom  |\n\n## Installation\n\n`librep` can simply be installed using `pip install`:\n\n```bash\npip install librep\n# or\npip install https://github.com/umami-hep/librep/archive/master.tar.gz\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python-based command line tool to replace text/code in files",
    "version": "0.0.5",
    "split_keywords": [
        "tools"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "8344e1d416c59e6c3864add9ca203863",
                "sha256": "37074435e5812508e6697f57f064d734e6b91ab1d60e2420cce21265f6a059ae"
            },
            "downloads": -1,
            "filename": "librep-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8344e1d416c59e6c3864add9ca203863",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 9874,
            "upload_time": "2022-05-16T08:23:54",
            "upload_time_iso_8601": "2022-05-16T08:23:54.333657Z",
            "url": "https://files.pythonhosted.org/packages/d5/d9/bdb362e6bf816860f490b1afa489c11db846630bcc4bd04b117e6f16bfff/librep-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "1a379f72ee1121efd3ac08f58ff6704a",
                "sha256": "8a0b4b2155a9788b18175e52f4c143a1621d7d8d268a3c4f206815ca5ea67952"
            },
            "downloads": -1,
            "filename": "librep-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "1a379f72ee1121efd3ac08f58ff6704a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 9722,
            "upload_time": "2022-05-16T08:23:55",
            "upload_time_iso_8601": "2022-05-16T08:23:55.702373Z",
            "url": "https://files.pythonhosted.org/packages/ef/97/2fbabe2efae965206f5f628a905d5ba4297a1dca19118a7c12a57780e8eb/librep-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-05-16 08:23:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "umami-hep",
    "github_project": "librep",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "librep"
}
        
Elapsed time: 0.01436s