示例#1
0
def getLineObjs():
    filePath = stateFiles.getPickleFilePath()
    try:
        lineObjs = pickle.load(open(filePath, 'rb'))
    except:
        output.appendError(LOAD_SELECTION_WARNING)
        sys.exit(1)
    logger.addEvent('total_num_files', len(lineObjs.items()))

    selectionPath = stateFiles.getSelectionFilePath()
    if os.path.isfile(selectionPath):
        setSelectionsFromPickle(selectionPath, lineObjs)

    matches = [lineObj for i, lineObj in lineObjs.items()
               if not lineObj.isSimple()]
    if not len(matches):
        output.writeToFile('echo "No lines matched!!"')
        sys.exit(0)
    return lineObjs
示例#2
0
def getLineObjs():
    filePath = stateFiles.getPickleFilePath()
    try:
        lineObjs = pickle.load(open(filePath, 'rb'))
    except:
        output.appendError(LOAD_SELECTION_WARNING)
        sys.exit(1)
    logger.addEvent('total_num_files', len(lineObjs.items()))

    selectionPath = stateFiles.getSelectionFilePath()
    if os.path.isfile(selectionPath):
        setSelectionsFromPickle(selectionPath, lineObjs)

    matches = [lineObj for i, lineObj in lineObjs.items()
               if not lineObj.isSimple()]
    if not len(matches):
        output.writeToFile('echo "No lines matched!!"')
        sys.exit(0)
    return lineObjs
示例#3
0
def setSelectionsFromPickle(selectionPath, lineObjs):
    try:
        selectedIndices = pickle.load(open(selectionPath, 'rb'))
    except:
        output.appendError(LOAD_SELECTION_WARNING)
        sys.exit(1)
    for index in selectedIndices:
        if index >= len(lineObjs.items()):
            error = 'Found index %d more than total matches' % index
            output.appendError(error)
            continue
        toSelect = lineObjs[index]
        if isinstance(toSelect, format.LineMatch):
            lineObjs[index].setSelect(True)
        else:
            error = 'Line %d was selected but is not LineMatch' % index
            output.appendError(error)
示例#4
0
def setSelectionsFromPickle(selectionPath, lineObjs):
    try:
        selectedIndices = pickle.load(open(selectionPath, 'rb'))
    except:
        output.appendError(LOAD_SELECTION_WARNING)
        sys.exit(1)
    for index in selectedIndices:
        if index >= len(lineObjs.items()):
            error = 'Found index %d more than total matches' % index
            output.appendError(error)
            continue
        toSelect = lineObjs[index]
        if isinstance(toSelect, format.LineMatch):
            lineObjs[index].setSelect(True)
        else:
            error = 'Line %d was selected but is not LineMatch' % index
            output.appendError(error)