Giter Site home page Giter Site logo

mhucka / zowie Goto Github PK

View Code? Open in Web Editor NEW
101.0 3.0 4.0 2.38 MB

Adds Zotero "select" links to attachment files in a Zotero database on macOS, so that outside of Zotero, you can find the bibliographic entry to which a file belongs. (Only works for local storage, not linked attachments.)

Home Page: https://mhucka.github.io/zowie

License: Other

Python 86.10% Makefile 13.90%
zotero pdf metadata macos finder file-metadata extended-attributes zotero-api pdf-files zotero-link

zowie's Issues

Encountered error KeyError: 'parentItem'

When trying to add some pdfs with this:

zowie -m findercomment,wherefrom ~/Zotero/storage/ -o

I run into this error:

Ovewriting Finder comments with Zotero link for file 
/Users/mhaehnel/Zotero/storage/2CEBUQ7U/humboldt1815-prolegomena-xiv.pdf
Overwriting "Where From" metadata with Zotero link in 
/Users/mhaehnel/Zotero/storage/2CEBUQ7U/humboldt1815-prolegomena-xiv.pdf
Encountered error KeyError: 'parentItem'

with this PDF:

humboldt1815-prolegomena-xiv.pdf

And this citation:

Screenshot 2020-12-12 at 13 53 12

Zowie for ms windows

is there any alternative for windows that can carry the same function of getting a hyperlink from Zotero document to be opened directly from another app via this link.
thanks in advance.

"tuple index out of range"

I'm sure this is on me, but I mis-entered my Zotero UserID and API key initially. On re-running Zowie with the -a argument and a newly created API key, and then the correct Zotero UserID, I'm getting a "Encountered error IndexError: tuple index out of range." and then Zowie exits. I tried running it with the debug option, but the process fails in the same place.

Python Error with sidetracked?

Hello,
This is a great idea. I'd love to have it working.
There seems to be something the matter with the python3 installation though on both of my machines.
Not sure what is causing this.

Thanks,
Maurice

Traceback (most recent call last):
File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.9/site-packages/zowie/main.py", line 33, in
from zowie.main_body import MainBody
File "/usr/local/lib/python3.9/site-packages/zowie/main_body.py", line 32, in
from .zotero import Zotero
File "/usr/local/lib/python3.9/site-packages/zowie/zotero.py", line 30, in
from sidetrack import log, logr
ImportError: cannot import name 'logr' from 'sidetrack' (/usr/local/lib/python3.9/site-packages/sidetrack/init.py)

Trying a new username id

Hello,
I was able to download and run zowie except that I inputted an incorrect user ID and when I try to try again it just keeps telling me the same error. How can I input a new user id?
-Andrea

Write zotero select link on top of each PDF page

I think your software is great: it helps me a lot in everyday researching life.

I have one suggestion for improvement: when dealing with hundreds of files per week in scientific research, the metadata step always involves opening an additional window in Acrobat Reader or other programs. In Reader it is also not possible for me to open the select link directly.

It would be much faster if zowie offered the possibility to insert the select link e.g. at the top of the PDF in small font.
Example with select item links on the right top of each page:
2022-03-30_10-23-47

I realize that this changes the PDF a lot and also takes a long time per file to insert a link on each page. However, it would give me the ability to jump immediately to Zotero with a single click when reading any page.

Thanks a lot for zowie!

sh: zowie: command not found when applying smart rule

When a new file is added, my smart rule which should create the comment with the Zotero link fails with this message:

sh: zowie: command not found

I'm using the script and the smart rule setting from this link:
https://github.com/mhucka/zowie/wiki/Example:-using-Zowie-with-DEVONthink

When I run Zowie from command line with zowie -s ~/Zotero everything works fine. I checked also the installation of Zowie with pip show zowie:

Name: zowie
Version: 1.2.0
Summary: Write Zotero select links into article attachment files
Home-page: https://github.com/mhucka/zowie
Author: Michael Hucka
Author-email: [email protected]
License: BSD 3-clause
Location: /opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages
Requires: aenum, biplist, boltons, bun, commonpy, keyring, keyrings.alt, pdfrw, plac, py-applescript, pyobjc-core, pyobjc-framework-AppleScriptKit, pyobjc-framework-AppleScriptObjC, pyxattr, pyzotero, setuptools, sidetrack
Required-by:

I tried adding /opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages to the script:
set result to do shell script ¬ ¬ "PATH=$PATH:$HOME/.local/bin:/usr/local/bin:/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages" & " zowie -s -q " & quoted_file_path

But this doesn't help. Any suggestion what might be wrong?

Find itemkey based on SQLite database

One method to solve the issue of getting the itemkey for linked attachments is to read the SQLite database ~/Zotero/zotero.sqlite, iterate through each attachment, then find the corresponding itemkey. I've peeped into the database and saw that there are two tables that would be useful: itemAttachments and items.

