This repository was archived by the owner on Apr 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmendeley_quick_testing.py
More file actions
155 lines (113 loc) · 4.44 KB
/
mendeley_quick_testing.py
File metadata and controls
155 lines (113 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# -*- coding: utf-8 -*-
"""
Example function calls
"""
import string
import random
import sys
import os
import json
from PyQt5.QtWidgets import *
import requests
from mendeley import client_library
from mendeley import api
from database import db_logging as db
<<<<<<< HEAD
=======
from mendeley import integrity
>>>>>>> a454f3d2717b10f207860099d8466b8333988a38
def random_entry():
d = dict()
d["title"] = ''.join(random.SystemRandom().choice(string.ascii_lowercase) for _ in range(8))
d["type"] = 'journal'
d["identifiers"] = dict()
d["identifiers"]["doi"] = '10.' + str(random.random())[2:12]
d["tags"] = ["cool paper"]
return d
def test_get_pdf(pdf_url):
resp = requests.get(pdf_url)
if 'text/html' in resp.headers['Content-Type']:
with open('test_file.html', 'wb') as file:
file.write(resp.content)
else:
with open('test_pdf.pdf', 'wb') as file:
file.write(resp.content)
def _file_selector():
app = QApplication(sys.argv)
dialog = QFileDialog()
dialog.setFileMode(QFileDialog.DirectoryOnly)
dialog.setViewMode(QFileDialog.List)
dialog.setDirectory(os.path.expanduser('~'))
if dialog.exec_():
filenames = dialog.selectedFiles()
return filenames[0]
else:
return None
def annotation_maker(document_id):
ann = dict()
ann['type'] = 'sticky_note'
ann['color'] = {'g': 0, 'b': 173, 'r': 255}
ann['document_id'] = document_id
ann['privacy_level'] = 'private'
ann['positions'] = [{'page': 1, 'top_left': {'y': 500, 'x': 120}, 'bottom_right': {'y': 500, 'x': 120}}]
ann['text'] = 'test post please ignore'
return ann
sd1 = {'title': 'All fields present', 'type': 'journal', 'authors': [{'first_name': 'Jon', 'last_name': 'Snow'}],
'tags': ['generated'], 'identifiers': {'doi': '10.1111'}, 'keywords': ['Longclaw', 'Nights Watch'],
'pages': '1-10'}
doi = '10.1177/1073858414541484'
doi = '10.1002/bit.25159'
doi_for_file = '10.1002/biot.201400046'
temp = client_library.UserLibrary(verbose=True)
<<<<<<< HEAD
#print([x['title'] for x in temp.raw])
=======
>>>>>>> a454f3d2717b10f207860099d8466b8333988a38
m = api.API()
# analyst = integrity.Analysis(temp)
# analyst.validate_dois()
# temp.update_file_from_local(doi=doi)
import pdb
pdb.set_trace()
# Adding a real entry
'''
ae = dict()
ae["title"] = 'Bioengineering Virus-Like Particles As Vaccines'
ae["type"] = 'journal'
ae["identifiers"] = {"doi" : '10.1002/bit.25159'}
m.documents.create(ae)
ae = dict()
ae["title"] = 'CRISPR/Cas9-mediated genome engineering: An adeno-associated viral (AAV) vector toolbox'
ae["type"] = 'journal'
ae["identifiers"] = {"doi" : '10.1002/biot.201400046'}
m.documents.create(ae)
'''
#actual_doc = temp.get_document('10.1002/biot.201400046')
#doc = temp.get_document('10.1111/j.1464-4096.2004.04875.x')
#print(doc)
#return_bundle = actual_doc.add_all_references()
#print(return_bundle)
#print('total number of references: ' + str(return_bundle['total_refs']))
#print('refs without DOIs: ' + str(return_bundle['without_dois']))
#doc_data = random_entry()
#print(doc_data)
<<<<<<< HEAD
# Testing the annotation retrieval function
doc_doi = '10.1016/S0304-3991(00)00076-0'
#doc = temp.get_document(doi=doc_doi, return_json=True)
#document_id = doc.get('id')
db_doi = '10.1111/j.1748-1716.1980.tb06578.x'
db_doc = db.get_saved_info(db_doi)
m_doc = temp.get_document(db_doi)
#
# New objective - enable exporting and archiving of Mendeley library
#
=======
# db_doi = '10.1111/j.1748-1716.1980.tb06578.x'
# db_doc = db.get_saved_info(db_doi)
# m_doc = temp.get_document(db_doi)
>>>>>>> a454f3d2717b10f207860099d8466b8333988a38
test_file = 'http://onlinelibrary.wiley.com/doi/10.1002/biot.201400828/pdf'
wy_test_file = 'http://onlinelibrary.wiley.com/doi/10.1002/biot.201400046/pdf'
sd_test_file = 'http://ac.els-cdn.com/S0006899313013048/1-s2.0-S0006899313013048-main.pdf?_tid=d0627c6c-22b6-11e6-bf6e-00000aab0f27&acdnat=1464208105_97b45bc2a955e54bd12cadd26e2e053c'
sp_test_file = 'http://download.springer.com/static/pdf/60/art%253A10.1007%252Fs10514-015-9513-5.pdf?originUrl=http%3A%2F%2Flink.springer.com%2Farticle%2F10.1007%2Fs10514-015-9513-5&token2=exp=1464211096~acl=%2Fstatic%2Fpdf%2F60%2Fart%25253A10.1007%25252Fs10514-015-9513-5.pdf%3ForiginUrl%3Dhttp%253A%252F%252Flink.springer.com%252Farticle%252F10.1007%252Fs10514-015-9513-5*~hmac=f82c4baeb735331580f20ab0b694b73a749fcbe905fdaf1a3821c2327a7b12c7'