Ich habe heute einmal ein kleines Python-Skript geschrieben, das die PO-Dateien aus dem GNOME-SVN herunterlädt, die nach einem bestimmten Datum geändert worden sind.
./gnome-po-get 2008-07-20 liefert etwa alle PO-Dateien, die in der letzten Woche geändert worden sind. Wie man gut sehen kann, bin ich kein sonderlich begabter Python-Programmierer und das Skript muss noch stark in Bezug auf Parametrisierung und Robustheit verbessert werden; aber vielleicht ist das ja schon einmal ein Anfang. Kritik und Verbesserungsvorschläge sind stets willkommen. Mein Ziel ist es eigentlich, das Skript so weit auszubauen, dass die PO-Dateien dann automatisiert nach Launchpad hochgeladen werden. Ich habe zwar schon eine kleine Skript-Sammlung auch zum Hochladen von Jereon T. Vermeulen gefunden [1], aber so richtig verstanden habe ich die noch nicht (hab mich auch noch kaum damit beschäftigt). Solange das automatische Hochladen noch nicht funktioniert, wäre mein Vorschlag, dass ich einmal wöchentlich die von dem Skript identifizierten PO-Dateien nach Launchpad manuell hochlade. Spricht da irgendetwas dagegen? [1] https://launchpad.net/lp-translations-tools Besten Gruß, Jochen -- Jochen Skulj http://www.jochenskulj.de GPG Key-ID: 0x37B2F0B8 Finger Print: F239 5D8D 97CD F91F 9D08 AE94 AA3B 1ED5 37B2 F0B8
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Downloads the po files from the GNOME SVN which were changed after a given date Copyright (C) 2008 Jochen Skulj <[EMAIL PROTECTED]> Licensed under the GNU General Public License Version 2 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. """ __author__ = "Jochen Skulj <[EMAIL PROTECTED]>" __state__ = "experimental" import datetime import optparse import sys import time import urllib def get_language(): """ returns the language code Return: language code """ return "de" def get_modules(): """ returns a list of modulse Return: list of modules """ return ["accerciser", "alacarte", "anjuta", "at-spi", "atk", "bug-buddy", "brasero", "banshee", "cheese", "conduit", "dasher", "deskbar-applet", "devhelp", "eel", "ekiga", "empathy", "eog", "epiphany", "evince", "evolution", "evolution-data-server", "evolution-exchange", "evolution-webcal", "fast-user-switch-applet", "file-roller", "gail", "gcalctool", "gconf", "gconf-editor", "gdl", "gdm", "gedit", "glade3", "gnome-applets", "gnome-backgrounds", "gnome-build", "gnome-control-center", "gnome-desktop", "gnome-doc-utils", "gnome-games", "gnome-icon-theme", "gnome-keyring", "gnome-keyring-manager", "gnome-mag", "gnome-media", "gnome-menus", "gnome-netstatus", "gnome-nettool", "gnome-panel", "gnome-power-manager", "gnome-screensaver", "gnome-session", "gnome-settings-daemon", "gnome-system-monitor", "gnome-system-tools", "gnome-terminal", "gnome-themes", "gnome-utils", "gnome-vfs", "gnome-volume-manager", "gnopernicus", "gok", "gtk+", "gtk-engines", "gtkhtml", "gtksourceview", "gucharmap", "gvfs", "libbonobo", "libbonoboui", "libgnome", "libgnomecanvas", "libgnomekbd", "libgnomeprint", "libgnomeprintui", "libgnomeui", "libgtop", "libgweather", "libwnck", "metacity", "mousetweaks", "nautilus", "nautilus-cd-burner", "orca", "pessulus", "sabayon", "seahorse", "sound-juicer", "swfdec-gnome", "tomboy", "totem", "totem-pl-parser", "vinagre", "vino", "vte", "yelp", "zenity"] def create_url(language, module): """ creates the url to download the po file Parameters: language: language code module: module name Return: url of the po file """ return "http://l10n.gnome.org/POT/"+ module + ".HEAD/" + module + ".HEAD." + language + ".po" def download(url): """ downloads a file Parameters: url: url of the file to download Returns: content of the downloaded file """ content = urllib.urlopen(url).readlines() return content def string_to_date(string): """ converts a string to and date object Parameters: string: string containing a date in YYYY-MM-DD format Return: date object """ result = None try: result = datetime.datetime(*time.strptime(string +" 00:00:00", "%Y-%m-%d %H:%M:%S")[0:7]) except ValueError: print "Date Format Error: " + string result = None return result def get_timestamp(content): """ gets the timestamp of a downloaded file Parameters: content: content of a downloaded file Returns: timestamp: timestamp of the po file """ timestamp = None for line in content: if line.find("PO-Revision-Date") > -1: timestamp_str = line[19:29] print timestamp_str timestamp = string_to_date(timestamp_str) break return timestamp def save(module, content): """ saves a file Parameters: module: module name content: content to save """ output = open(module + ".po", "w") for line in content: output.write(line) output.close() def main(): """ main routine """ parser = optparse.OptionParser(version="0.1", usage="gnome-po-get YYYY-MM-DD") (options, args) = parser.parse_args() if len(args) != 1: print "ERROR: You have to specify a date in the format\n" parser.print_help() sys.exit(1) date = string_to_date(args[0]) if date == None: sys.exit(1) language = get_language() for module in get_modules(): print "Downloading " + module + "..." url = create_url(language, module) content = download(url) timestamp = get_timestamp(content) if timestamp >= date: print "Saving " + module + "..." save(module, content) if __name__ == "__main__": main()
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
_______________________________________________ Translators-de mailing list [email protected] https://eshu.ubuntu-eu.org/mailman/listinfo/translators-de
