~nilsschlupp/auto-ndiswrapper/rewrite

« back to all changes in this revision

Viewing changes to main/createdatabase.py

  • Committer: Nils Schlupp
  • Date: 2008-07-17 07:13:10 UTC
  • Revision ID: nils.schlupp@gmail.com-20080717071310-qskvk4y6r5c7ccr0
added new createdatabse script, still needs some polishing on multiline driver input, but its getting there

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
# creates database based on info from the ndiswrapper wiki
 
4
 
 
5
import urllib2
 
6
import sys
 
7
 
 
8
def get_lists():
 
9
        '''
 
10
        returns a list containing all the urls to lists on the ndiswrapper wiki
 
11
        '''
 
12
        front = urllib2.urlopen('http://ndiswrapper.sourceforge.net/joomla/index.php?/component/option,com_openwiki/Itemid,33/id,list/')
 
13
        front = front.read()
 
14
        front = front.split('<li class="level1"><div class="li"> <a href="')
 
15
        lists = []
 
16
        for i in front:
 
17
                if 'wikilink' in i:
 
18
                        lists.append(i.split('" class="wikilink1"')[0])
 
19
 
 
20
        return lists
 
21
 
 
22
 
 
23
def getdatabase():
 
24
        '''
 
25
        returns a dictionary containing the databse
 
26
        '''
 
27
        dbase = {}
 
28
        for url in get_lists():
 
29
                site = urllib2.urlopen(url)
 
30
                site = site.read()
 
31
                site = site.split('<li class="level1"><div class="li"> ')
 
32
                for i in site:
 
33
                        if 'pciid' in i:
 
34
                                pciid = ''
 
35
                                d = {}
 
36
                                i = i.split('</div>')
 
37
                                for j in i:
 
38
                                        if 'pciid' in j:
 
39
                                                pciid = j.split('pciid: ')[-1].strip()[:9]
 
40
                                        if 'Card' in j:
 
41
                                                d['name'] = j.split('Card: ')[-1]
 
42
                                        if 'Chipset: ' in j:
 
43
                                                d['chipset'] = j.split('Chipset: ')[-1]
 
44
                                        if 'Other: ' in j:
 
45
                                                d['other'] = j.split('Other: ')[-1]
 
46
                                        if 'Driver: ' in j:
 
47
                                                d['driver'] = j.split('<a href="')[-1].split('" class="urlextern"')[0]
 
48
                                if pciid != '' :
 
49
                                        dbase[pciid] = d
 
50
 
 
51
        return dbase
 
52
 
 
53
 
 
54
 
 
55
 
 
56
if __name__ == '__main__':
 
57
        print getdatabase()