Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a3dcde9
Add JSON documents creating capability.
xavierfigueroav Mar 20, 2019
d4bfe2f
Add YAML documents creating capability.
xavierfigueroav Mar 27, 2019
b53e5c7
Add examples that convert from RDF and tag/value formats to JSON and …
xavierfigueroav Mar 27, 2019
86bc02f
Add JSON/YAML documents building and parsing capabilities.
xavierfigueroav Apr 1, 2019
255cfe0
Add JSON/YAML builders and parsers documentation.
xavierfigueroav Apr 5, 2019
a295cf9
Add JSON/YAML parsing usage examples.
xavierfigueroav Apr 5, 2019
ac6ed5d
Replace ruamel.yaml by PyYAML as a dependency for handling YAML format.
xavierfigueroav Apr 9, 2019
096dacf
Add tests for JSON and YAML capabilities.
xavierfigueroav Apr 12, 2019
135548e
Update examples to Python 3 syntax.
xavierfigueroav Apr 16, 2019
8bab698
Use ExtractedLicense objects in other types of licenses which contain…
xavierfigueroav May 15, 2019
bd94ced
Change write test files to support new license formats:
xavierfigueroav Jun 13, 2019
88c537e
Add support for parsing and creating Snippet information.
xavierfigueroav Jun 13, 2019
b70ada3
Add XML documents parsing and creating capabilities.
xavierfigueroav Jun 21, 2019
0d062c1
Add tests for XML parsers and writers.
xavierfigueroav Jun 21, 2019
826ce79
Add XML capabilities usage examples.
xavierfigueroav Jun 21, 2019
a621030
Add support for parsing and writing package identifier to JSON/YAML/X…
xavierfigueroav Aug 22, 2019
a330b05
Improve JSON, YAML and XML capabilities documentation.
xavierfigueroav Aug 23, 2019
2840266
Update README.md to include JSON/YAML/XML capabilities.
xavierfigueroav Aug 23, 2019
19dbedc
Use context manager to open/close files safely
pombredanne Aug 23, 2019
79217e3
Do not use builtin "file" as a variable name
pombredanne Aug 23, 2019
968c62e
Cleanup code
pombredanne Aug 23, 2019
a1c67b3
Add maxDiff None to all tests and format code
pombredanne Aug 28, 2019
cee204f
Format source code
pombredanne Aug 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ Pypi: https://pypi.python.org/pypi/spdx-tools
# Features

* API to create and manipulate SPDX documents.
* Parse and create Tag/Value format SPDX files
* Parse and create RDF format SPDX files
* Parse and create Tag/Value, RDF, JSON, YAML, XML format SPDX files


# TODOs
Expand All @@ -54,7 +53,7 @@ Example tag/value parsing usage:

