-
Notifications
You must be signed in to change notification settings - Fork 1
/
gimme.py
72 lines (60 loc) · 1.63 KB
/
gimme.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from sys import argv
import sys
import random
import os.path
import os
def load_items_from_file(filename = 'gimme.txt'):
if (os.path.isfile(filename)):
contents = open(filename)
return contents.readlines()
return []
def add_item(item, filename = 'gimme.txt'):
if (item in items):
return
with open(filename, "a") as item_file:
item_file.write(item + '\n')
done = []
items = load_items_from_file()
def get_items(count = 0):
print "Getting %s items" % m
i = 0
while (len(items) != len(done)) and (i < count):
item = random.choice(items)
if (item not in done):
i = i + 1
done.append(item)
print "Item %d: %s" % (i, item),
input = ''
try:
filename, count = argv
m = int(float(count))
"""
Fix this
print argv
"""
get_items(m)
sys.exit(0)
except ValueError:
print 'Did not ask for items, continuing...'
while input != 'q' and input != 'x':
input = raw_input('\nWhat do you want to do? ')
if input == 'g' or input == 'l' or input == 'ls':
print 'Getting list...'
if os.path.exists('gimme.txt'):
filename = open('gimme.txt')
print filename.read()
else:
print "No file"
if input == 'n' or input == 'a':
new_item = raw_input("\nWhat do you wana add? ")
add_item(new_item)
load_items_from_file()
if input == 'd' or input == 'r':
exit_or_not = raw_input("Are you sure you want to delete your file?(y/n): ")
if exit_or_not =='y':
os.remove('gimme.txt')
print "deleted!"
if input == '-i' or input == 'info':
print """ g, l = get list \\ n, a = add \n d, r = delete \\ y, n = yes/no
"""
print 'exiting...'