Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnboundLocalError: local variable 'tags' referenced before assignment #18

Open
ludzeller opened this issue Oct 5, 2017 · 4 comments
Open

Comments

@ludzeller
Copy link

Hi!

I ran

python menotexport.py -ns -f "Promotion" /Users/ludwig/Library/Application\ Support/Mendeley\ Desktop/[email protected]@www.mendeley.com.sqlite output

and I get

=============================== 27/167 ===============================
# <Menotexport>: Processing folder: "Promotion/Projekte /
Kolloquien/Kritische Artefakte/Bibliografie"
Traceback (most recent call last):
  File "menotexport.py", line 1455, in <module>
    args.separate,args.zotero,args.verbose)
  File "menotexport.py", line 1302, in main
    fidii,fnameii,allfolders,action,separate,iszotero,verbose)
  File "menotexport.py", line 1017, in processFolder
    annotations = getDocNotes(db, annotations, folderid,foldername)
  File "menotexport.py", line 645, in getDocNotes
    meta['tags']=tags
UnboundLocalError: local variable 'tags' referenced before assignment

Any ideas?

As you can see 26 folders (I guess?) were processed successfully...

@Xunius
Copy link
Owner

Xunius commented Oct 6, 2017

Hi ludzeller,

Yes it got 26 folders (subfolders in Promotion to be specific) done but failed at the 27th.
I had some trouble reproducing your error, but it is certainly some error in the code.
Can you give me the version of Mendeley you are using, and some other info regarding the document that failed at? Apparently it failed at retrieving the "tags" field, so what's in the "tags" field in the document it failed in your Mendeley? And lastly, you are using in windows right?

Sorry for the trouble.

@ludzeller
Copy link
Author

Thanks for getting back so fast and no need to apologise, I am looking forward to being able to make plain text from my notes... :)

I am on macOS 10.12.4 (16E195) using Mendeley 1.17.11.

I realised that I had plenty of / characters in my folder names, but also after removing them, I got the same error.

The folder it hangs has three entries, one with one PDF, one with three PDFs and one with none.

I don't know which one was processed first. But one of the PDF has the tag "Civilization; Europe; Fetishism; Folder - Ergänzung SNF 1" and another one "Folder - Ergänzung SNF 1".

Actually I never add tags. These have been added by Mendeley or some other tools somehow. I wouldn't mind if there was a flag to simply omit the tags?

For a test I just removed these two tags and it was able to process the folder then... Could it be some bad characters?

@Xunius
Copy link
Owner

Xunius commented Oct 6, 2017

Many thanks for the feedback. However I still couldn't reproduce the error, it doesn't seem to be bad characters though.
How is you export working? I've made a dirty patch that should get it working but will lose the tags when that error would occur. If you don't mind losing those tags, you could either delete them manually in Mendeley, or download the code again and give it a try.
P.S. I never realized that you can attach multiple files to a single document. I have no idea how that would affect this software, I'll mess around a bit more. What's your user case when having 3 files attached to a doc?

@ludzeller
Copy link
Author

Sorry for getting back so late. After I removed the probably filthy tags (just in one entry), I was able to process my whole library! But I guess the new flag could be handy at some point, at least for others!

And yes, I have some entries with multiple PDFs attached. In one case, where I had two PDF files, your script just created a file for the second PDF - Mendeley added a (2) to the filename of the PDF and your output mirrors that. The first PDF did not have any notes, so I cannot say if your code would always take the last (or second) PDF of that array - or if it only skips files without any annotations added. The latter was the case for that PDF #1.

Should I do more testing? Multiple files are rare for me, but they do occur. And of course it would be good to have all of them processed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants