{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Compliance checker" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Project root: /Users/dasha/code/jcdl_2019\n" ] } ], "source": [ "# standard path wrangling to be able to import project config and sources\n", "import os\n", "import sys\n", "root = os.path.dirname(os.getcwd())\n", "sys.path.append(root)\n", "print('Project root: {}'.format(root))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Imports:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Built-in\n", "import json\n", "from datetime import datetime\n", "\n", "# Custom\n", "from src.utils.config_loader import ConfigLoader\n", "from src.compliance.compliance_checker import ComplianceChecker" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load config:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "cfg = ConfigLoader.load_config()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Test the class:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\n", " \"10.1002/14651858.CD012515\": {\n", " \"published\": \"2017-01-24\",\n", " \"deposited\": \"2017-09-12\",\n", " \"status\": \"Not compliant\"\n", " },\n", " \"10.1007/s11192-018-2669-y\": {\n", " \"published\": \"2018-02-10\",\n", " \"deposited\": \"2018-02-14\",\n", " \"status\": \"Likely compliant\"\n", " },\n", " \"10.1145/3057148.3057154\": {\n", " \"published\": \"2017\",\n", " \"deposited\": null,\n", " \"status\": \"Missing data\"\n", " },\n", " \"98765\": {\n", " \"published\": null,\n", " \"deposited\": null,\n", " \"status\": \"Invalid DOI\"\n", " }\n", "}\n" ] } ], "source": [ "dois = [\n", " '10.1002/14651858.CD012515', # not compliant\n", " '10.1007/s11192-018-2669-y', # compliant\n", " '10.1145/3057148.3057154', # in CrossRef but not in CORE\n", " 98765 # not a DOI\n", "]\n", "\n", "cc = ComplianceChecker(cfg['core']['api_key'], cfg['core']['max_query_size'])\n", "\n", "print(json.dumps(cc.compliance_status(dois), indent=4))" ] } ], "metadata": { "kernelspec": { "display_name": "ref_compliance", "language": "python", "name": "ref_compliance" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.2" } }, "nbformat": 4, "nbformat_minor": 2 }