-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfake_data.py
46 lines (32 loc) · 1.07 KB
/
fake_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import random
import string
class fakeString():
def __init__(self, length: int):
self.length = length
def genStr(self) -> str:
characters = string.ascii_letters + string.digits
myString = ''.join(random.choice(characters) for _ in range(self.length))
return myString
class fakeList(fakeString):
def __init__(self, length: int, count: int):
super().__init__(length)
self.count = count
def genList(self) -> list:
myList = []
fs = fakeString(self.length)
for _ in range(self.count):
myList.append(fs.genStr())
return myList
class fakeDicts(fakeList):
def __init__(self, length: int, count: int, field: str):
super().__init__(length, count)
self.field = field
def genDicts(self) -> list:
myList = []
fl = fakeList(self.length, self.count)
tmpList = fl.genList()
for item in tmpList:
tmpDict = {}
tmpDict[self.field] = item
myList.append(tmpDict)
return myList