bear icon indicating copy to clipboard operation
bear copied to clipboard

Run on particular note or tag

Open mjknght opened this issue 5 years ago • 6 comments

This is great! A feature request for the particular: would it be possible to run the script just for a particular note or a particular tag? This comes to mind when thinking about how that might work.

mjknght avatar May 12 '20 09:05 mjknght

That would be pretty easy to limit the script to a given note if the user provides the note's UUID yes. For the tags I guess you mean restrict the script to operate on notes that include a given tag?

cglacet avatar May 12 '20 10:05 cglacet

Yes, that’s what I meant. I’d find that useful for certain tags, at least. Thanks for considering it!

mjknght avatar May 12 '20 10:05 mjknght

I'll add these two options very soon as it will only take a few lines of code :).

cglacet avatar May 12 '20 13:05 cglacet

I've updated the code in the notes-whitelist branch so we can try it out.

Here is how it can be used.

If you want to try it out, you'll have to switch to the test branch in your local copy of this repository (the install script will always install the master branch):

# depending on where you installed it, this should be the default:
cd ~/.github/bear/back-references  
git fetch
git checkout -t remotes/origin/notes-whitelist

Then you can run the python script directly using the options I mentioned in the README, for example:

BEAR_NOTES_WHITELIST=some-note-ID,some-other-note-ID \
BEAR_TAGS_WHITELIST="tag1#tag two" \
BEAR_INCLUDE_SUBTAGS=true \
python insert_backreferences.py

Let me know if you have problems with this (it's very likely that the UUID filtering will work, not so certain about the tag selection).

Once again, I recommend to run this in test mode first, just in case.

cglacet avatar May 24 '20 15:05 cglacet

@mjknght I haven't been working on this project for a while, did you have the opportunity to test this feature?

cglacet avatar Sep 14 '20 14:09 cglacet

Hi @cglacet – apologies for a late reply. I haven't had much luck with this I'm afraid. I have just tried again and still have the following when attempting to switch to the test branch and test things out:

Traceback (most recent call last):
  File "insert_backreferences.py", line 174, in <module>
    main_test()
  File "insert_backreferences.py", line 36, in main_test
    backreferences, _ = find_all_links(notes)
  File "insert_backreferences.py", line 101, in find_all_links_by_section
    for header, wiki_link in note.sections_outgoing_wiki_links:
  File "/Users/Mark/bear/bear_note.py", line 32, in sections_outgoing_wiki_links
    for link in bear_api.wiki_link(content):
  File "/Users/Mark/bear/bear_api.py", line 80, in wiki_link
    referenced_note = notes(title=link_title)[0]
  File "/Users/Mark/bear/bear_api.py", line 16, in notes
    result = conn.execute(sql_request)
sqlite3.OperationalError: near "s": syntax error

I'm not the most confident with such things, so it may be that I am making a simple mistake – any ideas?

Thanks in advance.

mjknght avatar Sep 30 '20 15:09 mjknght