Пример #1
0
def doProgram(stdscr, flags, cursesAPI=None, lineObjs=None):
    # curses and lineObjs get dependency injected for
    # our tests, so init these if they are not provided
    if not cursesAPI:
        cursesAPI = CursesAPI()
    if not lineObjs:
        lineObjs = getLineObjs()
    output.clearFile()
    logger.clearFile()
    screen = screenControl.Controller(flags, stdscr, lineObjs, cursesAPI)
    screen.control()
Пример #2
0
def doProgram(stdscr):
    output.clearFile()
    logger.clearFile()
    lineObjs = getLineObjs()
    screen = screenControl.Controller(stdscr, lineObjs)
    screen.control()
Пример #3
0
def getLineObjs():
    filePath = os.path.expanduser(PICKLE_FILE)
    lineObjs = pickle.load(open(filePath))
    matches = [
        lineObj for lineObj in lineObjs.values()
        if isinstance(lineObj, LineMatch)
    ]
    logger.addEvent('total_num_files', len(lineObjs))

    selectionPath = os.path.expanduser(SELECTION_PICKLE)
    if os.path.isfile(selectionPath):
        selectedIndices = pickle.load(open(selectionPath))
        for index in selectedIndices:
            if index < len(matches):
                matches[index].is_selected = True

    if not matches:
        output.writeToFile('echo "No lines matched!!"')
        sys.exit(0)
    return lineObjs


if __name__ == '__main__':
    if not os.path.exists(os.path.expanduser(PICKLE_FILE)):
        print('Nothing to do!')
        output.writeToFile('echo ":D"')
        sys.exit(0)
    output.clearFile()
    curses.wrapper(doProgram)
Пример #4
0
def doProgram(stdscr):
    output.clearFile()
    logger.clearFile()
    lineObjs = getLineObjs()
    screen = screenControl.Controller(stdscr, lineObjs)
    screen.control()
Пример #5
0
    screen.control()


def getLineObjs():
    filePath = os.path.expanduser(PICKLE_FILE)
    lineObjs = pickle.load(open(filePath))
    matches = [lineObj for i, lineObj in lineObjs.items()
               if not lineObj.isSimple()]
    logger.addEvent('total_num_files', len(lineObjs.items()))

    selectionPath = os.path.expanduser(SELECTION_PICKLE)
    if os.path.isfile(selectionPath):
        selectedIndices = pickle.load(open(selectionPath))
        for index in selectedIndices:
            if index < len(matches):
                matches[index].setSelect(True)

    if not len(matches):
        output.writeToFile('echo "No lines matched!!"')
        sys.exit(0)
    return lineObjs


if __name__ == '__main__':
    if not os.path.exists(os.path.expanduser(PICKLE_FILE)):
        print 'Nothing to do!'
        output.writeToFile('echo ":D"')
        sys.exit(0)
    output.clearFile()
    curses.wrapper(doProgram)