Exemplo n.º 1
0
def print_wait():
    # Set frame as previous code frame (calling function)
    frame = sys._getframe(1)
    # Set context as name of calling function
    module = os.path.splitext(os.path.basename(frame.f_code.co_filename))[0]
    function = frame.f_code.co_name
    context = "{0}.{1}".format(module, function)

    try:
        debugEnabled = eval(DEBUG_MODE_VARNAME, frame.f_globals,
                            frame.f_locals)
        if debugEnabled:
            cinput.get_keypress(
                "\n[{}] Press any key to continue...".format(context))
    except:
        print_err("Debug mode [{1}] not set for {0}".format(
            context, DEBUG_MODE_VARNAME))
Exemplo n.º 2
0
def run_error_scan(spellBee):

    spellBee.display_about()
    userInput = cinput.get_keypress("\nReady for error scan? Press any key when ready ... ")
    print SB_EMPTY_STRING

    activeWordIndex = 0

    while True:
        if (activeWordIndex < 0) or (activeWordIndex >= len(spellBee.activeWordIndexList)):
            break

        wordIndex = spellBee.activeWordIndexList[activeWordIndex]

        # Lookup word definition
        spellBee.lookup_dictionary_by_index(wordIndex)
        displayText = unicode("Scanned word #{0}: {1}", 'utf-8')
        print displayText.format(wordIndex + 1, spellBee.activeWord)

        # Move to next word
        activeWordIndex += 1
    
    displayText = unicode("\nError scan is complete. All errors are logged to {0}{1}.", 'utf-8')
    print displayText.format(SB_DATA_DIR, SB_ERR_LOG)
Exemplo n.º 3
0
        if setName == APP_STOP_SET_NM:
            processFlag = False

    if processFlag is False:
        print("Set {} marked for exclusion. Skipping.".format(setName))
    else:
        print("Set {} marked for processing.".format(setName))
        setEntries.append({"id" : setID, "name" : setName, "url" : setURL})

print("\nModule Label: " + moduleTitle)
print("Module Name: {SOURCE}/{MODULE_ID}-{MODULE_NM}".format(SOURCE=APP_SOURCE_ID, MODULE_ID=APP_MODULE_ID, MODULE_NM=APP_MODULE_NM))
print("Sets marked for processing:")
for setEntry in setEntries:
    print(setEntry)

userInput = cinput.get_keypress("\nPlease review sets and press any key when ready ... ")

# Iterate through sets from module
for setEntry in setEntries:
    print("\nSet URL: " + setEntry["url"])

    while True:
        try:
            browser.get(setEntry["url"])

            print("\nInitializing list and error files ...")
            
            APP_LIST_FILE = APP_LIST_DIR + cfile.cleanse_filename(APP_LIST.format(SOURCE=APP_SOURCE_ID, MODULE_ID=APP_MODULE_ID, MODULE_NM=APP_MODULE_NM, SET_ID=setEntry["id"]))
            print("Word List: " + APP_LIST.format(SOURCE=APP_SOURCE_ID, MODULE_ID=APP_MODULE_ID, MODULE_NM=APP_MODULE_NM, SET_ID=setEntry["id"]))
            if os.path.isfile(APP_LIST_FILE) and os.path.getsize(APP_LIST_FILE) > 0:
                print("List file {} exists. Deleting...".format(APP_LIST_FILE))
