示例#1
0
文件: users.py 项目: UDarya/TP
	def handle(self, *args, **options):
		names = {}
		while(len(names.keys())<int(options['users'])):
		    names[get_username(length=30)]=1
		i = 1
		cout1=1
		count = 1
		p_min = 1
		p_max=10000
		c = csv.writer(open("users.csv", "wb"))
		p = csv.writer(open("profiles.csv", "wb"))
		q = csv.writer(open("questions.csv", "wb"))
		a = csv.writer(open("answers.csv", "wb"))
		t = csv.writer(open("tags.csv", "wb"))
		qt = csv.writer(open("qt.csv", "wb"))
		for name in names.keys():
			c.writerow([datetime.now().strftime("%Y-%m-%d %H:%M:%S"), name, get_email(),random.randint(0,1),datetime.now().strftime("%Y-%m-%d %H:%M:%S")])
			p.writerow([i, random.randint(0,20)])
			i=i+1
		for j in range(0, int(options['questions'])):
			numb_word = 3
			lis = words(numb_word)
			q.writerow([random.randint(p_min,p_max),(sentence())[0:59],sentences(3),datetime.now().strftime("%Y-%m-%d %H:%M:%S")])
			for x in lis:
				t.writerow([x])
				qt.writerow([cout1,count])
				count = count+1
			cout1 = cout1+1
		for k in range(0, int(options['answers'])):
			a.writerow([sentences(3),datetime.now().strftime("%Y-%m-%d %H:%M:%S"),random.randint(0,1),random.randint(p_min,p_max),random.randint(p_min,100000)])
示例#2
0
    def handle(self, *args, **options):
        #print('hello')
        #print "USERS {} , Q :{}, A : {}".format(options['users'], options['questions'], options['answers'])
        names = {}
        while (len(names.keys()) < int(options['users'])):
            names[get_username(length=30)] = 1

        #print pformat(names)
        for name in names.keys():
            u = User.objects.create(username=name, email=get_email())
            p = Profile.objects.create(user_id=u.id,
                                       rating=random.randint(0, 20))

        for i in range(0, int(options['questions'])):
            tset = TextSet.objects.create(author_id=random.randint(1, 100),
                                          text=sentences(3),
                                          likes=random.randint(1, 100))
            q = Question.objects.create(title=(sentence())[0:59],
                                        text=tset,
                                        view_counter=0)

        #for i in range(0,int(options['upd'])):
        #Question.objects.filter(id>0).update(likes = random.randint(1, 100) )

        #title = (sentence())[0:10],
        count = Question.objects.count()
        print 'Count:' + str(count)
        for j in range(0, int(options['answers'])):
            q = Question.objects.get(id=random.randint(1, int(count)))
            tset = TextSet.objects.create(author_id=random.randint(1, 100),
                                          text=sentences(3),
                                          likes=random.randint(1, 100))
            a = Answer.objects.create(question=q,
                                      text=tset,
                                      view_counter=random.randint(1, 100))
示例#3
0
def create_card():
    return {
        "name":
        name.find_name(),
        "username":
        internet.user_name(),
        "email":
        internet.email(),
        "address": {
            "streetA": address.street_name(),
            "streetB": address.street_address(),
            "streetC": address.street_address(True),
            "streetD": address.secondary_address(),
            "city": address.city(),
            "ukCounty": address.uk_county(),
            "ukCountry": address.uk_country(),
            "zipcode": address.zip_code()
        },
        "phone":
        phone_number.phone_number(),
        "website":
        internet.domain_name(),
        "company": {
            "name": company.company_name(),
            "catchPhrase": company.catch_phrase(),
            "bs": company.bs()
        },
        "posts": [{
            "words": lorem.words(),
            "sentence": lorem.sentence(),
            "sentences": lorem.sentences(),
            "paragraph": lorem.paragraph()
        }, {
            "words": lorem.words(),
            "sentence": lorem.sentence(),
            "sentences": lorem.sentences(),
            "paragraph": lorem.paragraph()
        }, {
            "words": lorem.words(),
            "sentence": lorem.sentence(),
            "sentences": lorem.sentences(),
            "paragraph": lorem.paragraph()
        }]
    }
