Skip to main content

Grep for Unstructured Multiline Paragraphs

Project description


Grep for Unstructured Multiline Paragraphs

A multiline paragraph is a string in which there are no 'empty lines' - two newlines separated only by whitespace. For example given data.txt:

This is
one multiline

This is

This one is too!

grump takes a file and a list of strings and outputs all multiline paragraphs of this file containing each string in the list. For example:

$ grump -f data.txt this one
This is
one multiline

This one is too!


python3 -m pip install grump


usage: grump [-h] [-w] [-c] [-f FILENAME] regex [regex ...]

Grep for unstructured multiline paragraphs

positional arguments:
  regex                 the string or regular expression to match against

optional arguments:
  -h, --help            show this help message and exit
  -w, --word            only match whole words
  -c, --case-sensitive  Perform case sensitive matching. By default, grump is case insensitive.
                        the file to grep (default: STDIN)


From the CLI

grump -f testdata.txt amy fred
grump amy fred < testdata.txt
cat testdata.txt | grump amy fred
grump --file testdata.txt amy fred --word --case-sensitive
grump -f testdata.txt amy fred -w -c

As a module

import grump

# with text from textfile.txt
with grump.Grump('textfile.txt', ('amy','fred')) as matches:
    for p in matches:

# with text from STDIN
with grump.Grump(None, ('amy','fred')) as matches:
    for p in matches:

# with non-default matching rules
with grump.Grump(
    ) as matches:


black grump/
black tests/
  • Make a pull request


Give it a new version:

bump2version --no-commit --no-tag patch

and remove --no-commit and --no-tag when you're sure. Then

git push
git push --tags

Note, "patch" indicates a bugfix or minor improvement.

  • If there are new, backward compatible features change "patch" to "minor"
  • If there are backward incompatible changes change "patch" to "major"

Package it:

python clean --all
rm -rf dist/ build/ grump.egg-info/ grump_andrewsolomon.egg-info/
python sdist bdist_wheel

Upload it to test pypi:

twine upload --repository-url dist/*

install it from there:

python3 -m pip install --upgrade -i grump

Then upload it to

twine upload dist/*

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for grump, version 0.0.12
Filename, size File type Python version Upload date Hashes
Filename, size grump-0.0.12-py3-none-any.whl (10.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size grump-0.0.12.tar.gz (5.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page