コード例 #1
0
def test_padbytes_as_large_as_segment():
    # 180-byte long explicit record with padding, and padbytes are set to 176
    # record is expected to not be present
    f = dlisio.open('data/chap2/padbytes-large-as-segment-body.dlis')
    try:
        rec = core.extract(f, [0])[0]
        assert len(memoryview(rec)) == 0
    finally:
        f.close()
コード例 #2
0
def test_padbytes_as_large_as_record():
    # 180-byte long explicit record with padding, and padbytes are set to 180
    # (leaving the resulting len(data) == 0)
    f = dlisio.open('data/padbytes-large-as-record.dlis')
    f.reindex([0], [180])

    rec = f.extract([0])[0]
    assert rec.explicit
    assert len(memoryview(rec)) == 0
コード例 #3
0
def test_padbytes_as_large_as_record():
    # 180-byte long explicit record with padding, and padbytes are set to 180
    # (leaving the resulting len(data) == 0)
    f = dlisio.open('data/chap2/padbytes-large-as-record.dlis')
    try:
        rec = core.extract(f, [0])[0]
        assert rec.explicit
        assert len(memoryview(rec)) == 0
    finally:
        f.close()
コード例 #4
0
ファイル: test_dlis.py プロジェクト: cxz/dlisio
def g():
    s = dlisio.open("tests/test_dlis.py")  #any existing file is required
    g = dlisio.dlis(s, [], None, [])

    ch = Channel()
    ch.name = 'CHANNEL1'
    ch.origin = 0
    ch.copynumber = 0
    g.indexedobjects["CHANNEL"][ch.fingerprint] = ch

    ch = Channel()
    ch.name = 'CHANNEL1.V2'
    ch.origin = 0
    ch.copynumber = 0
    g.indexedobjects["CHANNEL"][ch.fingerprint] = ch

    ch = Channel()
    ch.name = 'CHANNEL1'
    ch.origin = 0
    ch.copynumber = 1
    g.indexedobjects["CHANNEL"][ch.fingerprint] = ch

    un = Unknown()
    un.name = 'UNEFRAME'
    un.origin = 0
    un.copynumber = 0
    un.type = "NONCHANNEL"
    g.indexedobjects["NONCHANNEL"][un.fingerprint] = un

    fr = Frame()
    fr.name = 'UNEFRAME'
    fr.origin = 0
    fr.copynumber = 0
    g.indexedobjects["FRAME"][fr.fingerprint] = fr

    un = Unknown()
    un.name = '440-CHANNEL'
    un.origin = 0
    un.copynumber = 0
    un.type = "440.TYPE"
    g.indexedobjects["440.TYPE"][un.fingerprint] = un

    ch = Channel()
    ch.name = '440.CHANNEL'
    ch.origin = 0
    ch.copynumber = 0
    ch.type = "440-TYPE"
    g.indexedobjects["440-TYPE"][ch.fingerprint] = ch

    return g
コード例 #5
0
def test_record_attributes():
    stream = dlisio.open('data/3-syntactic-logical-records.dlis')
    tells = [80, 116, 148]
    residuals = [0, 64, 32]
    # for the test pretend all 3 records are explicit
    explicits = [0, 1, 2]
    stream.reindex(tells, residuals)
    recs = stream.extract(explicits)
    buffer = bytearray(1)

    # last record ignored as encrypted
    assert len(recs) == 2

    assert recs[0].type == 1
    assert not recs[0].explicit
    assert not recs[0].encrypted
    # due to error in VE version
    assert not recs[0].consistent
    checked_byte = np.array(recs[0])[1]
    assert checked_byte == 4
    stream.get(buffer, tells[0] + 9, 1)
    assert checked_byte == buffer[0]

    assert recs[1].type == 2
    assert recs[1].explicit
    assert not recs[1].encrypted
    assert recs[1].consistent
    stream.get(buffer, tells[1] + 5, 1)
    assert np.array(recs[1])[1] == buffer[0]

    rec3 = stream[2]
    assert rec3.type == 3
    assert not rec3.explicit
    assert rec3.encrypted
    assert rec3.consistent
    assert np.array(rec3)[1] == 8

    stream.close()
コード例 #6
0
def g():
    s = dlisio.open(
        "tests/test_logical_file.py")  #any existing file is required
    g = dlisio.dlis(s, [], [], [])

    ch = Channel()
    ch.name = 'CHANNEL1'
    ch.origin = 0
    ch.copynumber = 0
    ch.logicalfile = g
    g.indexedobjects["CHANNEL"][ch.fingerprint] = ch

    ch = Channel()
    ch.name = 'CHANNEL1.V2'
    ch.origin = 0
    ch.copynumber = 0
    ch.logicalfile = g
    g.indexedobjects["CHANNEL"][ch.fingerprint] = ch

    ch = Channel()
    ch.name = 'CHANNEL1'
    ch.origin = 0
    ch.copynumber = 1
    ch.logicalfile = g
    g.indexedobjects["CHANNEL"][ch.fingerprint] = ch

    un = Unknown()
    un.name = 'UNEFRAME'
    un.origin = 0
    un.copynumber = 0
    un.type = "NONCHANNEL"
    un.logicalfile = g
    g.indexedobjects["NONCHANNEL"][un.fingerprint] = un

    fr = Frame()
    fr.name = 'UNEFRAME'
    fr.origin = 0
    fr.copynumber = 0
    fr.logicalfile = g
    g.indexedobjects["FRAME"][fr.fingerprint] = fr

    un = Unknown()
    un.name = '440-CHANNEL'
    un.origin = 0
    un.copynumber = 0
    un.type = "440.TYPE"
    un.logicalfile = g
    g.indexedobjects["440.TYPE"][un.fingerprint] = un

    ch = Channel()
    ch.name = '440.CHANNEL'
    ch.origin = 0
    ch.copynumber = 0
    ch.type = "440-TYPE"
    ch.logicalfile = g
    g.indexedobjects["440-TYPE"][ch.fingerprint] = ch

    g.record_types = list(g.indexedobjects.keys())

    # Simulate the occurance of multiple Channel sets
    g.record_types.append('CHANNEL')
    return g