示例#4
0
文件: cards.py 项目: Papisou/Faker.py
def create_card():
    return {
        "name": name.find_name(),
        "username": internet.user_name(),
        "email": internet.email(),
        "address": {
            "streetA": address.street_name(),
            "streetB": address.street_address(),
            "streetC": address.street_address(True),
            "streetD": address.secondary_address(),
            "city": address.city(),
            "ukCounty": address.uk_county(),
            "ukCountry": address.uk_country(),
            "zipcode": address.zip_code()
        },
        "phone": phone_number.phone_number(),
        "website": internet.domain_name(),
        "company": {
            "name": company.company_name(),
            "catchPhrase": company.catch_phrase(),
            "bs": company.bs()
        },
        "posts": [
            {
                "words": lorem.words(),
                "sentence": lorem.sentence(),
                "sentences": lorem.sentences(),
                "paragraph": lorem.paragraph()
            },
            {
                "words": lorem.words(),
                "sentence": lorem.sentence(),
                "sentences": lorem.sentences(),
                "paragraph": lorem.paragraph()
            },
            {
                "words": lorem.words(),
                "sentence": lorem.sentence(),
                "sentences": lorem.sentences(),
                "paragraph": lorem.paragraph()
            }
        ]
    }
示例#5
0
    def handle(self, *args, **options):
        names = {}
        while(len(names.keys())<int(options['users'])):
            names[get_username(length=26)+str(random.randint(1950, 2015))]=1
        
        for name in names.keys():
            u = User.objects.create(username=name, email=get_email())
            p = Profile.objects.create(user_id=u.id, rating=random.randint(0,20))
        
        p_min = Profile.objects.all().aggregate(Min('id'))['id__min']
        p_max = Profile.objects.all().aggregate(Max('id'))['id__max']

        for i in range(0, int(options['questions'])):
            q = Question.objects.create(author_id=random.randint(p_min, p_max),
                title=(sentence())[0:59], text=sentences(3))

        q_min = Question.objects.all().aggregate(Min('id'))['id__min']
        q_max = Question.objects.all().aggregate(Max('id'))['id__max']

        for i in range(0, int(options['answers'])):
            a = Answer.objects.create(author_id=random.randint(p_min, p_max),
                question_id=random.randint(q_min, q_max), text=sentences(4))
示例#6
0
	def handle(self,*args,**options):
		
		names = {}
		while(len(names.keys())<int(options['users'])):
			names[get_username(length=random.randint(20,40))]=1

		for name in names.keys():
			u = User.objects.create(username=name+str(random.randint(0,1000)),email=get_email())
			p = Profile.objects.create(user_id=u.id,rating=random.randint(0,20))

		p_min = Profile.objects.all().aggregate(Min('id'))['id__min']
		p_max = Profile.objects.all().aggregate(Max('id'))['id__max']
		
		for k in range(0,int(options['tags'])):
			t = Tag.objects.create(name=word())			
		t_min = Tag.objects.all().aggregate(Min('id'))['id__min']
		t_max = Tag.objects.all().aggregate(Max('id'))['id__max']

		for i in range(0,int(options['questions'])):
			q = Question.objects.create(author_id=random.randint(p_min,p_max), title=(sentence())[0:59], text = sentences(3))
			for z in range(0, random.randint(0,10)):
                		q.tags.add(Tag.objects.get(id=random.randint(t_min, t_max)))

		q_min = Question.objects.all().aggregate(Min('id'))['id__min']
		q_max = Question.objects.all().aggregate(Max('id'))['id__max']
	
		for j in range(0,int(options['answers'])):
			a = Answer.objects.create(author_id=random.randint(p_min,p_max), question_id=random.randint(q_min,q_max), text= sentences(10), is_right=random.choice([True, False]))