~ubuntu-branches/ubuntu/maverick/hwdata/maverick

« back to all changes in this revision

Viewing changes to check_monitorsdb.py

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2009-01-15 14:40:13 UTC
  • mfrom: (1.1.8 upstream) (3.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090115144013-q8ficz3tr2ww4b5b
Tags: 0.220-1ubuntu1
* Merge from debian unstable, remaining changes: LP: #317407
  - Add new monitors to MonitorsDB

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
f = open("MonitorsDB", "r")
 
4
out = open("MonitorsDBOut", "w")
 
5
 
 
6
monIds = dict()
 
7
 
 
8
for line in f.readlines():
 
9
    if len(line.strip()) and not line.strip().startswith('#'):
 
10
        values = map(lambda x: x.strip(), line.split(';'))
 
11
        if len(values) < 5:
 
12
            print "This line contains two few values\n%s" % line
 
13
        manufacturer = values[0]
 
14
        model = values[1]
 
15
        monId = values[2]
 
16
        vGh = values[3]
 
17
        hGh = values[4]
 
18
        if len(manufacturer) == 0:
 
19
            print "This line doesn't contain Manufacturer\t%s" % line
 
20
            continue
 
21
        if len(model) == 0:
 
22
            print "This line contains empty model\t%s" % line
 
23
            continue
 
24
        if len(monId) == 0 or monId == "0":
 
25
            print "This line contains empty monitor Id\n%s" % line
 
26
            continue
 
27
        if len(vGh) == 0 or len(hGh) == 0:
 
28
            print "This line contains wrong Gh\t%s" % line
 
29
            continue
 
30
        if monIds.has_key(monId):
 
31
            print "Two line have the same monitor Ids\n%s%s" % (monIds[monId], line)
 
32
            continue
 
33
        else:
 
34
            monIds[monId] = line
 
35
    out.write(line)
 
36
f.close()
 
37
out.close()
 
38