[ubuntu-l10n-it] Re: Un piccolo script per la documentazione.

  • From: Leo Iannacone <leo.iannacone@xxxxxxxxx>
  • To: ubuntu-l10n-it@xxxxxxxxxxxxx
  • Date: Mon, 16 Mar 2009 21:14:18 +0100

Mi sono scordato di allegare il file.

Eccolo...
#!/usr/bin/env python

""" 
        A simple script that reads translation infos about ubuntu-docs project
        Author: http://launchpad.net/l3on 
        Thanks to http://launchpad.net/gaspa for some issues
"""

from os import system
from re import findall
from urllib import urlopen


# Modify these variables if you need
language = "it"
language_str = "Italian"
release = "jaunty"


project = "ubuntu-docs"
launchpad = "https://translations.launchpad.net";
base_url = "%s/ubuntu/%s/+source/%s/" % (launchpad,release,project)

base_data = urlopen(base_url).read()

projects = findall('<td><a href="(.*)">',base_data)

template = '''
<html>
<head>
<link href="https://launchpad.net/+icing/rev7767/+style-slimmer.css"; 
type="text/css" rel="stylesheet">
</head>
<body>
<table id="language-chart" class="sortable listing" width="100%%">
<thead>
        <tr>
        <th>%s</th>
        <th>Status</th>
        <th>Untranslated</th>
        <th>Need review</th>
        <th>Changed</th>
        <th>Last Edited</th>
        <th>By</th>
        </tr>
</thead>

<tbody>
%s
</tbody>
</table>
</body>
</html>
'''


html = ''

for proj in projects:
        proj_data = urlopen(launchpad+proj).read()
        proj = proj.replace('/ubuntu/%s/+source/%s/+pots/' % 
(release,project),'')
        proj_html = proj_data.split('%s_%s">' % 
(proj,language))[1].split('</tr>')[0].replace('href="','href="%s' % 
launchpad).replace('src="','src="%s' % launchpad).replace(language_str,proj)

        html += '<tr>%s</tr>\n' % proj_html

print template % (language_str, html)
        

Other related posts: