Skip to main content

Grep-like filter for the Beancount plain text accounting system

Project description

CI status

Beangrep - grep-like filter for Beancount

Beangrep is a grep-like filter for the Beancount plain text accounting system.

Installation

Prebuilt package

$ python3 -m venv ./venv    # optional but recommended
$ source venv/bin/activate

$ pip install beangrep
[...]
Successfully installed beancount-2.3.6 beangrep-...

$ bean-grep --help
Usage: bean-grep [OPTIONS] FILENAME
[...]

From source

$ git clone https://github.com/zacchiro/beangrep
$ cd beangrep

$ python3 -m venv ./venv    # optional but recommended
$ source venv/bin/activate

$ pip install -e .
[...]
Successfully installed beancount-2.3.6 beangrep-...

$ bean-grep --help
Usage: bean-grep [OPTIONS] FILENAME
[...]

Usage

The CLI says it all when invoked as bean-grep --help:

Usage: bean-grep [OPTIONS] [PATTERN] FILENAME...

  Search for entries matching given criteria in Beancount journals. Pretty
  print matching entries to standard output.

  Search criteria can be specified with the options below and/or providing an
  explicit "smart" PATTERN. If given, PATTERN is interpreted as described
  below under "Patterns". If not given, search criteria are defined by
  explicit options.

  Multiple options, options given mutiple times, and PATTERN(s) are logically
  joined (AND-ed) together.

  The granularity of matching (and results) is that of individual entries,
  e.g., full transactions, balances, notes, etc. By default only transactions
  are returned; use the --type/-T option to override.

  To read from standard input, pass "-" as FILENAME, but beware that it
  implies on-disk buffering of stdin.

Options:
  -a, --account REGEX             Only return entries referencing accounts
                                  with names matching given regex.
  -A, --amount "[OP]AMOUNT [REGEX]"
                                  Only return entries with amounts matching
                                  the given amount predicate. An amount
                                  predicate start with an optional comparison
                                  operator (one of "<", "<=", "=", ">=", ">",
                                  with "=" being the default), followed by a
                                  decimal number (using "." as decimal
                                  separator), followed by an optional currency
                                  regex. Multiple amount predicates can be
                                  given to express complex amount ranges.
  -d, --date [OP]DATE             Only return entries with dates matching the
                                  given date predicate. A date predicate start
                                  with an optional comparison operator (one of
                                  "<", "<=", "=", ">=", ">", with "=" being
                                  the default), and is followed by a date in
                                  the form YYYY-[MM[-DD]]. Multiple date
                                  predicates can be given to express complex
                                  date ranges.
  -l, --link REGEX                Only return entries with at least one link
                                  matching given regex.
  -m, --meta, --metadata REGEX[:REGEX]
                                  Only return entries with at least one
                                  metadata key/value pair matching given
                                  pattern. A pattern is a pair of regexs
                                  separated by ":", the former matching on
                                  metadata key, the latter on metadata value.
                                  The second regex is optional and defaults to
                                  ".*".
  -n, --narration REGEX           Only return entries whose narrations match
                                  given regex.
  -p, --payee REGEX               Only return entries whose payees match given
                                  regex.
  -s, --somewhere, --anywhere REGEX
                                  Only return entries with a value in them,
                                  anywhere, matching given regex.
  -t, --tag REGEX                 Only return entries with at least one tag
                                  matching given regex. The tag can be located
                                  anywhere.
  -T, --type TYPE(S)              Only return entries of certain types.  Types
                                  are specified as a ","-separated list of
                                  type names; type names are: open, close,
                                  commodity, pad, balance, transaction, note,
                                  event, query, price, document, custom. The
                                  special value "all" means: all directive
                                  types. [default: transaction]
  --case-sensitive                Search case sensitively. Overrides:
                                  -i/--ignore-case and -S/--smart-case.
  -i, --ignore-case               Search case insensitively. Overrides
                                  -S/--smart-case; overridden by --case-
                                  sensitive.
  -S, --smart-case                Search case insensitively if all criteria
                                  are lowercase, sensitively otherwise.
                                  Overridden by: --case-sensitive and
                                  -i/--ignore-case.  [default: True]
  --posting-tags-meta TEXT        Metadata key used to attach tags to
                                  transaction postings.  [default: tags]
  -q, --quiet / --no-quiet        Quiet, do not write anything to standard
                                  output. Exit successfully immediately if any
                                  match is found.  [default: no-quiet]
  --skip-internals / --no-skip-internals
                                  When matching, ignore internal information
                                  not visible in the ledger. This includes the
                                  automatic metadata: ['filename', 'lineno']
                                  [default: skip-internals]
  -v, --invert-match              Invert the sense of matching: return entries
                                  that do *not* match given criteria. This
                                  clears the default "--type transaction"
                                  criteria, to avoid only returning non-
                                  transaction entries by default.
  --verbose                       Increase logging verbosity. Default
                                  verbosity is at WARNING level; passing this
                                  option once will increase it to INFO, twice
                                  or more to DEBUG.
  -V, --version                   Show the version and exit.
  --help                          Show this message and exit.

  Patterns:

  When given the "smart" PATTERN is interpreted according to the following
  heuristics, tried in order, first match wins:

  - if it is in the form "YYYY-MM-DD" -> then it is interpreted as --date

  - "#tag" -> --tag

  - "^link" -> --link

  - "@payee" -> --payee

  - if it starts with one of the five account types ("Assets", "Equity",
  "Expenses",   "Income", "Liabilities") -> --account

  - "key:value" -> --metadata

  - otherwise -> --somewhere

  Exit status:

  Exit status is 0 (success) if a match is found, 1 if no match is found, 2 if
  an error occurred.

Author

License

Beangrep is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

A copy of the GNU General Public License is distributed with Beangrep as well as from the official license page.

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

beangrep-0.5.0.tar.gz (55.4 kB view details)

Uploaded Source

Built Distribution

beangrep-0.5.0-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file beangrep-0.5.0.tar.gz.

File metadata

  • Download URL: beangrep-0.5.0.tar.gz
  • Upload date:
  • Size: 55.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for beangrep-0.5.0.tar.gz
Algorithm Hash digest
SHA256 1edc375d75df0d2b4fad99ac949bd9ed89fccb1c16f2e27d75916b48d9e79964
MD5 a4368bd561e02267ce2dd8c0760d2dd2
BLAKE2b-256 a895d65f784a1f556c342da26315e448fb999c7f7ae898a3c1d58162742f4d80

See more details on using hashes here.

File details

Details for the file beangrep-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: beangrep-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for beangrep-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05004e4792646b1e8144c2e19fb60847fcd0a93b5df60b6eace86af0b24143aa
MD5 a5662aecc85290d9d609ff3bf380731e
BLAKE2b-256 d72b3321a4bf78e90016687e5dc04a4bdc8132a943e52bfe787ef375c39ba22e

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