Skip to content

Commit 4776d06

Browse files
committed
Aliased underscore options with dashes.
1 parent eed916e commit 4776d06

File tree

7 files changed

+445
-58
lines changed

7 files changed

+445
-58
lines changed

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,31 +70,31 @@ Install on Linux, Mac OS X
7070

7171
.. code:: bash
7272
73-
python3 -m pip install academic_tracker
73+
python3 -m pip install academic-tracker
7474
7575
7676
Install on Windows
7777
------------------
7878

7979
.. code:: bash
8080
81-
py -3 -m pip install academic_tracker
81+
py -3 -m pip install academic-tracker
8282
8383
8484
Upgrade on Linux, Mac OS X
8585
--------------------------
8686

8787
.. code:: bash
8888
89-
python3 -m pip install academic_tracker --upgrade
89+
python3 -m pip install academic-tracker --upgrade
9090
9191
9292
Upgrade on Windows
9393
------------------
9494

9595
.. code:: bash
9696
97-
py -3 -m pip install academic_tracker --upgrade
97+
py -3 -m pip install academic-tracker --upgrade
9898
9999
100100

docs/tutorial.rst

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Details about the configuration JSON file can be found in the :doc:`jsonschema`
99
section, but in general the sections of the configuration JSON file that aren't
1010
needed for a particular command are not required. For instance, the ORCID_search
1111
section is not required for reference_search since it does not search ORCID. The
12-
same is true if the --no_ORCID option is used.
12+
same is true if the --no-ORCID option is used.
1313

1414
Outputs
1515
~~~~~~~
@@ -27,7 +27,7 @@ Command Line Signature
2727
----------------------
2828
.. code-block:: console
2929
30-
academic_tracker author_search <config_json_file> [--test --prev_pub=<file-path> --no_GoogleScholar --no_ORCID --no_Crossref --no_PubMed --verbose --silent]
30+
academic_tracker author_search <config_json_file> [--test --prev-pub=<file-path> --no-GoogleScholar --no-ORCID --no-Crossref --no-PubMed --verbose --silent]
3131
3232
3333
Description
@@ -38,11 +38,11 @@ on. The cutoff_year attribute for either the projects or the authors can be used
3838
to filter the publications to only those in that year or after.
3939

4040
Similarly, a previous publications JSON file can be used to filter out publications
41-
that are already in the file. This file can be specified manually with the --prev_pub
41+
that are already in the file. This file can be specified manually with the --prev-pub
4242
option. If not specified manually author_search will automatically look for a
4343
publications.json file in the most recent tracker directories and if it finds
4444
one it will be used as the previous publications. To stop this automatic lookup
45-
enter "ignore" for the --prev_pub option. The output publications.json file will
45+
enter "ignore" for the --prev-pub option. The output publications.json file will
4646
be a combination of the previous publications and any new publications found. To
4747
be clear the new publications.json file will be the previous publications.json
4848
file with any new entries added in.
@@ -72,25 +72,25 @@ Options
7272
The test option changes the name of the output directory from tracker-YYMMDDHHMM
7373
to tracker-test-YYMMDDHHMM and prevents any emails from being sent.
7474

75-
--prev_pub:
75+
--prev-pub:
7676

7777
Specifies a publications.json file to use as a list of publications to ignore
7878
when searching for new publications. Set to "ignore" to prevent author_search
7979
from automatically looking for a publications.json file in tracker directories.
8080

81-
--no_GoogleScholar:
81+
--no-GoogleScholar:
8282

8383
If used author_search will not search Google Scholar for publications.
8484

85-
--no_ORCID:
85+
--no-ORCID:
8686

8787
If used author_search will not search ORCID for publications.
8888

89-
--no_Crossref:
89+
--no-Crossref:
9090

9191
If used author_search will not search Crossref for publications.
9292

93-
--no_PubMed:
93+
--no-PubMed:
9494

