<commit_before>import sys
import os

def SyncMain(args):
    import iopc_sync
    iopc_sync.Main(args)

def BuildMain(args):
    import iopc_build
    iopc_build.Main(args)

def StatusMain(args):
    import iopc_status
    iopc_status.Main(args)

def CommitMain(args):
    import iopc_commit
    iopc_commit.Main(args)

ActionTable = {
    "SYNC": SyncMain,
    "BUILD": BuildMain,
    "STATUS": StatusMain,
    "COMMIT": CommitMain,
}

def help():
    print "PackMan.py <packages_dir> <Action>"
    print "  Action:"
    for act in ActionTable:
        print "    " + act
    sys.exit(1)

def setLibPath():
    # append library path
    python_lib = os.path.abspath("pylib")
    sys.path.append(python_lib)

    if not os.path.exists(python_lib):
        print "Please download [pylib] from github!!"
        print "git clone https://github.com/YuanYuLin/pylib.git"
        sys.exit(1)

    sys.path.append(python_lib)
    python_lib = os.path.abspath("pyiopc")
    sys.path.append(python_lib)

def loadJson2Obj(path):
    import ops
    return ops.loadJson2Obj(path)

if __name__ == '__main__':
    setLibPath()

    if len(sys.argv) < 4:
        help()

    packages_dir = sys.argv[1]
    action       = sys.argv[2]

    if action not in ActionTable:
        help()

    json_menu = os.path.abspath(packages_dir + os.sep + "packages.json")
    account_menu = os.path.abspath(packages_dir + os.sep + "account.json")
    if not os.path.exists(json_menu):
        print "[" + json_menu + "] not exist!"
        help()

    cfg     = loadJson2Obj(json_menu)
    account = loadJson2Obj(account_menu)

    import iopc
    args = {}
    iopc.setCfg(args, cfg)
    iopc.setAccount(args, account)
    iopc.setParams(args, sys.argv[3:])

    ActionTable[action](args)
<commit_msg>update PackMan<commit_after>import sys
import os

def SyncMain(args):
    import iopc_sync
    iopc_sync.Main(args)

def BuildMain(args):
    import iopc_build
    iopc_build.Main(args)

def StatusMain(args):
    import iopc_status
    iopc_status.Main(args)

def CommitMain(args):
    import iopc_commit
    iopc_commit.Main(args)

ActionTable = {
    "SYNC": SyncMain,
    "BUILD": BuildMain,
    "STATUS": StatusMain,
    "COMMIT": CommitMain,
}

def help():
    print "PackMan.py <packages_dir> <Action>"
    print "  Action:"
    for act in ActionTable:
        print "    " + act
    sys.exit(1)

def setLibPath():
    # append library path
    python_lib = os.path.abspath("pylib")
    sys.path.append(python_lib)

    if not os.path.exists(python_lib):
        print "Please download [pylib] from github!!"
        print "git clone https://github.com/YuanYuLin/pylib.git"
        sys.exit(1)

    sys.path.append(python_lib)
    python_lib = os.path.abspath("pyiopc")
    sys.path.append(python_lib)

def loadJson2Obj(path):
    import ops
    return ops.loadJson2Obj(path)

if __name__ == '__main__':
    setLibPath()

    if len(sys.argv) < 4:
        help()

    packages_dir = sys.argv[1]
    action       = sys.argv[2]

    if action not in ActionTable:
        help()

    json_menu = os.path.abspath(packages_dir + os.sep + "packages.json")
    if not os.path.exists(json_menu):
        print "[" + json_menu + "] not exist!"
        help()

    account_menu = os.path.abspath(packages_dir + os.sep + "account.json")
    if not os.path.exists(account_menu):
        print "[" + account_menu + "] not exist!"
        help()

    cfg     = loadJson2Obj(json_menu)
    account = loadJson2Obj(account_menu)

    import iopc
    args = {}
    iopc.setCfg(args, cfg)
    iopc.setAccount(args, account)
    iopc.setParams(args, sys.argv[3:])

    ActionTable[action](args)

{'fraction_non_alphanumeric': 0.12315270935960591, 'fraction_numerical': 0.005473453749315818, 'mean_word_length': 2.8272251308900525, 'pattern_counts': {'":': 8, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4903764', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1303, 'n_words': 265}