```

The `examples` directory contains several code samples:
The `examples` directory contains several code samples. Here some of them:

* `parse_tv.py` is an example tag/value parsing usage.
Try running `python parse_tv.py ../data/SPDXSimpleTag.tag `
Expand Down Expand Up @@ -119,7 +118,9 @@ If there is no issue for the changes that you want to make, create first an issu
# Dependencies

* PLY : https://pypi.python.org/pypi/ply/ used for parsing.
* rdflib : https://pypi.python.org/pypi/rdflib/ for for handling RDF.
* rdflib : https://pypi.python.org/pypi/rdflib/ for handling RDF.
* PyYAML: https://pypi.org/project/PyYAML/ for handling YAML.
* xmltodict: https://pypi.org/project/xmltodict/ for handling XML.


# Support
Expand Down
185 changes: 185 additions & 0 deletions data/SPDXJsonExample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
{
"Document": {
"comment": "This is a sample spreadsheet",
"name": "Sample_Document-V2.1",
"documentDescribes": [
{
"Package": {
"id": "SPDXRef-Package",
"originator": "Organization: SPDX",
"files": [
{
"File": {
"comment": "This file belongs to Jena",
"licenseInfoFromFiles": [
"LicenseRef-1"
],
"sha1": "3ab4e1c67a2d28fced849ee1bb76e7391b93f125",
"name": "Jenna-2.6.3/jena-2.6.3-sources.jar",
"copyrightText": "(c) Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, LP",
"artifactOf" : [
{
"name" : "Jena",
"homePage" : "http://www.openjena.org/",
"projectUri" : "http://subversion.apache.org/doap.rdf"
}
],
"licenseConcluded": "LicenseRef-1",
"licenseComments": "This license is used by Jena",
"checksums": [
{
"value": "3ab4e1c67a2d28fced849ee1bb76e7391b93f125",
"algorithm": "checksumAlgorithm_sha1"
}
],
"fileTypes": [
"fileType_archive"
],
"id": "SPDXRef-File1"
}
},
{
"File": {
"licenseInfoFromFiles": [
"Apache-2.0"
],
"sha1": "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
"name": "src/org/spdx/parser/DOAPProject.java",
"copyrightText": "Copyright 2010, 2011 Source Auditor Inc.",
"licenseConcluded": "Apache-2.0",
"checksums": [
{
"value": "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
"algorithm": "checksumAlgorithm_sha1"
}
],
"fileTypes": [
"fileType_source"
],
"id": "SPDXRef-File2"
}
}
],
"licenseInfoFromFiles": [
"Apache-1.0",
"LicenseRef-3",
"MPL-1.1",
"LicenseRef-2",
"LicenseRef-4",
"Apache-2.0",
"LicenseRef-1"
],
"sha1": "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
"name": "SPDX Translator",
"packageFileName": "spdxtranslator-1.0.zip",
"licenseComments": "The declared license information can be found in the NOTICE file at the root of the archive file",
"summary": "SPDX Translator utility",
"sourceInfo": "Version 1.0 of the SPDX Translator application",
"copyrightText": " Copyright 2010, 2011 Source Auditor Inc.",
"packageVerificationCode": {
"value": "4e3211c67a2d28fced849ee1bb76e7391b93feba",
"excludedFilesNames": [
"SpdxTranslatorSpdx.rdf",
"SpdxTranslatorSpdx.txt"
]
},
"licenseConcluded": "(Apache-1.0 AND LicenseRef-2 AND MPL-1.1 AND LicenseRef-3 AND LicenseRef-4 AND Apache-2.0 AND LicenseRef-1)",
"supplier": "Organization: Linux Foundation",
"checksums": [
{
"value": "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
"algorithm": "checksumAlgorithm_sha1"
}
],
"versionInfo": "Version 0.9.2",
"licenseDeclared": "(LicenseRef-4 AND LicenseRef-3 AND Apache-2.0 AND LicenseRef-2 AND MPL-1.1 AND LicenseRef-1)",
"downloadLocation": "http://www.spdx.org/tools",
"description": "This utility translates and SPDX RDF XML document to a spreadsheet, translates a spreadsheet to an SPDX RDF XML document and translates an SPDX RDFa document to an SPDX RDF XML document."
}
}
],
"creationInfo": {
"comment": "This is an example of an SPDX spreadsheet format",
"creators": [
"Tool: SourceAuditor-V1.2",
"Person: Gary O'Neall",
"Organization: Source Auditor Inc."
],
"licenseListVersion": "3.5-1-g1266c6b",
"created": "2010-02-03T00:00:00Z"
},
"externalDocumentRefs": [
{
"checksum": {
"value": "d6a770ba38583ed4bb4525bd96e50461655d2759",
"algorithm": "checksumAlgorithm_sha1"
},
"spdxDocumentNamespace": "https://spdx.org/spdxdocs/spdx-tools-v2.1-3F2504E0-4F89-41D3-9A0C-0305E82C3301",
"externalDocumentId": "DocumentRef-spdx-tool-2.1"
}
],
"namespace": "https://spdx.org/spdxdocs/spdx-example-444504E0-4F89-41D3-9A0C-0305E82C3301",
"annotations": [
{
"comment": "This is just an example. Some of the non-standard licenses look like they are actually BSD 3 clause licenses",
"annotationType": "REVIEW",
"id": "SPDXRef-45",
"annotationDate": "2012-06-13T00:00:00Z",
"annotator": "Person: Jim Reviewer"
}
],
"dataLicense": "CC0-1.0",
"reviewers": [
{
"comment": "This is just an example. Some of the non-standard licenses look like they are actually BSD 3 clause licenses",
"reviewer": "Person: Joe Reviewer",
"reviewDate": "2010-02-10T00:00:00Z"
},
{
"comment": "Another example reviewer.",
"reviewer": "Person: Suzanne Reviewer",
"reviewDate": "2011-03-13T00:00:00Z"
}
],
"extractedLicenseInfos": [
{
"extractedText": "This package includes the GRDDL parser developed by Hewlett Packard under the following license:\n\u00a9 Copyright 2007 Hewlett-Packard Development Company, LP\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: \n\nRedistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. \nRedistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. \nThe name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. \nTHIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
"licenseId": "LicenseRef-2"
},
{
"extractedText": "The CyberNeko Software License, Version 1.0\n\n \n(C) Copyright 2002-2005, Andy Clark. All rights reserved.\n \nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer. \n\n2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in\n the documentation and/or other materials provided with the\n distribution.\n\n3. The end-user documentation included with the redistribution,\n if any, must include the following acknowledgment: \n \"This product includes software developed by Andy Clark.\"\n Alternately, this acknowledgment may appear in the software itself,\n if and wherever such third-party acknowledgments normally appear.\n\n4. The names \"CyberNeko\" and \"NekoHTML\" must not be used to endorse\n or promote products derived from this software without prior \n written permission. For written permission, please contact \n andyc@cyberneko.net.\n\n5. Products derived from this software may not be called \"CyberNeko\",\n nor may \"CyberNeko\" appear in their name, without prior written\n permission of the author.\n\nTHIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, \nOR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT \nOF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR \nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE \nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, \nEVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
"comment": "This is tye CyperNeko License",
"licenseId": "LicenseRef-3",
"name": "CyberNeko License",
"seeAlso": [
"http://justasample.url.com",
"http://people.apache.org/~andyc/neko/LICENSE"
]
},
{
"extractedText": "/*\n * (c) Copyright 2009 University of Bristol\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n * 3. The name of the author may not be used to endorse or promote products\n * derived from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\n * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */ ",
"licenseId": "LicenseRef-4"
},
{
"extractedText": "/*\n * (c) Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, LP\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n * 3. The name of the author may not be used to endorse or promote products\n * derived from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\n * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */",
"licenseId": "LicenseRef-1"
}
],
"specVersion": "SPDX-2.1",
"id": "SPDXRef-DOCUMENT",
"snippets": [
{
"comment": "This snippet was identified as significant and highlighted in this Apache-2.0 file, when a commercial scanner identified it as being derived from file foo.c in package xyz which is licensed under GPL-2.0-or-later.",
"name": "from linux kernel",
"copyrightText": "Copyright 2008-2010 John Smith",
"licenseConcluded": "Apache-2.0",
"licenseInfoFromSnippet": [
"Apache-2.0"
],
"licenseComments": "The concluded license was taken from package xyz, from which the snippet was copied into the current file. The concluded license information was found in the COPYING.txt file in package xyz.",
"id": "SPDXRef-Snippet",
"fileId": "SPDXRef-DoapSource"
}
]
}
}
Loading