9595
If used author_search will not search PubMed for publications. This option is
9696
assumed if the PubMed_search section of the configuration JSON file is missing.
@@ -282,7 +282,7 @@ Designating a previous publications filepath instead of letting Academic Tracker
282282

283283
.. code-block:: console
284284
285-
>academic_tracker author_search config_file.json --prev_pub prev_pub_file_path.json
285+
>academic_tracker author_search config_file.json --prev-pub prev_pub_file_path.json
286286
Finding author's publications. This could take a while.
287287
Searching PubMed.
288288
Searching ORCID.
@@ -345,7 +345,7 @@ Console:
345345

346346
.. code-block:: console
347347
348-
>academic_tracker author_search config_file.json --no_ORCID
348+
>academic_tracker author_search config_file.json --no-ORCID
349349
Finding author's publications. This could take a while.
350350
Searching PubMed.
351351
Searching Google Scholar.
@@ -361,7 +361,7 @@ Command Line Signature
361361
----------------------
362362
.. code-block:: console
363363
364-
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]
364+
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]
365365
366366
367367
Description
@@ -380,21 +380,21 @@ is expected to be the first page of a bibliography and will be tokenized in a
380380
specific way. All other URLs are simply read as a text file and tokenized like
381381
one.
382382

383-
The --PMID_reference and --MEDLINE_reference options change how the reference file
384-
is interpreted. If the --PMID_reference option is used then it indicates that the
383+
The --PMID-reference and --MEDLINE-reference options change how the reference file
384+
is interpreted. If the --PMID-reference option is used then it indicates that the
385385
given reference file is a list of PMIDs (PubMed's unique IDs). Instead of tokenizing
386386
this file it is assumed that each line is a PMID so PubMed will be queried for
387387
each PMID and Crossref will not be queried. The idea for this option was to be
388388
able to quickly grab information from PubMed.
389389

390-
The --MEDLINE_reference option indicates that given reference file is a MEDLINE_
390+
The --MEDLINE-reference option indicates that given reference file is a MEDLINE_
391391
formatted file. This will be tokenized in a unique way since the publication
392392
information is spread out over multiple lines in this format. This format is
393393
supported because it is a dounload option on MyNCBI bibliography pages.
394394

395395
Details about tokenization are in the :doc:`tokenization` section.
396396

397-
The --prev_pub option is different for reference_search than it is for author_search.
397+
The --prev-pub option is different for reference_search than it is for author_search.
398398
First, reference_search does not automatically look for a publicaitons.json file
399399
to use since the same assumptions as described for author_search do not hold here.
400400
Second, publications in the prev_pub file are not used to ignore publications.
@@ -410,25 +410,25 @@ Options
410410
The test option changes the name of the output directory from tracker-YYMMDDHHMM
411411
to tracker-test-YYMMDDHHMM and prevents any emails from being sent.
412412

413-
--prev_pub:
413+
--prev-pub:
414414

415415
Specifies a publications.json file to use as a list of publications to compare
416416
with when generating the summary report.
417417

418-
--PMID_reference:
418+
--PMID-reference:
419419

420420
Specifies that the reference file is a list of PMIDs and to only return
421421
information from PubMed.
422422

423-
--MEDLINE_reference:
423+
--MEDLINE-reference:
424424

425425
Specifies that the reference file is a MEDLINE_ formatted file.
426426

427-
--no_Crossref:
427+
--no-Crossref:
428428

429429
If used reference_search will not search Crossref for publications.
430430

431-
--no_PubMed:
431+
--no-PubMed:
432432

433433
If used reference_search will not search Crossref for publications. This option
434434
is assumed if the PubMed_search section of the configuration JSON file is missing.
@@ -456,7 +456,7 @@ the summary_report section of the configuration JSON file.
456456
A summary_report.txt file is only created if the summary_report attribute is in
457457
the configuration JSON file.
458458

459-
If --PMID_reference is used no reports or emails are generated.
459+
If --PMID-reference is used no reports or emails are generated.
460460

461461
Details about reports can be found in the :doc:`reporting` section.
462462

@@ -514,7 +514,7 @@ Designating a previous publications filepath.
514514

515515
.. code-block:: console
516516
517-
>academic_tracker reference_search config_file.json reference_file.txt --prev_pub prev_pub_file_path.json
517+
>academic_tracker reference_search config_file.json reference_file.txt --prev-pub prev_pub_file_path.json
518518
Finding publications. This could take a while.
519519
Searching PubMed.
520520
Searching Crossref.
@@ -542,7 +542,7 @@ Console:
542542

543543
.. code-block:: console
544544
545-
>academic_tracker reference_search config_file.json reference_file.txt --no_Crossref
545+
>academic_tracker reference_search config_file.json reference_file.txt --no-Crossref
546546
Finding publications. This could take a while.
547547
Searching PubMed.
548548
Success. Publications and reports saved in tracker-2202020140
@@ -817,7 +817,7 @@ Command Line Signature
817817
----------------------
818818
.. code-block:: console
819819
820-
academic_tracker tokenize_reference <references_file_or_URL> [--MEDLINE_reference --verbose --silent]
820+
academic_tracker tokenize_reference <references_file_or_URL> [--MEDLINE-reference --verbose --silent]
821821
822822
823823
Description
@@ -827,7 +827,7 @@ Tokenize the input reference and output a tokenization report and JSON file.
827827

828828
Options
829829
-------
830-
--MEDLINE_reference:
830+
--MEDLINE-reference:
831831

832832
Specifies that the reference file is a MEDLINE_ formatted file.
833833

@@ -993,7 +993,7 @@ Command Line Signature
993993
----------------------
994994
.. code-block:: console
995995
996-
academic_tracker gen_reports_and_emails_ref <config_json_file> <references_file_or_URL> <publication_json_file> [--test --prev_pub=<file-path> --MEDLINE_reference --verbose --silent]
996+
academic_tracker gen_reports_and_emails_ref <config_json_file> <references_file_or_URL> <publication_json_file> [--test --prev-pub=<file-path> --MEDLINE-reference --verbose --silent]
997997
998998
999999
Description
@@ -1030,12 +1030,12 @@ Options
10301030
The test option changes the name of the output directory from tracker-YYMMDDHHMM
10311031
to tracker-test-YYMMDDHHMM and prevents any emails from being sent.
10321032

1033-
--prev_pub:
1033+
--prev-pub:
10341034

10351035
Specifies a publications.json file to use as a list of publications to compare
10361036
with when generating the summary report.
10371037

1038-
--MEDLINE_reference:
1038+
--MEDLINE-reference:
10391039

10401040
Specifies that the reference file is a MEDLINE_ formatted file.
10411041

src/academic_tracker/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@
3939
This module contains general functions for interfacing with the internet.
4040
4141
"""
42-
__version__ = "1.0.4"
42+
__version__ = "1.0.6"

src/academic_tracker/__main__.py

Lines changed: 66 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,55 @@
11
"""
22
Usage:
3-
academic_tracker author_search <config_json_file> [--test --prev_pub=<file-path> --no_GoogleScholar --no_ORCID --no_Crossref --no_PubMed --verbose --silent]
4-
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]
3+
academic_tracker author_search <config_json_file> [--test]
4+
[--prev_pub=<file-path> --prev-pub=<file-path>]
5+
[--no-GoogleScholar --no_GoogleScholar]
6+
[--no-ORCID --no_ORCID]
7+
[--no-Crossref --no_Crossref]
8+
[--no-PubMed --no_PubMed]
9+
[--verbose --silent]
10+
academic_tracker reference_search <config_json_file> <references_file_or_URL> [--test]
11+
[--prev-pub=<file-path> --prev_pub=<file-path>]
12+
[--PMID-reference --PMID_reference]
13+
[--MEDLINE-reference --MEDLINE_reference]
14+
[--no-Crossref --no_Crossref]
15+
[--no-PubMed --no_PubMed]
16+
[--verbose --silent]
517
academic_tracker find_ORCID <config_json_file> [--verbose --silent]
618
academic_tracker find_Google_Scholar <config_json_file> [--verbose --silent]
719
academic_tracker add_authors <config_json_file> <authors_file> [--verbose --silent]
8-
academic_tracker tokenize_reference <references_file_or_URL> [--MEDLINE_reference --verbose --silent]
20+
academic_tracker tokenize_reference <references_file_or_URL> [--MEDLINE-reference --MEDLINE_reference]
21+
[--verbose --silent]
922
academic_tracker gen_reports_and_emails_auth <config_json_file> <publication_json_file> [--test --verbose --silent]
10-
academic_tracker gen_reports_and_emails_ref <config_json_file> <references_file_or_URL> <publication_json_file> [--test --prev_pub=<file-path> --MEDLINE_reference --verbose --silent]
23+
academic_tracker gen_reports_and_emails_ref <config_json_file> <references_file_or_URL> <publication_json_file> [--test]
24+
[--prev-pub=<file-path> --prev_pub=<file-path>]
25+
[--MEDLINE-reference --MEDLINE_reference]
26+
[--verbose --silent]
1127
1228
Options:
1329
-h --help Show this screen.
1430
-v --version Show version.
1531
--verbose Print hidden error messages.
1632
--silent Do not print anything to the screen.
1733
--test Generate pubs and email texts, but do not send emails.
18-
--prev_pub=<file-path> Filepath to json or csv with publication ids to ignore. Enter "ignore" for the <file_path> to not look for previous publications.json files in tracker directories.
34+
--prev-pub=<file-path> Filepath to json or csv with publication ids to ignore.
35+
Enter "ignore" for the <file_path> to not look for previous publications.json files in tracker directories.
36+
--prev_pub=<file-path> Deprecated. Use --prev-pub instead.
1937
2038
Reference Type Options:
21-
--PMID_reference Indicates that the reference_file is a PMID file and only PubMed info will be returned.
22-
--MEDLINE_reference Indicates that the reference_file is a MEDLINE file.
39+
--PMID-reference Indicates that the reference_file is a PMID file and only PubMed info will be returned.
40+
--PMID_reference Deprecated. Use --PMID-reference instead.
41+
--MEDLINE-reference Indicates that the reference_file is a MEDLINE file.
42+
--MEDLINE_reference Deprecated. Use --MEDLINE-reference instead.
2343
2444
Search Options:
25-
--no_GoogleScholar Don't search Google Scholar.
26-
--no_ORCID Don't search ORCID.
27-
--no_Crossref Don't search Crossref.
28-
--no_PubMed Don't search PubMed.
45+
--no-GoogleScholar Don't search Google Scholar.
46+
--no_GoogleScholar Deprecated. Use --no-GoogleScholar instead.
47+
--no-ORCID Don't search ORCID.
48+
--no_ORCID Deprecated. Use --no-ORCID instead.
49+
--no-Crossref Don't search Crossref.
50+
--no_Crossref Deprecated. Use --no-Crossref instead.
51+
--no-PubMed Don't search PubMed.
52+
--no_PubMed Deprecated. Use --no-PubMed instead.
2953
"""
3054

3155

@@ -57,6 +81,14 @@
5781

5882
def main():
5983

84+
## Have to modify the doc string so docopt can recognize more options than what is written.
85+
# options_to_alias = ["--no-PubMed", "--no-ORCID", "--no-Crossref", "--no-GoogleScholar", "--PMID-reference", "--MEDLINE-reference", "--prev-pub"]
86+
# for option in options_to_alias:
87+
# alias = f"--{option[2:].replace('-', '_')}"
88+
# doc = __doc__.replace("option", f"{option} {alias}")
89+
90+
# args = docopt.docopt(doc, version=str("Academic Tracker ") + __version__)
91+
6092
args = docopt.docopt(__doc__, version=str("Academic Tracker ") + __version__)
6193

6294
user_input_checking.cli_inputs_check(args)
@@ -67,32 +99,42 @@ def main():
6799
SILENT = args["--silent"]
68100

69101
if len(sys.argv) > 1 and sys.argv[1] == "author_search":
70-
author_search(args["<config_json_file>"], args["--no_ORCID"],
71-
args["--no_GoogleScholar"], args["--no_Crossref"],
72-
args["--no_PubMed"],
73-
args["--test"], args["--prev_pub"])
102+
author_search(args["<config_json_file>"],
103+
args["--no_ORCID"] or args["--no-ORCID"],
104+
args["--no_GoogleScholar"] or args["--no-GoogleScholar"],
105+
args["--no_Crossref"] or args["--no-Crossref"],
106+
args["--no_PubMed"] or args["--no-PubMed"],
107+
args["--test"],
108+
args["--prev-pub"] if args["--prev-pub"] else args["--prev_pub"])
74109
elif len(sys.argv) > 1 and sys.argv[1] == "reference_search":
75-
if args["--PMID_reference"]:
110+
if args["--PMID_reference"] or args["--PMID-reference"]:
76111
PMID_reference(args["<config_json_file>"], args["<references_file_or_URL>"], args["--test"])
77112
else:
78-
reference_search(args["<config_json_file>"], args["<references_file_or_URL>"],
79-
args["--MEDLINE_reference"], args["--no_Crossref"],
80-
args["--no_PubMed"],
81-
args["--test"], args["--prev_pub"])
113+
reference_search(args["<config_json_file>"],
114+
args["<references_file_or_URL>"],
115+
args["--MEDLINE_reference"] or args["--MEDLINE-reference"],
116+
args["--no_Crossref"] or args["--no-Crossref"],
117+
args["--no_PubMed"] or args["--no-PubMed"],
118+
args["--test"],
119+
args["--prev-pub"] if args["--prev-pub"] else args["--prev_pub"])
82120
elif len(sys.argv) > 1 and sys.argv[1] == "find_ORCID":
83121
find_ORCID(args["<config_json_file>"])
84122
elif len(sys.argv) > 1 and sys.argv[1] == "find_Google_Scholar":
85123
find_Google_Scholar(args["<config_json_file>"])
86124
elif len(sys.argv) > 1 and sys.argv[1] == "add_authors":
87125
add_authors(args["<config_json_file>"], args["<authors_file>"])
88126
elif len(sys.argv) > 1 and sys.argv[1] == "tokenize_reference":
89-
tokenize_reference(args["<references_file_or_URL>"], args["--MEDLINE_reference"])
127+
tokenize_reference(args["<references_file_or_URL>"],
128+
args["--MEDLINE_reference"] or args["--MEDLINE-reference"])
90129
elif len(sys.argv) > 1 and sys.argv[1] == "gen_reports_and_emails_auth":
91130
gen_reports_and_emails_auth(args["<config_json_file>"], args["<publication_json_file>"], args["--test"])
92131
elif len(sys.argv) > 1 and sys.argv[1] == "gen_reports_and_emails_ref":
93-
gen_reports_and_emails_ref(args["<config_json_file>"], args["<references_file_or_URL>"],
94-
args["<publication_json_file>"], args["--MEDLINE_reference"],
95-
args["--test"], args["--prev_pub"])
132+
gen_reports_and_emails_ref(args["<config_json_file>"],
133+
args["<references_file_or_URL>"],
134+
args["<publication_json_file>"],
135+
args["--MEDLINE_reference"] or args["--MEDLINE-reference"],
136+
args["--test"],
137+
args["--prev-pub"] if args["--prev-pub"] else args["--prev_pub"])
96138
else:
97139
print("Unrecognized command")
98140

0 commit comments

Comments
 (0)