Example #1
0
                      help="Output format such as json-ld, xml, turtle (default: turtle)",
                      type="string", default="turtle")

    (options, args) = parser.parse_args()

    if len(args) != 1:
        parser.error("Error: incorrect number of arguments, try --help")

    doc = get_demo_record(file_name=args[0], verbose=options.verbose)
    validate(doc)
    if options.verbose:
        from rerodoc.dojson.book import book2marc
        print(json.dumps(book2marc.do(doc), indent=2))

    from rerodoc.dojson.utils import get_context
    context = get_context("book")
    doc.update(context)

    if options.verbose:
        print("Input record in json format:")
        print(json.dumps(doc, indent=2))

    compacted = jsonld.compact(doc, context)
    #print compacted
    expanded = jsonld.expand(compacted)
    #import pprint
    #pprint.pprint(expanded)
    #flattened = jsonld.flatten(doc)
    #framed = jsonld.frame(doc, context)
    #normalized = jsonld.normalize(doc, {'format': 'application/nquads'})
    graph = Graph().parse(data=json.dumps(compacted, indent=2), format="json-ld")
Example #2
0
def book_context():
    """Session-wide book context."""
    from rerodoc.dojson.utils import get_context
    return get_context("book")
Example #3
0
 def test_get_wrong_context(self):
     from rerodoc.dojson.utils import get_context
     assert get_context("not_exists") == None