コード例 #1
0
ファイル: kefutility.py プロジェクト: kujaku11/PH5_py3
def Kef2TableData(statusbar, filename):
    try:
        kef = kefx.Kef(filename)
        kef.open()
        kef.read()
        kef.rewind()
    except Exception:
        raise

    tables = {}
    types = {}
    count = 0
    totalLines = kef.pathCount
    for path, kVal in kef:
        if path not in tables:
            tables[path] = []
            types[path] = []
        if types[path] == []:
            for label in kef.keySets[path]:
                types[path].append(PH5TYPE[label[-2:]])

        entry = []
        for label in kef.keySets[path]:
            entry.append(kVal[label])
        tables[path].append(entry)
        count += 1

        if count % 10000 == 0:
            msg = "Converting Kef to Data: %s/%s."
            statusbar.showMessage(msg % (count, totalLines))

    kef.close()
    return tables, kef.keySets, totalLines, types
コード例 #2
0
ファイル: external_file.py プロジェクト: thecassion/PH5
def kef_open(filename):
    try:
        kx = kefx.Kef(filename)
        kx.open()
        kx.read()
        kx.rewind()
    except Exception as e:
        raise kefx.KefError(e.message)

    return kx
コード例 #3
0
def read_kef():
    '''   Open KEF and read ARGS.kefile
    '''
    global KEF
    try:
        KEF = kefx.Kef(ARGS.kefile)
        KEF.open()
        KEF.read()
        KEF.rewind()
    except Exception as e:
        LOGGER.error(e.message)
        sys.exit()
コード例 #4
0
def main():
    args = get_args()

    kefin = args.infile

    try:
        kx = kefx.Kef(kefin)
        kx.open()
    except Exception as e:
        LOGGER.error("Error opening kef file {0} - {1}".format(kefin, e))
    else:
        kx.read()
        kx.rewind()
        kx.ksort('id_s')
        kx.rewind()
        if isinstance(args.outfile, (str, unicode)):
            args.outfile = open(args.outfile, "w")
        args.outfile.write(kx.to_str())
コード例 #5
0
ファイル: sort_array_t.py プロジェクト: thecassion/PH5
def main():
    nodeIDRE = re.compile("\d+X\d+")
    try:
        kefin = sys.argv[1]
        kx = kefx.Kef(kefin)
        kx.open()
    except:
        print "Version: {0} Usage: sort_array_t Array_t_unsorted.kef > Array_t_sorted.kef".format(
            PROG_VERSION)
        sys.exit()

    kx.read()
    kx.rewind()
    kx.ksort('id_s')
    kx.rewind()
    for p, kv in kx:
        if nodeIDRE.match(kv['id_s']):
            kv['id_s'] = kv['id_s'].split('X')[1]
        kefx.print_kef(p, kv)
コード例 #6
0
ファイル: kef2ph5.py プロジェクト: kujaku11/PH5_py3
def populateTables():
    global EX, KEFFILE, TRACE
    LOGGER.info("Loading {0} into {1}.".format(KEFFILE, PH5))
    k = kefx.Kef(KEFFILE)
    k.open()

    while True:
        n = k.read(10000)
        if n == 0:
            err = "Empty kef file."
            break

        # Get Das_g references
        ret = k.strip_receiver_g()

        if ret:
            add_references(ret)

        # Make sure Array_t_xxx, Event_t_xxx, and Offset_t_aaa_sss exist
        arrays, events, offsets = k.strip_a_e_o()
        if arrays:
            for a in arrays:
                a = a.split(':')[0]
                EX.ph5_g_sorts.newArraySort(a)

        if events:
            for e in events:
                e = e.split(':')[0]
                EX.ph5_g_sorts.newEventSort(e)

        if offsets:
            for o in offsets:
                o = o.split(':')[0]
                EX.ph5_g_sorts.newOffsetSort(o)

        if TRACE is True:
            err = k.batch_update(trace=True)
        else:
            err = k.batch_update()

    k.close()
    if err is True:
        LOGGER.error("There were errors! See output.")
コード例 #7
0
ファイル: kef2ph5.py プロジェクト: thecassion/PH5
def populateTables():
    global EX, KEFFILE, TRACE
    k = kefx.Kef(KEFFILE)
    k.open()

    while True:
        n = k.read(10000)
        if n == 0:
            err = "Empty kef file."
            break

        #   Get Das_g references
        ret = k.strip_receiver_g()

        if ret:
            add_references(ret)

        #   Make sure Array_t_xxx, Event_t_xxx, and Offset_t_aaa_sss exist
        arrays, events, offsets = k.strip_a_e_o()
        #print arrays
        if arrays:
            for a in arrays:
                a = a.split(':')[0]
                refa = EX.ph5_g_sorts.newArraySort(a)

        if events:
            for e in events:
                e = e.split(':')[0]
                refe = EX.ph5_g_sorts.newEventSort(e)

        if offsets:
            for o in offsets:
                o = o.split(':')[0]
                refo = EX.ph5_g_sorts.newOffsetSort(o)

        if TRACE == True:
            err = k.batch_update(trace=True)
        else:
            err = k.batch_update()

    k.close()
    if err == True:
        sys.stderr.write("\nError: There were errors! See output.\n")