-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates README files and example files.
Adds new example file rdf_to_tv.py. Signed-off-by: Ahmed H. Ismail <[email protected]>
- Loading branch information
Showing
7 changed files
with
78 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/usr/bin/env python | ||
if __name__ == '__main__': | ||
import sys | ||
from spdx.parsers.tagvalue import Parser | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python | ||
# Converts an RDF file to tag/value format. | ||
# usage rdf_to_tv <rdffile> <tagvaluefile> | ||
if __name__ == '__main__': | ||
import sys | ||
import codecs | ||
from spdx.parsers.rdf import Parser | ||
from spdx.parsers.loggers import StandardLogger | ||
from spdx.parsers.rdfbuilders import Builder | ||
from spdx.writers.tagvalue import write_document, InvalidDocumentError | ||
infile_name = sys.argv[1] | ||
outfile_name = sys.argv[2] | ||
rdfparser = Parser(Builder(), StandardLogger()) | ||
with open(infile_name) as infile: | ||
document, error = rdfparser.parse(infile) | ||
if not error: | ||
# print map(lambda c: c.name, document.creation_info.creators) | ||
print 'Parsing Successful' | ||
with codecs.open(outfile_name, mode='w', encoding='utf-8') as outfile: | ||
try: | ||
write_document(document, outfile) | ||
except InvalidDocumentError: | ||
# Note document is valid if error is False | ||
print 'Document is Invalid' | ||
else: | ||
print 'Errors encountered while parsing RDF file.' | ||
messages = [] | ||
document.validate(messages) | ||
print '\n'.join(messages) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters