/usr/share/gettext-lint/Equivalent.py is in gettext-lint 0.4-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | # -*- coding: utf-8 -*-
# Equivalents file class
#
# Pedro Morais <morais@kde.org>
# José Nuno Pires <jncp@netcabo.pt>
# (c) Copyright 2003, 2004
# Distributable under the terms of the GPL - see COPYING
class Equivalent:
def __init__(self):
self.map = None
def read_lines(self, filename):
try:
file = open(filename)
lines = file.readlines()
file.close()
return lines
except IOError:
return None
def parse(self, filename, strip = ''):
lines = self.read_lines(filename)
if lines == None: return 0
if self.map == None: self.map = {}
msgid = None
list = []
for i in lines:
i = i.strip()
for k in strip: i = i.replace(k, '')
if len(i) == 0:
if msgid != None and len(list) > 0: self.map[msgid] = list
msgid = None
list = []
elif msgid == None:
msgid = i
else:
list.append(i)
if msgid != None and len(list) > 0: self.map[msgid] = list
return 1
def check(self, msgid, result):
if self.map == None or not self.map.has_key(msgid): return 0
eq = self.map[msgid]
for i in result:
if not(i in eq): return 0
return 1
|