Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
cmdline.py57 linesDownload Raw Back to framework
1# cmdline - command line utilities.2import string3import sys4 5import win32ui6 7 8def ParseArgs(str):9    import string10 11    ret = []12    pos = 013    length = len(str)14    while pos < length:15        try:16            while str[pos] in string.whitespace:17                pos = pos + 118        except IndexError:19            break20        if pos >= length:21            break22        if str[pos] == '"':23            pos = pos + 124            try:25                endPos = str.index('"', pos) - 126                nextPos = endPos + 227            except ValueError:28                endPos = length29                nextPos = endPos + 130        else:31            endPos = pos32            while endPos < length and not str[endPos] in string.whitespace:33                endPos = endPos + 134            nextPos = endPos + 135        ret.append(str[pos : endPos + 1].strip())36        pos = nextPos37    return ret38 39 40def FixArgFileName(fileName):41    """Convert a filename on the commandline to something useful.42    Given an automatic filename on the commandline, turn it a python module name,43    with the path added to sys.path."""44    import os45 46    path, fname = os.path.split(fileName)47    if len(path) == 0:48        path = os.curdir49    path = os.path.abspath(path)50    # must check that the command line arg's path is in sys.path51    for syspath in sys.path:52        if os.path.abspath(syspath) == path:53            break54    else:55        sys.path.append(path)56    return os.path.splitext(fname)[0]57 
codekingpro/portable-devtools · Team Ai