def startRound(): global totalScore r = RandomWords() nextR = RandomWords() randomWord = r.get_random_word(hasDictionaryDef="true") if verifyWordHasAntonym(randomWord): userGuess(getAntonymList(randomWord), randomWord) else: startRound()
def start_game(): # Reset the session vars word = RandomWords().get_random_word(hasDictionaryDef=True, maxLength=12, minLength=5).lower() while not word.isalpha(): word = RandomWords().get_random_word(hasDictionaryDef=True, maxLength=12, minLength=5).lower() session['word'] = word session['correct_guesses'] = '' session['incorrect_guesses'] = '' return redirect("/guess", code=302)
def get_band_name(optional_word): r = RandomWords() random_word = str(r.get_random_word()) random_word2 = str(r.get_random_word()) and_the = "and the" band_name = optional_word + " " + and_the + " " + random_word + " " + random_word2 return band_name
def create_repositories(driver, n): r = RandomWords() words = list() for i in range(n): print('Creating repository number %d...' % (i+1)) words = r.get_random_words(maxLength=15, limit=2) print('Random words generated in iteration %d: %r' % (i, words)) composed_repository_name = 'orarepo' for item in words: composed_repository_name = composed_repository_name + '-' + item print('Composed repository name: ' + composed_repository_name) # Convert to lowercasxe composed_repository_name = composed_repository_name.lower() driver.get('https://github.com/new') # Now, in github.com/new repository_name = driver.find_element_by_name('repository[name]') repository_description = driver.find_element_by_name('repository[description]') repository_readme_init = driver.find_element_by_id('repository_auto_init') repository_private = driver.find_element_by_id('repository_visibility_private') repository_name.send_keys(composed_repository_name) repository_description.send_keys('%s, generated using Selenium automation by jasperan: https://github.com/jasperan/orarepo-creator' % composed_repository_name) repository_readme_init.click() repository_private.click() time.sleep(.5) repository_create = driver.find_element_by_xpath('//*[@id="new_repository"]/div[3]/button') repository_create.click() print('Successfully created repository number %d.' % (i+1))
def create(): if params["run"] == "dev": openerLink = "http://127.0.0.1:5500/l/" else: data = Config.query.filter_by(key="openerLink").first() openerLink = data.value if (request.method == 'POST'): custom = request.form.get('custom') link = request.form.get('link') regex = re.compile('[@_!#$%^&*()<>?/\|}{~:]') if (regex.search(custom) == None): if Links.query.filter_by(FLink=custom).first(): flash(u"Short Link already taken, please choose another!", category="danger") return redirect("/create") else: entry = Links(originalLink=link, FLink=custom) db.session.add(entry) db.session.commit() flash(u"Your short link for " + link + " is " + openerLink + custom, category="success") flash( u"The short link will not be saved, please notedown the link!", category="info") return redirect("/create") else: flash(u"[@_!#$%^&*()<>?/\|}{~:] characters are not valid!", category="danger") return redirect("/create") randomLink = RandomWords().get_random_word() return render_template('create.html', randomLink=randomLink)
def __init__(self): # Wrong guesses number self.index = 0 # Guessed letters self.guessed = [] # Word to be guessed self.word = RandomWords().get_random_word().upper()
def gen_word(): r = RandomWords() random_words = r.get_random_words() gen_random_number = random.randint(1, len(random_words)) #print(random_words[gen_random_number]) random_word = random_words[gen_random_number] return random_word
def getRandomWord(): if RandomWords is not None: r = RandomWords() return r.get_random_word() else: import random return str(random.randint(1000, 9999))
def Add_New_Milestone(self): r=RandomWords() name=r.get_random_word() self.driver.find_element_by_xpath(self.Addnewmilestone_button_xpath).click() self.driver.find_element_by_xpath(self.Name_text_xpath).send_keys(name) self.driver.find_element_by_xpath(self.Probabliity_text_xpath).send_keys('5') self.driver.find_element_by_xpath(self.Save_button_xpath).click()
def testing(): r = RandomWords() text = r.get_random_word() print("Testing using the word - " + text + "\n") for i in range(5,25,5): print(str(i) + " queries - " + str(test(text,i)) + " seconds") print("\n")
def main(): r = RandomWords() words = list() words = r.get_random_words(maxLength=15, limit=2) print('Random words: ', words) composed_repository_name = 'orarepo' for item in words: composed_repository_name = composed_repository_name + '-' + item print('Composed repository name: ' + composed_repository_name) # Convert to lowercasxe composed_repository_name = composed_repository_name.lower() # Now, we will initialize the repository in Github using os.system #location = input('Please introduce the pwd where you want to create the repositories:') #os.system('cd ' + location) os.system('mkdir /home/jasper/git/%s' % composed_repository_name) os.system('cd /home/jasper/git/%s' % composed_repository_name) os.system('git init /home/jasper/git/%s' % composed_repository_name) os.system('touch /home/jasper/git/%s/README.md' % composed_repository_name) os.system('echo %s >> /home/jasper/git/%s/README.md' % (composed_repository_name, composed_repository_name)) os.system('git add -A') os.system('git commit') os.system('git push --set-upstream origin master') #os.system('git remote add origin [email protected]/jasperan/%s' % composed_repository_name) os.system('git push')
async def word(ctx): dictionary = PyDictionary() while True: try: ranWord = RandomWords() word = ranWord.get_random_word(hasDictionaryDef="true") print(word) meaning = dictionary.meaning(word) synonyms = dictionary.synonym(word) antonyms = dictionary.antonym(word) break except Exception: pass cleanMeaning = str(meaning).replace('{', '').replace('[', '').replace( ']', '').replace('}', '').replace("'", '') cleanSyns = str(synonyms).replace('[', '').replace(']', '').replace("'", '') cleanAnt = str(antonyms).replace('[', '').replace(']', '').replace("'", '') wordEmbed = discord.Embed(title=f"Random Word - {word.capitalize()}", description=f"{cleanMeaning}\n", color=0xB87DDF) wordEmbed.add_field(name="Synonyms", value=cleanSyns) wordEmbed.add_field(name="Antonyms", value=cleanAnt) await ctx.channel.send(embed=wordEmbed)
def __init__(self, master): self.ranWordGen = RandomWords() print("check your internet connection!") master.title("Hangman") self.dashtext = StringVar() self.attempttext = StringVar() self.complicated = IntVar() self.dashes = Label(master, textvariable=self.dashtext) self.attempts = Label(master, textvariable=self.attempttext) self.dashes.pack() self.lives = IntVar() self.liveslabel = Label(master, textvariable=self.lives) self.liveslabel.pack() self.insert = Entry(master) self.insert.bind("<Return>", self.checkLetter) self.insert.pack() self.attempts.pack() self.newgame() self.playButton = Button(master, text="new Game", command=self.newgame) self.playButton.pack() self.quitButton = Button(master, text="quit", command=master.quit) self.quitButton.pack() self.ownwords = Checkbutton(master, text="random words", variable=self.complicated) self.ownwords.pack() self.insert.focus()
def generate_words(length): wordGenerator = RandomWords() print(length) word1 = wordGenerator.get_random_word(hasDictionaryDef='true', includePartOfSpeech='noun,adjective,verb', minCorpusCount=10000, excludePartOfSpeech='Pronoun,name', minLength=length, maxLength=length) word2 = wordGenerator.get_random_word(hasDictionaryDef='true', includePartOfSpeech='noun,adjective,verb', minCorpusCount=10000, excludePartOfSpeech='Pronoun,name', minLength=length, maxLength=length) print(word1, word2) return (word1,word2)
def fill_data(userinfo): name = driver.find_element_by_name("name") email = driver.find_element_by_name("email") title = driver.find_element_by_name("title") author = driver.find_element_by_name("author") genre = driver.find_element_by_name("genre") color = driver.find_element_by_name("color") keyword = driver.find_element_by_name("keyword") inspiration = driver.find_element_by_name("inspiration") remarks = driver.find_element_by_name("remarks") word = RandomWords() genre_array = [ 'Action', 'Adventure', 'Comedy', 'Drama', 'Fantasy', 'Horror', 'Romance', 'Tragedy' ] color_array = ['Red', 'Blue', 'Green', 'Yellow', 'Gray', 'Black', 'White'] genre_number = randrange(0, len(genre_array) - 1, 1) color_number = randrange(0, len(color_array) - 1, 1) new_title = word.get_random_word() name.send_keys(userinfo[0]) email.send_keys(userinfo[1]) title.send_keys(new_title) author.send_keys(userinfo[0]) genre.send_keys(genre_array[genre_number]) color.send_keys(color_array[color_number]) keyword.send_keys(word.get_random_word()) inspiration.send_keys("wwww.wrapyourbook.com") remarks.send_keys(word.get_random_word()) print("\nName of the book: " + new_title + "\n") print("Username: "******"User Email: " + userinfo[1] + "\n")
def generate_products(): """ generate a given number of products (default 30), randomly, and return them as a list """ # initialize list of noun and adj num_products = 30 products = [0] * num_products prices = [0] * num_products weights = [0] * num_products flammabilities = [0] * num_products # initlize random word object random = RandomWords() adj = [ random.get_random_word(includePartOfSpeech="adjective") for product in products ] noun = [ random.get_random_word(includePartOfSpeech="noun") for product in products ] products = [noun + " " + adj for noun, adj in zip(adj, noun)] prices = [random.randint(5, 100) for price in prices] weights = [random.randint(5, 100) for weight in weights] flammabilities = [ random.randint(0.0, 2.5) for flammability in flammabilities ] return products, prices, weights, flammabilities
def __init__(self, config): try: self.email = config['account'].split(':')[0] self.password = config['account'].split(':')[1] except: sys.exit(1) self.config = config self.randomWord = RandomWords() self.action = 'starting the oneCaptcha tool.' self.notification = None self.startTime = time.time() self.currentWatchTime = 0 self.completedSearches = 0 self.readStories = 0 self.currentTranslations = 0 self.completedEmailActions = 0 self.maxSearches = random.randint(int(self.config['settings']['min_searches']), int(self.config['settings']['max_searches'])) self.maxWatchTime = random.randint(int(self.config['settings']['min_watchTime']), int(self.config['settings']['max_watchTime'])) self.maxStories = random.randint(int(self.config['settings']['min_newsStories']), int(self.config['settings']['max_newsStories'])) self.maxTranslations = random.randint(int(self.config['settings']['min_translations']), int(self.config['settings']['max_translations'])) self.maxEmailActions = random.randint(int(self.config['settings']['min_emailActions']), int(self.config['settings']['max_emailActions'])) self.log = Logger(config['tid']).log
def __random_password_gen__(self): r = RandomWords() randomWords = r.get_random_words() print(randomWords) password = randomWords[0] + "-" + randomWords[1] + "-" + randomWords[ 2] + "-" + randomWords[3] return password
def get_word_to_guess(): try: r = RandomWords() words_list = r.get_random_words() word_to_guess = words_list[random.randint(0, len(words_list) - 1)].lower() except TypeError as e: print( "-----------------------------------------------------------------------------------------" ) print( "'random_word' module did not succesfully return a list of words. Picking one from the default list." ) print( "-----------------------------------------------------------------------------------------" ) default_words = [ "noiseless", "day", "boring", "holiday", "grieving", "subtract", "love", "whine", "bustling", "craven", "guttural", "muscle", "choke", "oatmeal", "shrill", "shade", "can", "hilarious", "discreet", "big" ] word_to_guess = default_words[random.randint(0, len(default_words) - 1)].lower() return word_to_guess
def f_wordget(): while True: word = RandomWords().get_random_word() if f_wordcheck(word) == True: word = word.lower() break return (word)
def index(request): singleword = 'hello' defination = '' translate = '' keys = '' values = '' word = '' if 'getword'in request.POST: r = RandomWords() dictionary = PyDictionary() word = r.get_random_word(hasDictionaryDef="true") wordone = word.replace('a','_') wordtwo = wordone.replace('e','_') wordthree = wordtwo.replace('i','_') singleword = wordthree.replace('o','_') try: defination = (dictionary.meaning(word)) values = defination.values() except: values = '' print(word) data = request.POST text = data['word'] print(text) if word == text: print('Hello') context = {'word': singleword,'defination':defination,'translate':translate,'values':values,'w':word} return render(request,'wordgame/game.html',context)
def generate_word(): rw = RandomWords() word = rw.get_random_word(hasDictionaryDef='true').upper() for i in word: if i == '-' or i == ' ': generate_word() return word
def get_a_new_word(): length = 4 r = RandomWords() word = '' while(len(word) !=length or does_contain_repeated_words(word)): word = r.get_random_word(hasDictionaryDef="true", includePartOfSpeech="verb", minLength=length, maxLength=length) return word
def getGibberishWords(n): gibberishWordsList = [] r = RandomWords() # For n entries for i in range(n): # Generate a random word and convert to Gibberish try: word = r.get_random_word() except: i = i - 1 continue print('Random Word:', word) # Following portion relates to word having more than one syllable ''''# Find all syllables in a word, then form gibberish word syllables = getAllSyllables(word) #gibberish = "" # Process each syllable #for syllable in syllables: ''' # Only single syllable words will be processed if syllable_count(word) > 1: print('Cannot process word having multiple syllables!') i = i - 1 continue gibberish = convertToGibberish(word) gibberishWordsList.append(gibberish) return gibberishWordsList
def main(): r = RandomWords() a = r.get_random_word() #generates random word print(a) good = [] #sotres correct guesses bad = [] #stores incorrect guesses for i in a: #adds underscores for each letter in the word so user can see good.append("_") guess = input("Enter a letter.\n") #user guesses a letter while len(bad) < 7: #user has total of 7 incorrect guesses if guess in good: #checks to see if user alreafy guessed a letter print("You've already guessed that letter.") if guess in bad: #removes guess from bad list if user already guessed it to avoid duplicates print("You've already guessed that letter.") bad.remove(guess) for i in range(len(a)): #iterates through letters of random word if a[i] == guess: #replaces underscore with letter of random word in good list good[i] = a[ i] #index of good aligns with the spelling of the random word if guess not in a: #adds incorrect guess to bad list print("No such letter.") bad.append(guess) if "_" not in good: #user wins if all the underscores in good list are gone print("Congratulaions! You've won. The word is", a) exit() print(good) #shows user their progress print("The incorrect letters you've guessed are", bad) guess = input("Enter another letter.\n") if len(bad) == 7: #user loses on 7th incorrect guess (hangman) print("You've lost. The word is", a)
def update_songs(cur, conn): #get a random word from rand word generator r = RandomWords() rw = r.get_random_word() #plug word into spotify and get list of songs get_artists(rw, cur, conn) get_songs(rw, cur, conn)
def create_list(length): r = RandomWords() list = [] for i in range(int(length)): list.append(r.get_random_word()) print(list) return list
def getWord(): try: rand = RandomWords() word = rand.get_random_word(hasDictionaryDef="true").lower() except: words = ["summer", "autumn", "winter", "spring"] word = words[random.randrange(0, words.__len__())] return word
def execute(self, context): from random_word import RandomWords r = RandomWords() word = r.get_random_word() bpy.ops.object.text_add() ob = bpy.context.object ob.data.body = word return {"FINISHED"}
def test_login_user_not_exists_error(self): selenium = self.selenium selenium.get('http://127.0.0.1:8000/accounts/user_login/') selenium.find_element_by_name('username').send_keys( RandomWords().get_random_word()) selenium.find_element_by_name('password').send_keys('badpass') selenium.find_element_by_name('login').click() assert 'LOGIN' in selenium.page_source