Skip to main content

Bear-note-graph 🐻🐍

PyPI version

Note: Still WIP, not as thoroughly tested as I would have liked

This is a simple CLI to generate a Graphviz-powered graph of your notes in Bear.

Example

This is an example in PNG format, with the flag --anonymise, which you can use in case you want to show your own graph but avoid showing the titles of your notes ¯\﹍(ツ)﹍/¯

Example graph

If you use the default output (PDF) you will get clickable links to notes and tags (BUT ONLY ON iOS, Preview for Mac does not open app links). I recommend you copy your graph to iCloud if you want clicking. You can see an example of the PDF here (although it is anonymised as well).

Installation

You need an environment with at least Python 3.7, and

pip install bear-note-graph

Installing graphviz

To generate the graph, the sfdp command from Graphviz needs to be available, and for some settings (like, if you want to change overlap modes) you may need to reinstall to add gts. For this, you should have homebrew available.

brew uninstall graphviz --ignore-dependencies
brew install gts
brew install graphviz

Usage

usage: bear-note-graph [-h] [--config [config]] [--dump-config]
                       [--dump-palette] [--anonymise] [--only-tags]
                       [--only-notes] [--debug]

bear-note-graph generates a Graphviz graph of your Bear notes

optional arguments:
  -h, --help         show this help message and exit
  --config [config]  Configuration file to use. Use --dump-config-file to get
                     a sample
  --dump-config      Print the default configuration file and exit
  --dump-palette     Print the default palette file and exit
  --anonymise        Mangle the tags and link names preserving 'look'
  --only-tags        Show only tag links
  --only-notes       Show only note links
  --debug            Set logging to debug level

You just need to run bear-note-graph after installing, by default everything will be output in /tmp/.

Configuration file

This is straight from the defaults

graph:
  anonymise: False                         # Make the output anonymous
  max_label_length: 50                     # Max length to show of the notes/tags
  include_only_tags: ""                    # Generate graph only for these tags (comma separated)
  exclude_titles: "readings,> "            # Skip all notes with titles containing this (comma separated)
  exclude_tags: "journal,@"                # Skip all tags containing this (comma separated)
  show_tag_edges: True                     # Whether to show tags and the linking between tags and notes
  show_note_edges: True                    # Whether to show note edges
  prune: False                             # Remove all notes with no tags (useful for include_only)
  overlap: False                           # Overlap mode for nodes in the graph
  sep: "+90,90"                            # Margins around nodes
  splines: True                            # Whether to use splines for the arrows
  bgcolor: "solarized-dark.base02"         # Background colour for the graph
  free_form: "K=0.9"                       # Any additional parameters to Graphviz
  tmp: "/tmp"                              # Temporary folder for the copy of the Bear SQLite database
  destination: "/tmp/bear_graph"           # Default destination for the Graphviz result
  output_format: "pdf"                     # Format of the output graphviz (only useful if run_graphviz is set)
  run_graphviz: "sfdp"                     # Algorithm to run automatically sfdp or neato recommended

tag:
  shape: "folder"                          # Shape
  style: "rounded,filled"                  # Style
  fill_color: "solarized-dark.yellow"      # Fill
  strike_color: "solarized-dark.orange"    # Stroke
  free_form: ""

note:
  shape: "note"
  style: "filled"
  fill_color: "solarized-dark.cyan"
  strike_color: "solarized-dark.blue"
  free_form: ""

tag_link:
  strike_color: "solarized-dark.magenta"
  arrowhead: "none"                        # Arrowhead
  free_form: "penwidth=\"2.5\""            # You can add any additional parameters

note_link:
  strike_color: "solarized-dark.green"
  arrowhead: "normal"
  free_form: "penwidth=\"2.5\""

custom_palette_here:                       # You can inline palettes here
  screaming_color: "#AAAAAA"               # You can inline palettes here

Most of the configuration parameters are for Graphviz, so check them in their documentation.

The Markdown parsing

In case you are curious, I wrote a custom Markdown parser. Because, why not, and I wanted to play with parser combinators. It is not as thoroughly tested as I would like, and it also has issues with blank spaces around the nodes, but for the purpose I wanted it, it works.

The anonymisation

This is just so I can show my own graph without showing the tags or note titles. It's based on a relatively good hashing algorithm, and does some tweaking to make it look "realistic".

Metadata

Release files for bear-note-graph 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bear-note-graph 0.1.9
File Size Uploaded Provenance
bear-note-graph-0.1.9.tar.gz 13.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bear-note-graph 0.1.9
File Interpreter ABI Platform
bear_note_graph-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 26.7 kB

Release files / bear-note-graph-0.1.9.tar.gz

Download URL bear-note-graph-0.1.9.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d789551ab238fd3ed06c2484a0a5de9c35c594e9bb3a8509ad51735e11b738a4
BLAKE2b-256 checksum
How to use checksums
5dc22d3dd681f4b8939e55f4e631513fed9bdf15321b125fa52fea7d490fa5a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.7.4 Darwin/18.7.0

Release files / bear_note_graph-0.1.9-py3-none-any.whl

Download URL bear_note_graph-0.1.9-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7acf8621d2750dce225b66209fd82dcaa6a7ddad1d9992c4181e9ac61888b522
BLAKE2b-256 checksum
How to use checksums
1d6101dd5127e6af4990a5de60b888a505840e63f3368fc0cbe2593492e8cda7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.7.4 Darwin/18.7.0

Security for bear-note-graph 0.1.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page