Skip to main content

Python-based command line tool to replace text/code in files

Project description

librep

librep - LIne Block REPlacement

This python-based command-line tools allows to render file placeholders in other files. The tools is independent of the document type, since it is assumed that the chosen syntax does not interfere with syntax of any (especially markup) languages. The indent of the placeholder is used for the whole inserted code/text block.

Usage

Insert a placeholder of the following syntax inside a file (here file_with_placeholder.md):

§§§<filename>:<start>:<end>§§§

Afterwards, you can render the placeholder by running

$ 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:

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

Note that this requires wget to be installed on your machine

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:

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

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

librep-0.0.1.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

librep-0.0.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file librep-0.0.1.tar.gz.

File metadata

  • Download URL: librep-0.0.1.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.13

File hashes

Hashes for librep-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b22fdd23b855edd7d8318bcc8c9cc0eb92ca8693b9e8c791c3ea70b540cf338e
MD5 1f88ab13667253e37c0b4ba260e42df7
BLAKE2b-256 aa46d8ffae43082385193feef3e529f0fb07ab70210e451ccd3d1cf6a5e684a3

See more details on using hashes here.

File details

Details for the file librep-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: librep-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.13

File hashes

Hashes for librep-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fa61a8fa311cc920ca18941f54749f98792c9406108488cf38ce265ea9cc6b3b
MD5 6cc8bdc46a0aa9f94386a5a28818ddda
BLAKE2b-256 36cb5b4134ce3bae8df809f114f84cec6262df387aac5c02556bf821f9b91584

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