Generate repeatable, consistent statistics to measure the adoption of Open Access in the University of Guelph research community.
- Clone this repo
- Run
pip install -r requirements.txt - Copy
secrets.template.pytosecrets.py - [Optional] Update
secrets.pywith your secret information (usernames, passwords, etc.) - Run
ugps.py --fetch --apc --localto collect and process data - Run
ugpy.py --report listto list all available reports. - Run
ugps.py --report allto run all reports or specify an individual report by name:ugps.py --report "Author Report"
If you don't populate secrets.py, you'll have to use the command line arguments below to specify them when you run --fetch
usage: ugps.py [-h] [--fetch] [--query QUERY] [--email EMAIL]
[--wosuser WOSUSER] [--wospass WOSPASS] [--in_file IN_FILE]
[--apc] [--local] [--report [REPORT]] [--output OUTPUT] [-v]
[-vv]
Fetch UG OA data and run reports.
optional arguments:
-h, --help show this help message and exit
--fetch Fetch data from data sources.
--query QUERY, -q QUERY Web of Science query
--email EMAIL, -e EMAIL Email used to communicate with the Unpaywall API.
--wosuser WOSUSER Web of Science user ID
--wospass WOSPASS Web of Science password
--in_file IN_FILE, -i IN_FILE Input file (exported from web of science search)
--apc Fetch and estimate APC costs.
--local Identify local authors.
--report [REPORT] Name of report to run.
--output OUTPUT, -o OUTPUT Directory in which to write reports.
-v
-vv
Reports are automatically loaded if the report class has been imported and it inherits from the Report base class.
In simple terms, the easiest way to add your own report is to:
- Add a new python file that contains your class to
report/reports - Make sure your class inherits from
report.reporting.Report - Implement the
runfunction in your class.
I recommend just duplicating, renaming, and modifying BasicReport.py
You can interface with the database in one of two ways:
- Via the Peewee ORM - Models are defined in models.py. See
BasicReport.pyfor an example of this. - Via sqlite3. See
AuthorReport.pyfor an example of this.
The Report base class provides some convenience functions to implement reports. Namely:
get_values(record): Automatically fetch values using the column mapping provided in the class. The mapping can define a callable function to extract the value from a record, an property to access in the record object, or None to create an empty column. See the Report class for more details.get_value(record, key): Fetch a single value from the column mapping, following the logic outlined inget_values().make_file_name(): Using a report's name, produce a sanitized version usable as a file name.