Example #1
0
def marc2record(marc, record_type='book'):
    from rerodoc.dojson.book import book
    from rerodoc.dojson.audio import audio
    if record_type == 'book':
        return book.do(marc)
    if record_type == 'audio':
        return audio.do(marc)
Example #2
0
def get_demo_record(rec):
    """Get a record in Json format from a MarcXML."""

    from dojson.contrib.marc21.utils import create_record
    from rerodoc.dojson.book import book
    blob = create_record(rec)
    data = book.do(blob)
    return data
Example #3
0
def marc2marc(marc, record_type='book'):
    from rerodoc.dojson.book import book, book2marc
    from rerodoc.dojson.audio import audio, audio2marc
    if record_type == 'book':
        record = book.do(marc)
        return book2marc.do(record)
    if record_type == 'audio':
        record = audio.do(marc)
        return audio2marc.do(record)
Example #4
0
def get_demo_record(file_name, verbose=False):
    """Get a record in Json format from a MarcXML."""

    from dojson.contrib.marc21.utils import create_record
    from rerodoc.dojson.book import book
    blob = create_record(file(file_name).read())
    data = book.do(blob)
    if verbose:
        print(json.dumps(blob, indent=2))
        print(json.dumps(data, indent=2))
    return data
Example #5
0
    def test_book_full_dimension(self):
        from rerodoc.dojson.book import book

        data = book.do({"300__": {"c": "25 x 30 cm"}})
        assert data.get("dimension") == {"width": 25, "height": 30}
Example #6
0
    def test_book_simple_bad_pages(self):
        from rerodoc.dojson.book import book

        data = book.do({"300__": {"a": "A25 j. fjklad"}})
        assert data.get("n_pages") == None
Example #7
0
    def test_book_simple_dimension(self):
        from rerodoc.dojson.book import book

        data = book.do({"300__": {"c": "25 cm"}})
        assert data.get("dimension") == {"width": 25}
Example #8
0
    def test_book_simple_n_pages(self):
        from rerodoc.dojson.book import book

        data = book.do({"300__": {"a": "25"}})
        assert data.get("n_pages") == 25
Example #9
0
    def test_book_n_pages_sheet(self):
        from rerodoc.dojson.book import book

        data = book.do({"300__": {"a": "230 f."}})
        assert data.get("n_pages") == 230
Example #10
0
    def test_book_invalid_date(self):
        from rerodoc.dojson.book import book

        data = book.do({"260__": {"c": "209 jfkad afje788"}})
        assert data.get("publication_date", None) == None
Example #11
0
    def test_book_full_date(self):
        from rerodoc.dojson.book import book

        data = book.do({"260__": {"c": "2015 bla 2013 bla 2001"}})
        assert data.get("publication_date") == {"to": 2015, "full": "2001-2015", "from": 2001}
Example #12
0
    def test_book_from_date(self):
        from rerodoc.dojson.book import book

        data = book.do({"260__": {"c": "2015-"}})
        assert data.get("publication_date") == {"full": "2015-", "from": 2015}