Exemplo n.º 4
0
def run_revision(spellBee):
    _FUNC_NAME_ = "run_revision"

    spellBee.print_active_word_list()
    display_help("revise")
    userInput = cinput.get_keypress("\nReady to revise? Press any key when ready ... ")

    testDate = time.strftime('%a %d-%b-%Y %H:%M:%S')
    testTotalCount = spellBee.active_word_count()
    testCorrectCount = 0

    userResponse = SB_EMPTY_STRING
    testValuation = SB_EMPTY_STRING

    spellBee.reset_test_result()
  
    activeWordIndex = 0

    while True:
        coutput.print_debug(SB_ERR_DEBUG, _FUNC_NAME_, "activeWordIndexList :: {0}".format(spellBee.activeWordIndexList))
        coutput.print_debug(SB_ERR_DEBUG, _FUNC_NAME_, "activeWordIndex :: {0}".format(activeWordIndex))
        if (activeWordIndex < 0) or (activeWordIndex >= len(spellBee.activeWordIndexList)):
            break

        wordIndex = spellBee.activeWordIndexList[activeWordIndex]
        coutput.print_debug(SB_ERR_DEBUG, _FUNC_NAME_, "wordIndex :: {0}".format(wordIndex))

        # Lookup word definition
        spellBee.lookup_dictionary_by_index(wordIndex)
        spellBee.display_word_cue(SB_STUDY_WORD_DEFN_TITLE.format(INDEX=wordIndex + 1, WORD=spellBee.activeWord))
        userResponse = cinput.get_keypress("Enter response: ")

        # E[x]it test
        if userResponse.lower() == "x":
            break

        # Re[v]iew active word list
        elif userResponse.lower() == "v":
            print SB_EMPTY_STRING
            spellBee.print_active_word_list()
            continue

        # Display [h]elp and statistics
        elif userResponse.lower() == "h":
            print SB_EMPTY_STRING
            spellBee.display_about()
            display_help("revise")
            continue

        # Process correct response
        elif userResponse.lower() == "y":
            correctResponse = True
            testValuation = SB_RIGHT_SYMBOL + " " + spellBee.activeWord
            testCorrectCount += 1

            # Display valuation
            # Handle display text in ascii
            asciiTestValuation = testValuation.encode('utf-8')
            coutput.print_color('green', " " * 50 + asciiTestValuation)

            # Save valuation
            spellBee.log_test_valuation(testValuation)

            # Move to next word
            activeWordIndex += 1

        # Process incorrect response
        elif userResponse.lower() == "n":
            correctResponse = False
            testValuation = SB_WRONG_SYMBOL + " " + spellBee.activeWord
            spellBee.log_practice_word(spellBee.activeWord)

            # Display valuation
            # Handle display text in ascii
            asciiTestValuation = testValuation.encode('utf-8')
            coutput.print_color('red', " " * 50 + asciiTestValuation)

            # Save valuation
            spellBee.log_test_valuation(testValuation)

            # Move to next word
            activeWordIndex += 1

        # [R]epeat question as default action
        else:
            continue
    
    spellBee.log_test_result(testDate, str(testCorrectCount) + "/" + str(testTotalCount))
    print "\nYour revision is complete. Displaying results..."
    
    spellBee.display_evaluation_result('revise', SB_TEST_SAVE_RESULT, True)
Exemplo n.º 5
0
def run_test(spellBee):
    _FUNC_NAME_ = "run_test"

    spellBee.display_about()
    display_help("test")
    userInput = cinput.get_keypress("\nReady for the test? Press any key when ready ... ")

    testDate = time.strftime('%a %d-%b-%Y %H:%M:%S')
    testTotalCount = spellBee.active_word_count()
    testCorrectCount = 0

    userResponse = SB_EMPTY_STRING
    testValuation = SB_EMPTY_STRING

    spellBee.reset_test_result()

    
    # Disable saving practice words if :
    # saving is disabled for test results, or
    # the test is based on practice, revision or wild card lists
    savePracticeWordsEnabled = SB_TEST_SAVE_PRACTICE
    if SB_TEST_SAVE_RESULT == False or 'practice' in spellBee.contestList.lower() or 'revision' in spellBee.contestList.lower() or '*' in spellBee.contestList:
        savePracticeWordsEnabled = False
    coutput.print_debug(SB_ERR_DEBUG, _FUNC_NAME_, "SB_TEST_SAVE_PRACTICE :: {0}".format(SB_TEST_SAVE_PRACTICE))
    coutput.print_debug(SB_ERR_DEBUG, _FUNC_NAME_, "savePracticeWordsEnabled :: {0}".format(savePracticeWordsEnabled))

    activeWordIndex = 0

    while True:
        coutput.print_debug(SB_ERR_DEBUG, _FUNC_NAME_, "activeWordIndexList :: {0}".format(spellBee.activeWordIndexList))
        coutput.print_debug(SB_ERR_DEBUG, _FUNC_NAME_, "activeWordIndex :: {0}".format(activeWordIndex))
        if (activeWordIndex < 0) or (activeWordIndex >= len(spellBee.activeWordIndexList)):
            break

        wordIndex = spellBee.activeWordIndexList[activeWordIndex]
        coutput.print_debug(SB_ERR_DEBUG, _FUNC_NAME_, "wordIndex :: {0}".format(wordIndex))

        # Lookup word definition
        spellBee.lookup_dictionary_by_index(wordIndex)
        spellBee.display_word_cue(SB_PRACTICE_WORD_DEFN_TITLE.format(INDEX=wordIndex + 1))
        userResponse = cinput.get_input("Enter spelling: ")

        # E[x]it test
        if userResponse.lower() == "x":
            break

        # [R]epeat question
        elif userResponse.lower() == "r":
            continue

        # Display [h]elp and statistics
        elif userResponse.lower() == "h":
            print SB_EMPTY_STRING
            spellBee.display_about()
            display_help("test")
            continue

        else:
            correctResponse = False

            # Process correct response
            if spellBee.valuate_test_response(userResponse, spellBee.activeWord, SB_TEST_MODE):
                correctResponse = True
                testValuation = SB_RIGHT_SYMBOL + " " + userResponse
                testCorrectCount += 1
            # Process incorrect response
            else:
                testValuation = SB_WRONG_SYMBOL + " " + userResponse
                spellBee.log_practice_word(spellBee.activeWord)

            # Indicate correct form of the answer, if different from the response
            if userResponse != spellBee.activeWord:
                testValuation = testValuation + " (" + spellBee.activeWord + ")"

            # Display valuation
            # Handle display text in ascii
            asciiTestValuation = testValuation.encode('utf-8')
            if correctResponse:
                coutput.print_color('green', " " * 50 + asciiTestValuation)
            else:
                coutput.print_color('red', " " * 50 + asciiTestValuation)
            
            # Save valuation
            spellBee.log_test_valuation(testValuation)

            # Move to next word
            activeWordIndex += 1
    
    spellBee.log_test_result(testDate, str(testCorrectCount) + "/" + str(testTotalCount))
    print "\nYour test is complete. Displaying results..."
    
    spellBee.display_evaluation_result('test', SB_TEST_SAVE_RESULT, savePracticeWordsEnabled)
