예제 #1
0
# how many incorrect guesses has the player made?
guesses = 0

# randomly select one of five words to play hangman
word = random.choice(["secret", "cucumber", "potpourri", "jumpoff", "queazy"])

# proxy is the placeholder text that hides the letters from the player
# if they haven't yet guessed a letter then proxy shows an underscore instead
proxy = ["_"] * len(word)

# clear the console
f.clear()

# play the intro text
f.intro()

# prompt the player to start the game
raw_input("\n\nPress ENTER when you are ready!")

# clear the console
f.clear()

# first drawing of the gallows!!
f.draw(guesses)

#print a playful message to the player
f.message(guesses, random.choice(m[guesses]))

# print out the hidden word proxy
# the proxy starts out as a string of underscores
예제 #2
0
from num2words import num2words
from random import randint
import functions

functions.intro()

numberAux = functions.getLanguage()
langShort = functions.setLang(numberAux)
langLarge = functions.findLang(langShort)

number = randint(0, 1001)
ordinal = functions.setOrdinal()

word = num2words(number, ordinal, langShort)

if ordinal:
    print(f"\nHow to write the ordinal {number} in {langLarge}?")
    resp = input()
else:
    print(f"\nHow to write the number {number} in {langLarge}?")
    resp = input()

print(f"\nRight answer: {word}")
print(f"Your  answer: {resp}\n")

if resp == word:
    print("You're right")
else:
    print("You're wrong")
예제 #3
0
# randomly select one of five words to play hangman
word = random.choice(["secret", "cucumber", "potpourri", "jumpoff", "queazy"])


# proxy is the placeholder text that hides the letters from the player
# if they haven't yet guessed a letter then proxy shows an underscore instead
proxy = ["_"] * len(word)


# clear the console
f.clear()


# play the intro text
f.intro()


# prompt the player to start the game
raw_input("\n\nPress ENTER when you are ready!")


# clear the console
f.clear()


# first drawing of the gallows!!
f.draw(guesses)


#print a playful message to the player
예제 #4
0
def main():
    functions.clear()
    if not functions.exists():
        try:
            functions.intro()
        except KeyboardInterrupt:
            functions.clear()
            import sys
            sys.exit(0)
    functions.clear()
    try:
        password = getpass.getpass("Password: "******"Invalid password")
        import sys
        sys.exit(1)
    while True:
        functions.clear()
        print("Vault")
        print(
            "Use Ctrl+C to return back to this menu, or use it here to exit.\n"
        )
        try:
            action = input(
                "1: Encrypt a file\n2: Download and encrypt a file from a URL\n3: Decrypt a file\n4: Change password\nSelect an option: "
            )
        except:
            break
        action = action.strip().lstrip()
        try:
            action = int(action)
        except:
            continue
        if action not in [1, 2, 3, 4]:
            continue
        if action == 1:
            functions.clear()
            try:
                path = input("Please specify a file to encrypt: ")
            except KeyboardInterrupt:
                continue
            if functions.validate(path) and not path.endswith(".png"):
                functions.clear()
                try:
                    response = input(
                        "This file may be a valid image file. Convert to .png (y/n)? "
                    )
                except KeyboardInterrupt:
                    continue
                if response.lower().lstrip().strip() == "y":
                    temp = path
                    path = functions.convert(path)
                    delete = input("Delete original file (y/n)? ")
                    if delete.lower().lstrip().strip() == "y":
                        if not windows:
                            temp = temp.replace("\\", "")
                        try:
                            directory = os.path.dirname(os.path.realpath(temp))
                            os.chdir(directory)
                            os.remove(temp)
                        except:
                            pass
            functions.clear()
            try:
                save = functions.encodepath(path)
                if save == None:
                    continue
            except Exception as e:
                print(str(e))
                try:
                    input("Invalid file path. Press enter to continue. ")
                except KeyboardInterrupt:
                    continue
                continue
            else:
                try:
                    input(
                        "File encrypted.\nEncrypted file path: {}\nPress enter to continue. "
                        .format(save))
                except KeyboardInterrupt:
                    continue
                continue

        elif action == 2:
            functions.clear()
            try:
                url = input("Please specify a file URL to download: ")
            except KeyboardInterrupt:
                continue

            name = os.path.split(url)[-1]
            base = os.path.dirname(os.path.realpath(__file__))
            path = os.path.join(base, name)
            functions.clear()

            try:
                r = requests.get(url, stream=True)
                with open(path, 'wb') as out_file:
                    shutil.copyfileobj(r.raw, out_file)
            except:
                try:
                    input("Invalid URL: {}\nPress enter to continue. ".format(
                        url))
                except KeyboardInterrupt:
                    continue
                continue
            if functions.validate(path) and not path.endswith(".png"):
                functions.clear()
                try:
                    response = input(
                        "This file may be a valid image file. Convert to .png (y/n)? "
                    )
                except KeyboardInterrupt:
                    continue
                if response.lower().lstrip().strip() == "y":
                    temp = path
                    path = functions.convert(path)
                    delete = input("Delete original file (y/n)? ")
                    if delete.lower().lstrip().strip() == "y":
                        if not windows:
                            temp = temp.replace("\\", "")
                        try:
                            directory = os.path.dirname(os.path.realpath(temp))
                            os.chdir(directory)
                            os.remove(temp)
                        except:
                            pass
            functions.clear()
            try:
                save = functions.encodepath(path)
            except:
                try:
                    input("Invalid file path. Press enter to continue. ")
                except KeyboardInterrupt:
                    continue
                continue
            else:
                try:
                    input(
                        "File encrypted.\nEncrypted file path: {}\nPress enter to continue. "
                        .format(save))
                except KeyboardInterrupt:
                    continue
                continue
        elif action == 3:
            functions.clear()
            try:
                path = input("Please specify a .enc file to decrypt: ")
            except KeyboardInterrupt:
                continue
            functions.clear()
            try:
                save = functions.decodepath(path)
            except Exception as e:
                print(str(e))
                try:
                    input("Invalid file path. Press enter to continue. ")
                except KeyboardInterrupt:
                    continue
                continue
            else:
                try:
                    input(
                        "File decrypted.\nDecrypted file path: {}\nPress enter to continue. "
                        .format(save))
                except KeyboardInterrupt:
                    continue
                continue
        elif action == 4:
            try:
                functions.clear()
                current = input("Current password: "******"Passwords do not match. Press enter to continue. ")
                    continue
                new = input("New password: "******"You will need to decrypt all files with your old password. Your new password will not be able to decrypt already encrypted files.\nRetype your password to confirm: "
                )
                if confirm != new:
                    input("Passwords do not match. Press enter to continue. ")
                    continue
                functions.writepw(new)
                functions.clear()
                input("Password changed to: {}.\nPress enter to continue. ".
                      format(new))
            except KeyboardInterrupt:
                continue

    functions.clear()
예제 #5
0
def main():
    func.intro()
    enc.checkIfStore()
    func.openPage(driver)
예제 #6
0
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 6 11:42:48 2019

@author: Kartik
"""
#importing libraries
import os as os

os.system('cls')  #clears screen before displaying ASCII art

import objects as obj
import functions as func

os.system('cls')  #clears screen again before initiating battle sequence

playAgain = "Y"  #to run the first instance

while playAgain == 'Y' or playAgain == 'y':
    func.intro()
    func.instance.score = 0
    obj.Player.gold = 0
    func.instance()
    func.store()
    func.end()
    break