-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.py
More file actions
56 lines (45 loc) · 1.37 KB
/
Copy pathdata.py
File metadata and controls
56 lines (45 loc) · 1.37 KB
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
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
import string
from datetime import datetime
from random import SystemRandom, choice
class RandomData(object):
sys_random = SystemRandom()
numbers = ''.join(map(str, range(10)))
letters = string.letters
letter_and_digit = '%s%s' % (string.letters, string.digits)
@staticmethod
def get_int(start=0, stop=10, step=1):
return RandomData.sys_random.randrange(start, stop, step)
@staticmethod
def get_number(length=1):
ret = []
for i in range(length):
ret.append(choice(RandomData.numbers))
return ''.join(ret)
@staticmethod
def get_letter(length=1):
ret = []
for i in range(length):
ret.append(choice(RandomData.letters))
return ''.join(ret)
@staticmethod
def get_letter_digit(length=1):
ret = []
for i in range(length):
ret.append(choice(RandomData.letter_and_digit))
return ''.join(ret)
@staticmethod
def random_choice(seq):
return choice(seq)
@staticmethod
def current_year():
return datetime.now().strftime("%Y")
@staticmethod
def current_month():
return datetime.now().strftime("%m")
@staticmethod
def current_day():
return datetime.now().strftime("%d")
@staticmethod
def current_weekday():
return datetime.now().weekday() + 1