Exemplo n.º 6
0
def run_practice(spellBee, practiceMode):

    userPracticeMode = practiceMode.strip().lower()

    if userPracticeMode == "study":
        spellBee.print_active_word_list()
    else:
        spellBee.display_about()
    display_help(userPracticeMode)
    userInput = cinput.get_keypress("\nReady to {0}? Press any key when ready ... ".format(userPracticeMode))

    activeWordIndex = 0

    while True:
        if (activeWordIndex < 0) or (activeWordIndex >= len(spellBee.activeWordIndexList)):
            break

        wordIndex = spellBee.activeWordIndexList[activeWordIndex]

        # Lookup word definition
        spellBee.lookup_dictionary_by_index(wordIndex)
        if userPracticeMode == "study":
            spellBee.display_word_cue(SB_STUDY_WORD_DEFN_TITLE.format(INDEX=wordIndex + 1, WORD=spellBee.wordList[wordIndex]))
        else:
            spellBee.display_word_cue(SB_PRACTICE_WORD_DEFN_TITLE.format(INDEX=wordIndex + 1))
        userInput = cinput.get_keypress(SB_PROMPT_SYMBOL)
        
        while True:
            # Move to [n]ext word
            if userInput.lower() == "n":
                activeWordIndex += 1
                break
            # Move to [p]revious word
            elif userInput.lower() == "p":
                activeWordIndex -= 1
                break
            # [R]epeat current word
            elif userInput.lower() == "r":
                if userPracticeMode == "study":
                    spellBee.display_word_cue(SB_STUDY_WORD_DEFN_TITLE.format(INDEX=wordIndex + 1, WORD=spellBee.wordList[wordIndex]))
                else:
                    spellBee.display_word_cue(SB_PRACTICE_WORD_DEFN_TITLE.format(INDEX=wordIndex + 1))
                userInput = cinput.get_keypress(SB_PROMPT_SYMBOL)
            # Re[v]iew active word list
            elif userInput.lower() == "v":
                print SB_EMPTY_STRING
                spellBee.print_active_word_list()
                userInput = cinput.get_keypress(SB_PROMPT_SYMBOL)
            # [S]how current word spelling
            elif userInput.lower() == "s":
                spellBee.display_word_cue(SB_STUDY_WORD_DEFN_TITLE.format(INDEX=wordIndex + 1, WORD=spellBee.wordList[wordIndex]))
                userInput = cinput.get_keypress(SB_PROMPT_SYMBOL)
            # [L]ookup word definition and pronunciation
            elif userInput.lower() == "l":
                userLookupWord = cinput.get_input("\nEnter word to be looked up: ")
                spellBee.lookup_all_dictionaries_by_word(userLookupWord)
                userInput = cinput.get_keypress(SB_PROMPT_SYMBOL)
            # Display [h]elp and statistics
            elif userInput.lower() == "h":
                print SB_EMPTY_STRING
                spellBee.display_about()
                display_help(userPracticeMode)
                userInput = cinput.get_keypress(SB_PROMPT_SYMBOL)
            # E[x]it application
            elif userInput.lower() == "x":
                exit_app()
            else:
                print "\nInvalid response."
                display_help(userPracticeMode)
                userInput = cinput.get_keypress(SB_PROMPT_SYMBOL)