Esempio n. 1
0
    def handle(self, *args, **options):
        adjectives = options['adjectives']
        if adjectives:
            try:
                with open(adjectives, 'r') as f:
                    for line in f:
                        adj = Adjective(adjective=line)
                        adj.save()
                        self.stdout.write('Successfully added word %s' % adj)
            except IOError:
                raise CommandError('File "%s" does not exist' % adjectives)

        animals = options['animals']
        if animals:
            try:
                with open(animals, 'r') as f:
                    for line in f:
                        an = Animal(animal=line)
                        an.save()
                        self.stdout.write('Successfully added word %s' % an)
            except IOError:
                raise CommandError('File "%s" does not exist' % animals)

        words = options['words']
        if words:
            try:
                with open(words, 'r') as f:
                    for line in f:
                        word = Word(word=line)
                        word.save()
                        self.stdout.write('Successfully added word %s' % word)
            except IOError:
                raise CommandError('File "%s" does not exist' % words)
Esempio n. 2
0
 def handle(self, *args, **options):
     adjectives = options['adjectives']
     if adjectives:
         try:
             with open(adjectives, 'r') as f:
                 for line in f:
                     adj = Adjective(adjective=line)
                     adj.save()
                     self.stdout.write('Successfully added word %s' % adj)
         except IOError:
             raise CommandError('File "%s" does not exist' % adjectives)
     
     animals = options['animals']
     if animals:
         try:
             with open(animals, 'r') as f:
                 for line in f:
                     an = Animal(animal=line)
                     an.save()
                     self.stdout.write('Successfully added word %s' % an)
         except IOError:
              raise CommandError('File "%s" does not exist' % animals)
         
     words = options['words']
     if words:
         try:
             with open(words, 'r') as f:
                 for line in f:
                     word = Word(word=line)
                     word.save()
                     self.stdout.write('Successfully added word %s' % word)
         except IOError:
             raise CommandError('File "%s" does not exist' % words)
def populate_dict(apps, schema_editor):
    wordlist = ['woodcraft', 'woodcraft', 'woodcut', 'wooded', 'woof', 'wool',
                'woozy', 'word', 'work', 'world', 'worm',
                'vegetable', 'vehement', 'vehicle', 'version', 'versus',
                'vertigo', 'very', 'vesicle', 'vestige',
                'veto', 'vet', 'vex', 'via', 'vial', 'vibes', 'vibrant',
                'Emergent', 'delavan', 'palladized', 'noncorporeal',
                'parasynthesis', 'cancellation', 'uncourteousness', 'salishan',
                'unrequested', 'resistance',
                'avoirdupois', 'muhlenberg', 'hygienic', 'Nonjudicatory',
                'scenography', 'impartibility', 'unrounded',
                'thermography', 'diffusibility', 'diplomacy', 'filate',
                'stringy']
    for phrase in wordlist:
        theword = Word(word=phrase)
        theword.save()
Esempio n. 4
0
def save_words(request):
	if request.method == 'POST':
		form = WordForm(request.POST)
		if(form.is_valid()) :
			wordsInput = []
			for i in range(1, 11):
				word = form.cleaned_data["word" + str(i)].split()
				if(len(word) > 0):
					wordsInput.append(' '.join(word))
			for wordInput in wordsInput:
				if len(Word.objects.filter(word = wordInput)) == 0:
					wordNew = Word(word = wordInput)
					wordNew.save()
				word = Word.objects.get(word = wordInput)
				if len(UserWord.objects.filter(user = request.user, word = word)) == 0:
					userWordNew = UserWord(user = request.user, word = word)
					userWordNew.save()				
	return HttpResponseRedirect('/words/')