-
Notifications
You must be signed in to change notification settings - Fork 0
/
pep.py
42 lines (30 loc) · 779 Bytes
/
pep.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
# external
import random
# internal
import scrape
import pickler
def pick(fresh, used):
pepo = random.choice(fresh)
if pepo in used:
pick(fresh, used)
else:
used.append(pepo)
return pepo
return pepo
def prep(debug=True):
# scrape for current peps
fresh = scrape.peps()
# get used peps list (from pickle)
used = pickler.read('used.p')
# make sure that there are some unused peps, if not reset used list to empty
if used == fresh:
used = []
pep = pick(fresh, used)
# put away new list of used peps
pickler.pickleit('used.p', used)
# add rest of url to pep
pepo = 'https://www.python.org' + pep
if debug:
print('got the pep! {}'.format(pepo))
return pepo
prep()