One can query the itemID (or perhaps parentItemID) of each attachment in the itemAttachments table then lookup the corresponding key in the items table. I've attached photos of example entries of each table.

Note that the absolute path of an attachment can be found if the attachment is linked. We can also filter attachments by whether the path column starts with storage:.

Expert from itemAttachments:
itemAttachments
Expert from items:
items

Question: using DevonThink ToGo to read / comment / index Zotero files?

Hi

Zowie sounds great - and I am will try it out but would like to know

  1. if I can index the Zotero pdf folder from DevonThink ToGo, or if I have to use DevonThink for that?
  2. when indexed (by DevonThink or ToGo), can I read the pdfs from DevonThink and from DevonThink ToGo and annotate them?

Thanks a lot,

Rainer

Error installing zowie with pipx

I'm not able to install zowie with pipx. Which pip install with no issue.

pipx install zowie
Fatal error from pip prevented installation. Full pip output in file:
    /Users/luispuerto/Developer/zzStorageRoom/dotfiles/.local/pipx/logs/cmd_2023-03-17_17.03.52_pip_errors.log

pip seemed to fail to build package:
    pyobjc-framework-Cocoa>=7.3

Some possibly relevant errors from pip install:
    error: subprocess-exited-with-error
    TypeError: not enough arguments for format string
    error: metadata-generation-failed

Error installing zowie.
Fatal error from pip prevented installation. Full pip output in file:
    /Users/luispuerto/Developer/zzStorageRoom/dotfiles/.local/pipx/logs/cmd_2023-03-17_17.03.52_pip_errors.log

pip seemed to fail to build package:
    pyobjc-framework-Cocoa>=7.3

Some possibly relevant errors from pip install:
    error: subprocess-exited-with-error
    TypeError: not enough arguments for format string
    error: metadata-generation-failed

Error installing zowie.
PIP STDOUT
----------
Collecting zowie
  Using cached zowie-1.2.0-py3-none-any.whl (38 kB)
Collecting aenum==3.1.0
  Using cached aenum-3.1.0-py3-none-any.whl (123 kB)
