Skip to content

Instantly share code, notes, and snippets.

@thurask
Created June 3, 2019 04:04
Show Gist options
  • Select an option

  • Save thurask/884a26f3d3db30b5944cccfd062afe34 to your computer and use it in GitHub Desktop.

Select an option

Save thurask/884a26f3d3db30b5944cccfd062afe34 to your computer and use it in GitHub Desktop.

Revisions

  1. thurask created this gist Jun 3, 2019.
    19 changes: 19 additions & 0 deletions dbpf_sorter.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    import collections
    import os


    def header_reader(infile):
    with open(infile, "rb") as afile:
    afile.seek(36)
    bval = afile.read(1)
    ival = int.from_bytes(bval, byteorder="big")
    return ival


    def dicter():
    packs = [os.path.abspath(x) for x in os.listdir() if x.endswith(".package")]
    dictx = {c.replace(os.getcwd(), ""): header_reader(c) for c in packs}
    dictsort = collections.OrderedDict(sorted(dictx.items(), key=lambda x: x[1]))
    for key, val in dictsort.items():
    print("{}: {}".format(key, val))