Exemplo n.º 1
0
def doCleanup(fid, status):
    try:
        med.MEDfileClose(fid)
    except RuntimeError as ex:
        print("ERROR : close file ...\n%s" % ex)
        status = -1
    finally:
        if status != 0:
            sys.exit(status)
Exemplo n.º 2
0
def RetrieveFamGrpsMapInternal(fn, mn):
    famsPy = {}
    grpsPy = {}
    fid = med.MEDfileOpen(fn, med.MED_ACC_RDONLY)
    med.MEDnFamily(fid, mn)
    s = set()
    for elt in range(med.MEDnFamily(fid, mn)):
        nbGrps = med.MEDnFamilyGroup(fid, mn, elt + 1)
        gro = med.MEDCHAR(med.MED_LNAME_SIZE * nbGrps + 1)
        famName, famId, grps = med.MEDfamilyInfo(fid, mn, elt + 1, gro)
        if famName in s:
            famName = "{}@".format(famName)
        famsPy[famName] = famId
        grps2 = [
            "".join(gro[i * med.MED_LNAME_SIZE:(i + 1) *
                        med.MED_LNAME_SIZE]).rstrip() for i in range(nbGrps)
        ]
        grpsPy[famName] = grps2
        s.add(famName)
        pass
    med.MEDfileClose(fid)
    return famsPy, grpsPy