File: make_kdepackages_updated.py

package info (click to toggle)
kde4libs 4:4.14.2-5+deb8u2
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 82,428 kB
  • ctags: 99,415
  • sloc: cpp: 761,864; xml: 12,344; ansic: 6,295; java: 4,060; perl: 2,938; yacc: 2,507; python: 1,207; sh: 1,179; ruby: 337; lex: 278; makefile: 29
file content (61 lines) | stat: -rw-r--r-- 1,761 bytes parent folder | download | duplicates (7)
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
# -*- coding: utf-8 -*-
#
# Script to automatically update the "kdepackages.h" file
# FIXME - This is a slow script. Rewrite me using a smart logic. Thanks!
#
import string
import urllib

def unescape(text):
    text = text.replace(" "," ")
    text = text.replace("‑","-")
    text = text.replace("&","&")
    return text


print "Fetching products and components from bugs.kde.org..."

pkg = open("kdepackages.h","w")
pkg.write("// DO NOT EDIT - EDIT bugs/Maintainers instead\n")
pkg.write("const char * const packages[] = {\n")

data = urllib.urlopen('http://bugs.kde.org/describecomponents.cgi').read()

for line in string.split(data,' '):
  if line.count("describecomponents.cgi") > 0:
    index1 = line.index("\">")+2
    product = line[index1:len(line)]
    index2 = product.index("<")
    product = product[0:index2]

    link = "describecomponents.cgi?product="
    index1 = line.index(link)
    link = line[index1:len(line)]
    index2 = link.index("\"")
    link = link[0:index2]

    link = 'http://bugs.kde.org/' + link
    data2 = urllib.urlopen(link).read()

    productname = unescape(product)
    print productname
    pkg.write("\"" + productname + "\",\n")
    data2 = string.split(data2,'\n')
    iter = 0
    end = len(data2)
    while( iter < end-1 ):
      iter = iter+1
      line = data2[iter]
      if line.count("<td rowspan=\"2\">")>0:
        iter = iter+1
        line = data2[iter]
        index1 = line.index("\">")+2
        product = line[index1:len(line)]
        index2 = product.index("<")
        product = unescape(product[0:index2])
        if product!="general":
          pkg.write("\"" + productname + "/" + product + "\",\n")
          print productname + "/" + product

pkg.write("0 };\n")
pkg.close()