-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstorage.py
43 lines (35 loc) · 1.31 KB
/
storage.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
import os
import time
import newegg
import graph
import best
types = [
('hdd', [(None, (2010150014,))]),
('laptop_hdd', [(None, (2010150380,))]),
('flash', [
("SD", (2010170068, '531:7930', '531:25651', '531:57101', '531:17056')),
("MicroSD", (2010170068, '531:31144', '531:18914')),
("CF", (2010170068, '531:7923')),
]),
('usb', [(None, (2013240522,))]),
('ssd', [
('Normal', (dict(N=100008120, IsNodeId=1),)),
('External', (dict(N=100011690, IsNodeId=1),)),
('Enterprise', (dict(N=100011691, IsNodeId=1),)),
]),
('enclosure', [
('3.5 inch', (2010150414, '360:7800')),
('2.5 inch', (2010150414, '360:7801')),
]),
]
result_dir = os.path.join(os.path.dirname(__file__), "result")
for name, subtypes in types:
t = time.time()
print
print name
print 'Scraping'
items = dict((subname, list(newegg.get(*call))) for subname, call in subtypes)
print 'Graphing'
graph.graph([(subname, [(item[0], item[0]/item[1]) for item in items[subname]]) for subname, call in subtypes], os.path.join(result_dir, name + '.png'))
print 'Itemizing'
best.best(name, [(subname, items[subname]) for subname, call in subtypes], os.path.join(result_dir, name + '.txt'), t, os.path.join(result_dir, 'record.txt'))