{"id":16971707,"url":"https://github.com/juancarlospaco/parselicense","last_synced_at":"2025-03-21T20:16:41.357Z","repository":{"id":151515605,"uuid":"254068204","full_name":"juancarlospaco/parselicense","owner":"juancarlospaco","description":"Parse Standard SPDX Licenses from string to Enum","archived":false,"fork":false,"pushed_at":"2020-04-08T21:03:47.000Z","size":86,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-26T14:48:40.536Z","etag":null,"topics":["license-checking","license-management","nim","nim-lang","spdx","spdx-license","spdx-licenses"],"latest_commit_sha":null,"homepage":"https://juancarlospaco.github.io/parselicense","language":"Nim","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juancarlospaco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-08T11:26:20.000Z","updated_at":"2021-12-09T16:26:19.000Z","dependencies_parsed_at":"2023-05-31T10:46:15.973Z","dependency_job_id":null,"html_url":"https://github.com/juancarlospaco/parselicense","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juancarlospaco%2Fparselicense","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juancarlospaco%2Fparselicense/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juancarlospaco%2Fparselicense/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juancarlospaco%2Fparselicense/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juancarlospaco","download_url":"https://codeload.github.com/juancarlospaco/parselicense/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244860611,"owners_count":20522466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["license-checking","license-management","nim","nim-lang","spdx","spdx-license","spdx-licenses"],"created_at":"2024-10-14T00:54:02.088Z","updated_at":"2025-03-21T20:16:41.348Z","avatar_url":"https://github.com/juancarlospaco.png","language":"Nim","funding_links":[],"categories":[],"sub_categories":[],"readme":"# parseLicense\n\n- Parse Standard SPDX Licenses from string to Enum. `parseLicense(s: string): License`.\n- [Tests. Documentation. Examples.](https://juancarlospaco.github.io/parselicense) Works at compile-time. Fast algo. `$` Dollar for human-friendly Standard name.\n\n\n# Use\n\n```nim\n  static:\n    const wtfplTxt = \"\"\"DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE\n\nVersion 2, December 2004\n\nCopyright (C) 2004 Sam Hocevar \u003csam@hocevar.net\u003e\n\nEveryone is permitted to copy and distribute verbatim or modified copies of\nthis license document, and changing it is allowed as long as the name is changed.\n\nDO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE\n\nTERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n   0. You just DO WHAT THE FUCK YOU WANT TO.\n\"\"\"\n    doAssert parseLicense(wtfplTxt, default = Licenses.Mit) == Licenses.WTFPL\n    doAssert parseLicense(wtfplTxt).get() == Licenses.WTFPL\n\n\n    const zeroBsdTxt = \"\"\"Copyright (C) 2006 by Rob Landley \u003crob@landley.net\u003e\n\nPermission to use, copy, modify, and/or distribute this software for any purpose\nwith or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE\nOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n\"\"\"\n    doAssert parseLicense(zeroBsdTxt, default = Licenses.Mit) == Licenses.ZeroBSD\n    doAssert parseLicense(zeroBsdTxt).get() == Licenses.ZeroBSD\n\n\n    const fairTxt = \"\"\"Fair License \u003cCopyright Information\u003e\n\nUsage of the works is permitted provided that this instrument is retained\nwith the works, so that any entity that uses the works is notified of this\ninstrument.\n\nDISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.\n\"\"\"\n    doAssert parseLicense(fairTxt, default = Licenses.Mit) == Licenses.Fair\n    doAssert parseLicense(fairTxt).get() == Licenses.Fair\n\n    const beerwareTxt = \"\"\"\"THE BEER-WARE LICENSE\" (Revision 42):\n\n\u003cphk@FreeBSD.ORG\u003e wrote this file. As long as you retain this notice you can\ndo whatever you want with this stuff. If we meet some day, and you think this\nstuff is worth it, you can buy me a beer in return Poul-Henning Kamp\n\"\"\"\n    doAssert parseLicense(beerwareTxt, default = Licenses.Mit) == Licenses.Beerware\n    doAssert parseLicense(beerwareTxt,).get() == Licenses.Beerware\n\n\n    const curlTxt = \"\"\"COPYRIGHT AND PERMISSION NOTICE Copyright (c) 1996 - 2015, Daniel Stenberg,\n\u003cdaniel@haxx.se\u003e.\n\nAll rights reserved.\n\nPermission to use, copy, modify, and distribute this software for any purpose\nwith or without fee is hereby granted, provided that the above copyright notice\nand this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO\nEVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES\nOR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\nIN THE SOFTWARE.\n\nExcept as contained in this notice, the name of a copyright holder shall not\nbe used in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization of the copyright holder.\n\"\"\"\n    doAssert parseLicense(curlTxt, default = Licenses.Mit) == Licenses.Curl\n    doAssert parseLicense(curlTxt,).get() == Licenses.Curl\n\n\n  ## Works with lowercased and uppercased Licenses.\n  const iscTxt = toLowerAscii(\"\"\"ISC License Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. (\"ISC\")\n\nCopyright (c) 1995-2003 by Internet Software Consortium\n\nPermission to use, copy, modify, and /or distribute this software for any\npurpose with or without fee is hereby granted, provided that the above copyright\nnotice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD\nTO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL\nDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING\nOUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\"\"\")\n  doAssert parseLicense(iscTxt, default = Licenses.Mit) == Licenses.Isc\n  doAssert parseLicense(iscTxt,).get() == Licenses.Isc\n\n\n  ## Works with invalid Data (Not a License).\n  doAssert parseLicense(\"Invalid data\", default = Licenses.Mit) == Licenses.Mit\n  doAssert parseLicense(\"Invalid data\").isNone()\n\n```\n\n\n# JavaScript\n\n- [For a version that works on the browser see the javascript folder.](https://github.com/juancarlospaco/parselicense/tree/master/javascript)\n\n\n# Note\n\nI am looking for a better algo that is small code and more efficient and precise,\nI search and only found modules on other languages that compare whole strings,\nor compare string lenghts, or compare filenames, or huge `try...except` chains of that.\nMy algo is what antivirus do basically, it wont need all license files shipped to compare to,\nif you have a better algo that is faster smaller code and works at compile-time,\njust send a pull request, and it will be merged.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuancarlospaco%2Fparselicense","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuancarlospaco%2Fparselicense","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuancarlospaco%2Fparselicense/lists"}