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

Multiple Tags in One Document causes Error #14

Open
StRuoff opened this issue Sep 6, 2017 · 9 comments
Open

Multiple Tags in One Document causes Error #14

StRuoff opened this issue Sep 6, 2017 · 9 comments

Comments

@StRuoff
Copy link

StRuoff commented Sep 6, 2017

When having multiple Tags in a Document in Mendeley, the following error shows up if you want to write a "ris" file:

Traceback (most recent call last): File "menotexport.py", line 1445, in <module> args.separate,args.zotero,args.verbose) File "menotexport.py", line 1292, in main fidii,fnameii,allfolders,action,separate,iszotero,verbose) File "menotexport.py", line 1057, in processFolder tagsdict=extracttags.groupByTags(annotations) File "/home/ruof_st/.Software/anaconda2/lib/python2.7/site-packages/lib/extracttags.py", line 38, in groupByTags tagsii=['@'+kk for kk in tagsii] TypeError: cannot concatenate 'str' and 'list' objects
Also, if this error is not showing up (by convering the list to a string in extracttags.py), the script stops at:

# <Menotexport>: Exporting meta-data and annotations to .ris file... Traceback (most recent call last): File "menotexport.py", line 1444, in <module> args.separate,args.zotero,args.verbose) File "menotexport.py", line 1291, in main fidii,fnameii,allfolders,action,separate,iszotero,verbose) File "menotexport.py", line 1098, in processFolder risfolder,allfolders,isfile,iszotero,verbose) File "/home/ruof_st/.Software/anaconda2/lib/python2.7/site-packages/lib/export2ris.py", line 263, in exportAnno2Ris allfolders,isfile,iszotero,verbose) File "/home/ruof_st/.Software/anaconda2/lib/python2.7/site-packages/lib/export2ris.py", line 287, in exportDoc2Ris risdata=parseMeta(docii,basedir,isfile,iszotero) File "/home/ruof_st/.Software/anaconda2/lib/python2.7/site-packages/lib/export2ris.py", line 200, in parseMeta keywords=list(set(keywords)) TypeError: unhashable type: 'list'

If I print, how the tags look like in the python code it gives this:
[[u'LES', u'detailed chemistry', u'diagnostics', u'swirl burner'], u'LES']
If I am right, the tags are loaded in a List, and afterwards the folder name is added to the list, making it a list of lists, causing the problem.

@Xunius
Copy link
Owner

Xunius commented Sep 6, 2017

Hi StRuoff
Thanks for reporting. Do you get any error exporting to "bib" files?
I'll have a closer look in the weekend.

@StRuoff
Copy link
Author

StRuoff commented Sep 7, 2017

Yes, I get it for bib too.
I think the error is caused by
else: tags=[meta['tags'],folder]
in Line 390 of menotexport.py. That is in the section getting the highlighting in the PDFs (function getHighlights). A similar line is found in the getNotes and getDocNotes, but the elif condition before that else is a bit different. Maybe that's causing the problem.

What I forgot to mention: I am using Python 2.7.13 with an anaconda2 installation on a SLED12 mashine. Maybe that error doesn't appear in Python3.

@StRuoff
Copy link
Author

StRuoff commented Sep 7, 2017

The condition I mentioned is:
elif type(meta['tags']) is list and folder not in meta['tags']:
The Problem for me is, that one of the Tags in the Document is the same as the folder name, making the condition false and jumping to the above mentiond else statement.
Is this the intended behaviour, and if yes, why is this condition different to the other two functions I metnioned above?

@Xunius
Copy link
Owner

Xunius commented Sep 9, 2017

Hi StRuooff,
I just got time to look into this. You mentioned at Line 390 of menotexport.py the line is:

else: tags=[meta['tags'],folder]

But in the most recent (it's actually quite some time ago) line 390 is:

elif type(meta['tags']) is list and folder in meta['tags']:

which is the condition for folder name being the same as one the tags in in the tag list.
So I wonder could you be using an older version and I've patched this problem up already?

Btw the treatment for that condition is

tags=meta['tags']

So it doens't add the folder to the tag list again.

@Xunius
Copy link
Owner

Xunius commented Sep 9, 2017

I got it.
You mentened that you installed via anaconda. I just checked it and indeed the anaconda version is wrong.
I've fixed that. Pls try upgrade it:

conda install -c guangzhi menotexport

which will upgrade to 1.4.3. Give it a try and let me know if you encounter any further error.
Sorry for the trouble.

@StRuoff
Copy link
Author

StRuoff commented Sep 11, 2017

Thanks for the response!
I figured it out myself, how to patch it, an ended up with exactly the line you suggested to add.
Are there other enhancements in the new version?

@Xunius
Copy link
Owner

Xunius commented Sep 11, 2017

Good!
I don't think there's anything new. If you have any idea in mind just let me know.

@StRuoff
Copy link
Author

StRuoff commented Sep 11, 2017

can I post my questions in this issue or create a new one?
I'm quite new to GitHub, so I don't want to mess with the "structures" of it :-)

@Xunius
Copy link
Owner

Xunius commented Sep 11, 2017

I'm no pro user either.
I guess open a new one, to make it easier for other people to search.

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