def RDF_to_YAML(infile_name, outfile_name):
    # if __name__ == "__main__":
    # import sys
    from spdx.parsers.rdf import Parser
    from spdx.parsers.loggers import StandardLogger
    from spdx.parsers.rdfbuilders import Builder
    from spdx.writers.yaml import write_document

    # file = sys.argv[1]
    p = Parser(Builder(), StandardLogger())
    with open(infile_name) as f:
        document, error = p.parse(f)

        if not error:
            with open(outfile_name, "w") as out:
                write_document(document, out)
        else:
            print("Errors encountered while parsing")
 def write_yaml_file(self, document, file_name):
     with open(file_name, mode='w') as out:
         yamlwriter.write_document(document, out)
Exemple #3
0
#!/usr/bin/env python

if __name__ == '__main__':
    import sys
    from spdx.parsers.tagvalue import Parser
    from spdx.parsers.loggers import StandardLogger
    from spdx.parsers.tagvaluebuilders import Builder
    from spdx.writers.yaml import write_document

    file = sys.argv[1]
    p = Parser(Builder(), StandardLogger())
    p.build()
    with open(file) as f:
        data = f.read()
        document, error = p.parse(data)
        if not error:
            with open('yaml_from_tv_example.yaml', 'w') as out:
                write_document(document, out)
        else:
            print('Errors encountered while parsing')