Collecting biplist==1.0.3
  Using cached biplist-1.0.3.tar.gz (21 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting boltons==21.0.0
  Using cached boltons-21.0.0-py2.py3-none-any.whl (193 kB)
Collecting bun==0.0.8
  Using cached bun-0.0.8-py3-none-any.whl (11 kB)
Collecting commonpy==1.5.0
  Using cached commonpy-1.5.0-py3-none-any.whl (23 kB)
Collecting keyring==23.2.1
  Using cached keyring-23.2.1-py3-none-any.whl (33 kB)
Collecting keyrings.alt==4.1.0
  Using cached keyrings.alt-4.1.0-py3-none-any.whl (20 kB)
Collecting pdfrw==0.4
  Using cached pdfrw-0.4-py2.py3-none-any.whl (69 kB)
Collecting plac==1.3.3
  Using cached plac-1.3.3-py2.py3-none-any.whl (22 kB)
Collecting py-applescript==1.0.2
  Using cached py_applescript-1.0.2-py3-none-any.whl (22 kB)
Collecting pyzotero==1.4.26
  Using cached Pyzotero-1.4.26-py2.py3-none-any.whl (27 kB)
Collecting pyxattr==0.7.2
  Using cached pyxattr-0.7.2.tar.gz (31 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting setuptools==58.3.0
  Using cached setuptools-58.3.0-py3-none-any.whl (946 kB)
Collecting sidetrack==2.0.0
  Using cached sidetrack-2.0.0-py3-none-any.whl (10 kB)
Collecting pyobjc-core==7.3.0
  Using cached pyobjc-core-7.3.tar.gz (684 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting pyobjc-framework-AppleScriptKit==7.3.0
  Using cached pyobjc_framework_AppleScriptKit-7.3-py2.py3-none-any.whl (3.8 kB)
Collecting pyobjc-framework-AppleScriptObjC==7.3.0
  Using cached pyobjc_framework_AppleScriptObjC-7.3-py2.py3-none-any.whl (3.9 kB)
Collecting pytest>=6.1.0
  Using cached pytest-7.2.2-py3-none-any.whl (317 kB)
Collecting rich>=9.0.0
  Using cached rich-13.3.2-py3-none-any.whl (238 kB)
Requirement already satisfied: wheel>=0.33.6 in ./Developer/zzStorageRoom/dotfiles/.local/pipx/shared/lib/python3.11/site-packages (from bun==0.0.8->zowie) (0.40.0)
Collecting PyYAML>=5.3.1
  Using cached PyYAML-6.0-cp311-cp311-macosx_11_0_arm64.whl (167 kB)
Collecting dateparser>=1.0.0
  Using cached dateparser-1.1.7-py2.py3-none-any.whl (293 kB)
Collecting h2>=3.2.0
  Using cached h2-4.1.0-py3-none-any.whl (57 kB)
Collecting httpx>=0.18.2
  Using cached httpx-0.23.3-py3-none-any.whl (71 kB)
Collecting humanize>=3.0.0
  Using cached humanize-4.6.0-py3-none-any.whl (109 kB)
Collecting python-dateutil>=2.8.1
  Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting tldextract>=2.2.3
  Using cached tldextract-3.4.0-py3-none-any.whl (93 kB)
Collecting validator-collection>=1.5.0
  Using cached validator_collection-1.5.0-py2.py3-none-any.whl (36 kB)
Collecting importlib-metadata>=3.6
  Using cached importlib_metadata-6.0.0-py3-none-any.whl (21 kB)
Collecting pyobjc-framework-Cocoa>=7.3
  Using cached pyobjc_framework_Cocoa-9.0.1-cp311-cp311-macosx_10_9_universal2.whl (388 kB)
Collecting pytz
  Using cached pytz-2022.7.1-py2.py3-none-any.whl (499 kB)
Collecting requests>=2.21.0
  Using cached requests-2.28.2-py3-none-any.whl (62 kB)
Collecting bibtexparser
  Using cached bibtexparser-1.4.0.tar.gz (51 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting feedparser>=6
  Using cached feedparser-6.0.10-py3-none-any.whl (81 kB)
Collecting regex!=2019.02.19,!=2021.8.27
  Using cached regex-2022.10.31-cp311-cp311-macosx_11_0_arm64.whl (287 kB)
Collecting tzlocal
  Using cached tzlocal-4.2-py3-none-any.whl (19 kB)
Collecting sgmllib3k
  Using cached sgmllib3k-1.0.0.tar.gz (5.8 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting hyperframe<7,>=6.0
  Using cached hyperframe-6.0.1-py3-none-any.whl (12 kB)
Collecting hpack<5,>=4.0
  Using cached hpack-4.0.0-py3-none-any.whl (32 kB)
Collecting certifi
  Using cached certifi-2022.12.7-py3-none-any.whl (155 kB)
Collecting httpcore<0.17.0,>=0.15.0
  Using cached httpcore-0.16.3-py3-none-any.whl (69 kB)
Collecting rfc3986[idna2008]<2,>=1.3
  Using cached rfc3986-1.5.0-py2.py3-none-any.whl (31 kB)
Collecting sniffio
  Using cached sniffio-1.3.0-py3-none-any.whl (10 kB)
Collecting zipp>=0.5
  Using cached zipp-3.15.0-py3-none-any.whl (6.8 kB)
Collecting pyobjc-framework-Cocoa>=7.3
  Using cached pyobjc_framework_Cocoa-9.0-cp311-cp311-macosx_10_9_universal2.whl (388 kB)
  Using cached pyobjc_framework_Cocoa-8.5.1-cp311-cp311-macosx_10_9_universal2.whl (388 kB)
  Using cached pyobjc-framework-Cocoa-8.5.tar.gz (4.6 MB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
  Using cached pyobjc-framework-Cocoa-8.4.1.tar.gz (4.6 MB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
  Using cached pyobjc-framework-Cocoa-8.4.tar.gz (4.6 MB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
  Using cached pyobjc-framework-Cocoa-8.3.tar.gz (4.0 MB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
  Using cached pyobjc-framework-Cocoa-8.2.tar.gz (4.0 MB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
  Using cached pyobjc-framework-Cocoa-8.1.tar.gz (4.0 MB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
  Using cached pyobjc-framework-Cocoa-8.0.tar.gz (4.0 MB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
  Using cached pyobjc-framework-Cocoa-7.3.tar.gz (3.5 MB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'

PIP STDERR
----------
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [9 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/zm/clm72_7978105k4sj96x794r0000gn/T/pip-install-tspdoh0w/pyobjc-framework-cocoa_e861cadae9024920801682e43b4fabd0/setup.py", line 23, in <module>
          Extension(
        File "/private/var/folders/zm/clm72_7978105k4sj96x794r0000gn/T/pip-install-tspdoh0w/pyobjc-framework-cocoa_e861cadae9024920801682e43b4fabd0/pyobjc_setup.py", line 459, in Extension
          "-DPyObjC_BUILD_RELEASE=%02d%02d" % (tuple(map(int, os_level.split("."))))
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      TypeError: not enough arguments for format string
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

-d option can't be used wit ~/Zotero folder

I tried to select only the recent files by using the -d option like that: zowie -d "2022-02-18" -s ~/Zotero. But in that case, zowie is only looking at the given folder and is not searching the sub-folders, which results in this message:

Will process 1 file using method findercomment.
Unable to retrieve Zotero record for /Users/myusername/Zotero

Do I need to add another option?

New Failure: ImportError: cannot import name '_objc' from partially initialized module 'objc' (most likely due to a circular import)

Started sometime after installing the most recent zowie update. Have reinstalled with same result.

macOS 13.5.2
Python 3.9.6
zowie 1.3.0 for Python 3.9

Zowie fails to start, gives traceback with error:

ImportError: cannot import name '_objc' from partially initialized module 'objc' (most likely due to a circular import) (/Users/username/.shiv/zowie_31546c4ecd8bf8e4b3cad617a60dd581617524d69e1487d41d9aeb4e1df8ddb0/site-packages/objc/__init__.py)

Sonoma

Hi,

I love Zowie.

But, after updating to Sonoma, I got the following error in Deveonthink, which was running smoothly before:

The self-contained executable of Zowie 1.3.0 that you are
attempting to run was built to work specifically (and only)
with version 3.11 of Python. The version of Python obtained
by running "python3" on your computer is 3.9. This makes it
incompatible and prevents this copy of Zowie from running.

However it works in terminal as follows:
zowie /path to folder/Zotero -s -KEY -i ID -d "2023-09-01"

What I did
A)
I deleted Python.
However, there is a Python in user/bin I can't get rid of. This must be the default and protected Python installed by Apple. I found some information telling me: Don't touch that!

B)
I reinstalled Python 3.11.0 and looked for other versions of Python, but none were found:
python3 --version
Python 3.11.0

whereis python3
python3: /usr/bin/python3 /Library/Frameworks/Python.framework/Versions/3.11/share/man/man1/python3.1

C)
I reinstalled Zowie:
python3 -m pip install zowie

D) I checked the path in
sudo nano /etc/paths
It is as follows:

/usr/local/bin
/System/Cryptexes/App/usr/bin
/usr/bin
/bin
/usr/sbin
/sbin

In the Devonthink script, I entered the path to Zowie:
set result to do shell script
"/usr/local/bin/zowie -s -q"

But still, Devonthink/Zowie do not find Python 3.11.0.

How can I tell Deventhink/Zowie to use Python 3.11.0?

Best wishes, Christof

Allow use with other files besides PDFs

The findercomment and wherefrom methods actually don't have anything to do with PDF files, and could work for other file types. Zowie could therefore support the ability to work on more file types besides PDF. (Perhaps it should have a flag to indicate file extensions to work on. Maybe --file-type or --extensions?)

Problem running script in Devonthink

I have downloaded ZOWIE from your site and installed it and works fine running from the command line. I am using python 3.9. I also have implanted the Devonthink rules that you list. The 'Run Zowie on newly indexed PDF.applescript' scrript, throws an error within Devonthink saying that I have python 3.8. Don't understand why it runs at command line but not in the script. Possible has something to do with the path, but not sure. Any thoughts? Thanks in advance for your help.

Suggest to loosen the dependency on boltons

Hi, your project zowie(commit id: 9f840a7) requires "boltons==21.0.0" in its dependency. After analyzing the source code, we found that the following versions of boltons can also be suitable, i.e., boltons 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.6.4, 0.6.5, 0.6.6, 15.0.0, 15.0.1, 15.0.2, 15.1.0, 15.1.1, 16.0.0, 16.0.1, 16.1.0, 16.1.1, 16.2.0, 16.2.1, 16.2.2, 16.3.0, 16.3.1, 16.4.0, 16.4.1, 16.5.0, 16.5.1, 17.0.0, 17.1.0, 17.2.0, 18.0.0, 18.0.1, 19.0.0, 19.0.1, 19.1.0, 19.2.0, 19.3.0, 20.0.0, 20.1.0, 20.2.0, 20.2.1, since all functions that you directly (1 APIs: boltons.debugutils.pdb_on_signal) or indirectly (propagate to 0 boltons's internal APIs and 3 outsider APIs) used from the package have not been changed in these versions, thus not affecting your usage.

Therefore, we believe that it is quite safe to loose your dependency on boltons from "boltons==21.0.0" to "boltons>=0.6.0,<=21.0.0". This will improve the applicability of zowie and reduce the possibility of any further dependency conflict with other projects.

May I pull a request to further loosen the dependency on boltons?

By the way, could you please tell us whether such an automatic tool for dependency analysis may be potentially helpful for maintaining dependencies easier during your development?

Update to Python 3.12?

Hi, I really like Zowie but it does not have a Python 3.12 version. Would it be possible to have an updated version?

Thanks,
SS

Doesn't work with linked attachments?

Can you please put this issue (a disclaimer) at the very beginning of the Readme file (or the post)?

Most people use Zotero with Zotfile extension (linked attachments).

I went through all the processes of setting up, and running the commands, only to learn later that this script doesn't work for linked attachments.

What a waste of time.

Have you made me know from the beginning, I would have never installed it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.