Exemple #1
0
def _readMetadata(group):
    """Reads a metadata block from the given group, and raises a :exc:`X5Error`
    if it does not look valid.

    :arg group: A ``h5py.Group`` object.
    :returns:   A ``dict`` containing the metadata.
    """

    format    = group.attrs.get('Format')
    version   = group.attrs.get('Version')
    meta      = group.attrs.get('Metadata')

    parserver = fslversion.parseVersionString(X5_VERSION)
    filever   = fslversion.parseVersionString(version)

    if (format != X5_FORMAT) or (filever[0] != parserver[0]):
        raise X5Error('Incompatible format/version (required: {}/{}, '
                      'present: {}/{})'.format(X5_FORMAT, X5_VERSION,
                                               format, version))

    meta             = {}
    meta['Format']   = format
    meta['Version']  = version
    meta['Metadata'] = meta

    return meta
Exemple #2
0
def test_parseVersionString_bad():

    tests = [
        '5',
        '5.5',
        '5.5.5.5',
        '5.5.5.abc',
        '5.a.5',
        'a.5.5',
        '5.5.a',
        '5.5.a',
    ]

    for test in tests:
        with pytest.raises(Exception):
            fslversion.parseVersionString(test)
Exemple #3
0
def test_parseVersionString():

    tests = [
        ('0.0.0',        [0,   0, 0]),
        ('0.0.10',       [0,   0, 10]),
        ('10.0.10',      [10,  0, 10]),
        ('10.10.10',     [10, 10, 10]),
        ('10.10.10.dev', [10, 10, 10]),

        # old-style hotfix release numbers
        ('10.10.10a',    [10, 10, 10]),
        ('10.10.10dev',  [10, 10, 10]),
    ]

    for verstr, expected in tests:
        assert fslversion.parseVersionString(verstr) == expected