Skip to content

Commit

Permalink
Created using Colab
Browse files Browse the repository at this point in the history
  • Loading branch information
pulipulichen committed Jan 6, 2025
1 parent f4d36ed commit 34677d3
Showing 1 changed file with 158 additions and 0 deletions.
158 changes: 158 additions & 0 deletions CITATION.cff Validator.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyPHq81zBywvUygOsPNHtCfx",
"include_colab_link": true
},
"kernelspec": {
"name": "ir",
"display_name": "R"
},
"language_info": {
"name": "R"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/pulipulichen/Colab-CITATION.cff-Validator/blob/main/CITATION.cff%20Validator.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"source": [
"install.packages(\"cffr\")\n",
"library(cffr)"
],
"metadata": {
"id": "o12lPQDjPIjB",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "43e22d1a-d2e5-4e55-9c0a-ccd74ccfe9e5"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"Installing package into ‘/usr/local/lib/R/site-library’\n",
"(as ‘lib’ is unspecified)\n",
"\n",
"also installing the dependencies ‘V8’, ‘jsonvalidate’\n",
"\n",
"\n"
]
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "uhg5GzNkNfZ3",
"outputId": "05b8c549-36be-4fbc-e280-1cd7efd4dba3"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Validating: /content//CITATION_complete.cff \n",
"\u001b[36m══\u001b[39m \u001b[36mValidating cff\u001b[39m \u001b[36m══════════════════════════════════════════════════════════════\u001b[39m\n"
]
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"\u001b[32m✔\u001b[39m Congratulations! \u001b[34m\u001b[34m/content//CITATION_complete.cff\u001b[34m\u001b[39m is valid\n",
"\n"
]
},
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content//CITATION_complete.cff is valid.\n",
"Validating: /content//CITATION_error.cff \n",
"\u001b[36m══\u001b[39m \u001b[36mValidating cff\u001b[39m \u001b[36m══════════════════════════════════════════════════════════════\u001b[39m\n"
]
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"\u001b[31m✖\u001b[39m Oops! \u001b[34m\u001b[34m/content//CITATION_error.cff\u001b[34m\u001b[39m has the following errors:\n",
"* \u001b[1m\u001b[1mcff\u001b[1m\u001b[22m: has additional properties\n",
"* \u001b[1m\u001b[1mcff.authors.0\u001b[1m\u001b[22m: no schemas match\n",
"* \u001b[1m\u001b[1mcff.doi\u001b[1m\u001b[22m: referenced schema does not match\n",
"* \u001b[1m\u001b[1mcff.keywords.0\u001b[1m\u001b[22m: is the wrong type\n",
"* \u001b[1m\u001b[1mcff.license\u001b[1m\u001b[22m: referenced schema does not match\n",
"* \u001b[1m\u001b[1mcff.url\u001b[1m\u001b[22m: referenced schema does not match\n",
"\n"
]
},
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content//CITATION_error.cff is invalid.\n",
"Validating: /content//CITATION.cff \n",
"\u001b[36m══\u001b[39m \u001b[36mValidating cff\u001b[39m \u001b[36m══════════════════════════════════════════════════════════════\u001b[39m\n"
]
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"\u001b[31m✖\u001b[39m Oops! \u001b[34m\u001b[34m/content//CITATION.cff\u001b[34m\u001b[39m has the following errors:\n",
"* \u001b[1m\u001b[1mcff\u001b[1m\u001b[22m: has additional properties\n",
"\n"
]
},
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content//CITATION.cff is invalid.\n"
]
}
],
"source": [
"# Specify the folder containing the .cff files\n",
"cff_folder <- \"/content/\"\n",
"\n",
"# List all .cff files in the folder\n",
"cff_files <- list.files(cff_folder, pattern = \"\\\\.cff$\", full.names = TRUE)\n",
"\n",
"# Loop through each .cff file and validate\n",
"for (cff_file in cff_files) {\n",
" cat(\"Validating:\", cff_file, \"\\n\")\n",
"\n",
" # Validate the .cff file\n",
" validation_result <- cff_validate(cff_file)\n",
"\n",
" # Check the validation result\n",
" if (validation_result) {\n",
" cat(cff_file, \"is valid.\\n\")\n",
" } else {\n",
" cat(cff_file, \"is invalid.\\n\")\n",
" }\n",
"}"
]
}
]
}

0 comments on commit 34677d3

Please sign in to comment.