跳转到主要内容

Beancount纯文本会计系统的grep-like过滤器

项目描述

CI status

Beangrep - Beancount的grep-like过滤器

Beangrep 是一个针对 grep 的类似过滤器,用于 Beancount 纯文本会计系统。

安装

预构建包

$ 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
[...]

从源码

$ 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
[...]

使用方法

当作为 bean-grep --help 调用时,CLI说明了所有内容

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.

  All options can be set via environment variables, which is most useful if
  you want to override the defaults. Each environment variable
  consists of the prefix BEANGREP_ followed by the option name in uppercase.
  e.g., BEANGREP_VERBOSE, BEANGREP_CASE_SENSITIVE, BEANGREP_QUIET,
  BEANGREP_NO_SKIP_INTERNALS, etc. Boolean options are enabled/disabled by
  setting the corresponding variables to 1/0 respectively, e.g.,
  BEANGREP_QUIET=1.

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.
  -f, --flag REGEX                Only return transactions with at least one
                                  flag matching the given regex (usually a
                                  single character, properly escaped).  Both
                                  transaction and posting flags are used for
                                  matching.
  -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.

作者

许可证

Beangrep 是免费软件;您可以在自由软件基金会发布的GNU通用公共许可证的条款下重新分发和/或修改它;许可证的版本为2,或者(根据您的选择)任何更高版本。

此程序的分发旨在使其有用,但没有任何保证;甚至没有关于其适销性或适用于特定目的的隐含保证。有关详细信息,请参阅GNU通用公共许可证。

GNU通用公共许可证的副本与Beangrep一起分发,并可在官方许可证页面上找到。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

beangrep-0.6.0.tar.gz (56.7 kB 查看哈希值)

上传时间

构建分布

beangrep-0.6.0-py3-none-any.whl (25.7 kB 查看哈希值)

上传时间 Python 3

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面