Skip to content

Commit 0d7ba60

Browse files
committed
GitHub Desktop completely botched things. Should be fixed.
1 parent 8ba03d3 commit 0d7ba60

File tree

5 files changed

+65
-148
lines changed

5 files changed

+65
-148
lines changed

src/academic_tracker/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,4 @@
3939
This module contains general functions for interfacing with the internet.
4040
4141
"""
42-
<<<<<<< Updated upstream:academic_tracker/__init__.py
43-
__version__ = "1.0.0"
44-
=======
4542
__version__ = "1.0.4"
46-
>>>>>>> Stashed changes:src/academic_tracker/__init__.py

src/academic_tracker/__main__.py

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""
1+
"""
22
Usage:
33
academic_tracker author_search <config_json_file> [--test --prev_pub=<file-path> --no_GoogleScholar --no_ORCID --no_Crossref --no_PubMed --verbose --silent]
44
academic_tracker reference_search <config_json_file> <references_file_or_URL> [--test --prev_pub=<file-path> --PMID_reference --MEDLINE_reference --no_Crossref --no_PubMed --verbose --silent]
@@ -11,7 +11,7 @@
1111
1212
Options:
1313
-h --help Show this screen.
14-
--version Show version.
14+
-v --version Show version.
1515
--verbose Print hidden error messages.
1616
--silent Do not print anything to the screen.
1717
--test Generate pubs and email texts, but do not send emails.
@@ -29,18 +29,6 @@
2929
"""
3030

3131

32-
## Need help with pycharm UML diagram.
33-
## add defulat pandas excel engine to required packages xlsxwriter I think
34-
35-
## take docs/_build out of gitignore and point GitHub pages there for documentation.
36-
## Add the url of this page to the about section on gitHub.
37-
## When to merge to master?
38-
## When to create github pages?
39-
## Is BSD license okay?
40-
## Putting on pypi? When?
41-
## Does the lab have github actions for sphinx documentation?
42-
43-
4432
import re
4533
import os
4634
import datetime
@@ -140,11 +128,7 @@ def author_search(config_json_filepath, no_ORCID, no_GoogleScholar, no_Crossref,
140128
user_input_checking.prev_pubs_file_check(prev_pubs)
141129

142130
## Query sources and build publication_dict.
143-
<<<<<<< Updated upstream:academic_tracker/__main__.py
144-
publication_dict, prev_pubs = athr_srch_modularized.build_publication_dict(config_dict, prev_pubs, no_ORCID, no_GoogleScholar, no_Crossref)
145-
=======
146131
publication_dict = athr_srch_modularized.build_publication_dict(config_dict, prev_pubs, no_ORCID, no_GoogleScholar, no_Crossref, no_PubMed)
147-
>>>>>>> Stashed changes:src/academic_tracker/__main__.py
148132

149133
save_dir_name = athr_srch_modularized.save_and_send_reports_and_emails(authors_by_project_dict, publication_dict, config_dict, test)
150134

@@ -197,12 +181,8 @@ def PMID_reference(config_json_filepath, ref_path_or_URL, test):
197181
config_dict = fileio.load_json(config_json_filepath)
198182

199183
## Get inputs from config file and check them for errors.
200-
<<<<<<< Updated upstream:academic_tracker/__main__.py
201-
user_input_checking.ref_config_file_check(config_dict, True)
202-
=======
203184
user_input_checking.ref_config_file_check(config_dict, True, False)
204185
user_input_checking.config_report_check(config_dict)
205-
>>>>>>> Stashed changes:src/academic_tracker/__main__.py
206186

207187
## Check the DOI file extension and call the correct read in function.
208188
extension = os.path.splitext(ref_path_or_URL)[1][1:].lower()
@@ -220,10 +200,8 @@ def PMID_reference(config_json_filepath, ref_path_or_URL, test):
220200
helper_functions.vprint("Nothing was read from the PMID file. Make sure the file is not empty or is a supported file type.")
221201
sys.exit()
222202

223-
if type(file_contents) == str:
224-
PMID_list = [line for line in file_contents.split("\n") if line]
225-
else:
226-
PMID_list = file_contents
203+
PMID_list = [line for line in file_contents.split("\n") if line] if type(file_contents) == str else file_contents
204+
227205
user_input_checking.tracker_validate(PMID_list, tracker_schema.PMID_reference_schema)
228206

229207
helper_functions.vprint("Querying PubMed and building the publication list.")
@@ -232,10 +210,9 @@ def PMID_reference(config_json_filepath, ref_path_or_URL, test):
232210
## Build the save directory name.
233211
if test:
234212
save_dir_name = "tracker-test-" + re.sub(r"\-| |\:", "", str(datetime.datetime.now())[2:16])
235-
os.mkdir(save_dir_name)
236213
else:
237214
save_dir_name = "tracker-" + re.sub(r"\-| |\:", "", str(datetime.datetime.now())[2:16])
238-
os.mkdir(save_dir_name)
215+
os.mkdir(save_dir_name)
239216

240217
## combine previous and new publications lists and save
241218
fileio.save_publications_to_file(save_dir_name, publication_dict, {})
@@ -396,6 +373,7 @@ def gen_reports_and_emails_auth(config_json_filepath, publication_json_filepath,
396373

397374
## Get inputs from config file and check them for errors.
398375
user_input_checking.tracker_validate(config_dict, tracker_schema.gen_reports_auth_schema)
376+
user_input_checking.config_report_check(config_dict)
399377

400378
## Create an authors_json for each project in the config_dict and update those authors attributes with the project attributes.
401379
authors_by_project_dict, config_dict = athr_srch_modularized.generate_internal_data_and_check_authors(config_dict)
@@ -429,6 +407,7 @@ def gen_reports_and_emails_ref(config_json_filepath, ref_path_or_URL, publicatio
429407

430408
## Get inputs from config file and check them for errors.
431409
user_input_checking.tracker_validate(config_dict, tracker_schema.gen_reports_ref_schema)
410+
user_input_checking.config_report_check(config_dict)
432411

433412
if not prev_pub_filepath or prev_pub_filepath.lower() == "ignore":
434413
prev_pubs = {}

src/academic_tracker/athr_srch_modularized.py

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import datetime
1111
import os
1212

13+
import deepdiff
14+
1315
from . import user_input_checking
1416
from . import fileio
1517
from . import helper_functions
@@ -35,10 +37,6 @@ def input_reading_and_checking(config_json_filepath, no_ORCID, no_GoogleScholar,
3537
## read in config file
3638
config_dict = fileio.load_json(config_json_filepath)
3739

38-
<<<<<<< Updated upstream:academic_tracker/athr_srch_modularized.py
39-
## Get inputs from config file and check them for errors.
40-
user_input_checking.config_file_check(config_dict, no_ORCID, no_GoogleScholar, no_Crossref)
41-
=======
4240
if not "ORCID_search" in config_dict:
4341
no_ORCID = True
4442

@@ -51,7 +49,6 @@ def input_reading_and_checking(config_json_filepath, no_ORCID, no_GoogleScholar,
5149
## Get inputs from config file and check them for errors.
5250
user_input_checking.config_file_check(config_dict, no_ORCID, no_GoogleScholar, no_Crossref, no_PubMed)
5351
user_input_checking.config_report_check(config_dict)
54-
>>>>>>> Stashed changes:src/academic_tracker/athr_srch_modularized.py
5552

5653
return config_dict
5754

@@ -107,29 +104,23 @@ def build_publication_dict(config_dict, prev_pubs, no_ORCID, no_GoogleScholar, n
107104

108105
## Get publications from PubMed
109106
helper_functions.vprint("Finding author's publications. This could take a while.")
110-
<<<<<<< Updated upstream:academic_tracker/athr_srch_modularized.py
111-
helper_functions.vprint("Searching PubMed.")
112-
PubMed_publication_dict = athr_srch_webio.search_PubMed_for_pubs(prev_pubs, config_dict["Authors"], config_dict["PubMed_search"]["PubMed_email"])
113-
prev_pubs.update(PubMed_publication_dict)
114-
=======
115107
current_pubs = {}
116108
if not no_PubMed:
117109
helper_functions.vprint("Searching PubMed.")
118110
PubMed_publication_dict = athr_srch_webio.search_PubMed_for_pubs(current_pubs, config_dict["Authors"], config_dict["PubMed_search"]["PubMed_email"])
119111
current_pubs.update(PubMed_publication_dict)
120-
>>>>>>> Stashed changes:src/academic_tracker/athr_srch_modularized.py
121112
if not no_ORCID:
122113
helper_functions.vprint("Searching ORCID.")
123-
ORCID_publication_dict = athr_srch_webio.search_ORCID_for_pubs(prev_pubs, config_dict["ORCID_search"]["ORCID_key"], config_dict["ORCID_search"]["ORCID_secret"], config_dict["Authors"])
124-
prev_pubs.update(ORCID_publication_dict)
114+
ORCID_publication_dict = athr_srch_webio.search_ORCID_for_pubs(current_pubs, config_dict["ORCID_search"]["ORCID_key"], config_dict["ORCID_search"]["ORCID_secret"], config_dict["Authors"])
115+
current_pubs.update(ORCID_publication_dict)
125116
if not no_GoogleScholar:
126117
helper_functions.vprint("Searching Google Scholar.")
127-
Google_Scholar_publication_dict = athr_srch_webio.search_Google_Scholar_for_pubs(prev_pubs, config_dict["Authors"], config_dict["Crossref_search"]["mailto_email"])
128-
prev_pubs.update(Google_Scholar_publication_dict)
118+
Google_Scholar_publication_dict = athr_srch_webio.search_Google_Scholar_for_pubs(current_pubs, config_dict["Authors"], config_dict["Crossref_search"]["mailto_email"])
119+
current_pubs.update(Google_Scholar_publication_dict)
129120
if not no_Crossref:
130121
helper_functions.vprint("Searching Crossref.")
131-
Crossref_publication_dict = athr_srch_webio.search_Crossref_for_pubs(prev_pubs, config_dict["Authors"], config_dict["Crossref_search"]["mailto_email"])
132-
prev_pubs.update(Crossref_publication_dict)
122+
Crossref_publication_dict = athr_srch_webio.search_Crossref_for_pubs(current_pubs, config_dict["Authors"], config_dict["Crossref_search"]["mailto_email"])
123+
current_pubs.update(Crossref_publication_dict)
133124

134125
publication_dict = {}
135126
if not no_PubMed:
@@ -148,13 +139,18 @@ def build_publication_dict(config_dict, prev_pubs, no_ORCID, no_GoogleScholar, n
148139
for key, value in Crossref_publication_dict.items():
149140
if not key in publication_dict:
150141
publication_dict[key] = value
142+
143+
## Compare current pubs with previous and only keep those that are new or updated.
144+
for pub_id, pub_values in prev_pubs.items():
145+
if pub_id in publication_dict and not deepdiff.DeepDiff(publication_dict[pub_id], pub_values, ignore_order=True, report_repetition=True):
146+
del publication_dict[pub_id]
151147

152148

153149
if len(publication_dict) == 0:
154150
helper_functions.vprint("No new publications found.")
155151
sys.exit()
156152

157-
return publication_dict, prev_pubs
153+
return publication_dict
158154

159155

160156

@@ -174,10 +170,9 @@ def save_and_send_reports_and_emails(authors_by_project_dict, publication_dict,
174170
## Build the save directory name.
175171
if test:
176172
save_dir_name = "tracker-test-" + re.sub(r"\-| |\:", "", str(datetime.datetime.now())[2:16])
177-
os.mkdir(save_dir_name)
178173
else:
179174
save_dir_name = "tracker-" + re.sub(r"\-| |\:", "", str(datetime.datetime.now())[2:16])
180-
os.mkdir(save_dir_name)
175+
os.mkdir(save_dir_name)
181176

182177

183178
email_messages = athr_srch_emails_and_reports.create_project_reports_and_emails(authors_by_project_dict, publication_dict, config_dict, save_dir_name)
@@ -222,9 +217,3 @@ def save_and_send_reports_and_emails(authors_by_project_dict, publication_dict,
222217
return save_dir_name
223218

224219

225-
226-
227-
228-
229-
230-

src/academic_tracker/ref_srch_modularized.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ def input_reading_and_checking(config_json_filepath, ref_path_or_URL, MEDLINE_re
4040
## read in config file
4141
config_dict = fileio.load_json(config_json_filepath)
4242

43-
<<<<<<< Updated upstream:academic_tracker/ref_srch_modularized.py
44-
## Get inputs from config file and check them for errors.
45-
user_input_checking.ref_config_file_check(config_dict, no_Crossref)
46-
=======
4743
if not "Crossref_search" in config_dict:
4844
no_Crossref = True
4945

@@ -53,7 +49,6 @@ def input_reading_and_checking(config_json_filepath, ref_path_or_URL, MEDLINE_re
5349
## Get inputs from config file and check them for errors.
5450
user_input_checking.ref_config_file_check(config_dict, no_Crossref, no_PubMed)
5551
user_input_checking.config_report_check(config_dict)
56-
>>>>>>> Stashed changes:src/academic_tracker/ref_srch_modularized.py
5752

5853
if not prev_pub_filepath or prev_pub_filepath.lower() == "ignore":
5954
prev_pubs = {}
@@ -150,10 +145,9 @@ def save_and_send_reports_and_emails(config_dict, tokenized_citations, publicati
150145
## Build the save directory name.
151146
if test:
152147
save_dir_name = "tracker-test-" + re.sub(r"\-| |\:", "", str(datetime.datetime.now())[2:16])
153-
os.mkdir(save_dir_name)
154148
else:
155149
save_dir_name = "tracker-" + re.sub(r"\-| |\:", "", str(datetime.datetime.now())[2:16])
156-
os.mkdir(save_dir_name)
150+
os.mkdir(save_dir_name)
157151

158152

159153
if "summary_report" in config_dict:
@@ -195,5 +189,3 @@ def save_and_send_reports_and_emails(config_dict, tokenized_citations, publicati
195189

196190

197191

198-
199-

0 commit comments

Comments
 (0)