~ubuntu-branches/ubuntu/hoary/mailman/hoary-security

« back to all changes in this revision

Viewing changes to templates/ru/s2s.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2004-10-11 02:02:43 UTC
  • Revision ID: james.westby@ubuntu.com-20041011020243-ukiishnhlkmsoh21
Tags: upstream-2.1.5
ImportĀ upstreamĀ versionĀ 2.1.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/python
 
2
 
 
3
# A simple script to check the status of the translation.
 
4
 
 
5
import sys, string
 
6
from pprint import pprint
 
7
 
 
8
def chop (line):
 
9
    if line[-2:] == '\r\n':
 
10
        line = line[:-2]
 
11
 
 
12
    if line[-1:] == '\n':
 
13
        line = line[:-1]
 
14
 
 
15
    return line
 
16
 
 
17
def cmprevision (a, b):
 
18
    '''revisions are something delimited with dots'''
 
19
 
 
20
    return cmp (map (lambda x: x.lower (), a.split ('.')), map (lambda x: x.lower (), b.split ('.')))
 
21
 
 
22
name = None
 
23
revision = None
 
24
 
 
25
files = {}
 
26
 
 
27
for line in sys.stdin.readlines ():
 
28
    parts = string.split (chop (line))
 
29
 
 
30
    if len (parts) > 0:
 
31
        if parts[0] == 'File:':
 
32
            name = parts[1]
 
33
        elif parts[0] == 'Repository':
 
34
            files[name] = parts[2]
 
35
 
 
36
# pprint (files)
 
37
 
 
38
action = 0
 
39
 
 
40
for line in open ('status', 'r').readlines ():
 
41
    parts = string.split (chop (line))
 
42
 
 
43
    if len (parts) > 0:
 
44
        if files.has_key (parts[0]):
 
45
            pass    # check the version
 
46
 
 
47
            relation = cmprevision (parts[1], files[parts[0]])
 
48
 
 
49
            if relation < 0:
 
50
                print 'Update: %s (%s -> %s)' % (parts[0], parts[1], files[parts[0]])
 
51
                action = 1
 
52
            elif relation > 0:
 
53
                print 'Downgrade?: %s (%s -> %s)' % (parts[0], parts[1], files[parts[0]])
 
54
                action = 1
 
55
 
 
56
            del files[parts[0]] # delete the item
 
57
        else:
 
58
            print 'Delete:', parts[0]
 
59
            action = 1
 
60
 
 
61
for file in files.keys ():
 
62
    print 'New:', file
 
63
    action = 1
 
64
 
 
65
if not action:
 
66
    print 'You are translating the latest versions'