コード例 #1
0
def main(path):

    completepath = os.path.join(path, METADATAFILE + "*")
    matchglobals = glob.glob(completepath)

    if not matchglobals:
        exit()

    tc_class = TollCheck(path=path)

    out = {}
    for m in matchglobals:

        out.update(tc_class.__load_info__(m))
        os.remove(m)

    tc_class.__save_obj__(out)
コード例 #2
0
def tometadata(path, partition_list=None, step_choices=None):

    # path = "."
    fishfiles = TollCheck(path=path)

    if partition_list is not None:
        partitions = []

        for i in partition_list:
            part_file = glob.glob(os.path.join(path, METADATAFILE + i))

            if part_file:
                partitions += part_file
    else:
        partitions = glob.glob(os.path.join(path, METADATAFILE + "*"))

    proto_fmt = "%-{}s | %-{}s\n"
    proto_base = "%s-+-%s\n"

    if not partitions:
        mydict = printdict(fishfiles.pickleIt, step_choices)
        dirmax, stepmax, values = mydict

        fmt = proto_fmt.format(dirmax, stepmax)
        # header = proto_fmt % ("Directory", "Steps")
        sys.stdout.write("\n")
        sys.stdout.write(fmt % ("Directory", "Steps"))
        sys.stdout.write(proto_base % ('-' * dirmax, '-' * stepmax))

        for cores_steps in values:
            sys.stdout.write(fmt % cores_steps)

        sys.stdout.write("\n")

    else:

        dirmaxchar = []
        stepmaxchar = []
        df = {}

        for f in partitions:
            key = re.sub(".+_part(.+)", "\\1", f)

            mydict = printdict(fishfiles.__load_info__(f), step_choices)
            dirmax, stepmax, values = mydict

            dirmaxchar.append(dirmax)
            stepmaxchar.append(stepmax)
            df.update({key: values})

        dirmaxchar_s = sorted(dirmaxchar, reverse=True)[0]
        stepmaxchar_s = sorted(stepmaxchar, reverse=True)[0]

        fmt = ("%-{}s | " + proto_fmt).format(6, dirmaxchar_s, stepmaxchar_s)

        sys.stdout.write("\n")
        sys.stdout.write(fmt % ("Branch", "Directory", "Steps"))
        sys.stdout.write(("%s-+-" + proto_base) %
                         ('-' * 6, '-' * dirmaxchar_s, '-' * stepmaxchar_s))

        for part in sorted(df.keys()):
            for cs in df[part]:
                sys.stdout.write(fmt % ((part, ) + cs))
        sys.stdout.write("\n")