This repository has been archived by the owner on May 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
GNOMEI18nTarget.py
124 lines (106 loc) · 4.44 KB
/
GNOMEI18nTarget.py
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
# Author : Simos Xenitellis <simos@gnome.org>, 2009
PROGNAME='gnome-i18n-manage-vcs'
PACKAGE_NAME = 'GNOME I18n Manage VCS'
PACKAGE_VERSION = '0.9'
PACKAGE_AUTHORS = ['Simos Xenitellis <simos@gnome.org>', 'Og Maciel <ogmaciel@gnome.org>']
PACKAGE_COPYRIGHT = 'Copyright 2009 Simos Xenitellis'
class GNOMEI18nTarget:
def __init__(self):
self.message_states = ['translated', 'untranslated', 'fuzzy', 'docfuzzy', 'docuntranslated', 'doctranslated']
self.flags = []
self.stats_release = None
self.stats_language = None
self.category_id = None
self.module_id = None
self.module_branch = None
self.domain = None
self.document = None
self.pofile = None
self.vcspath = None
self.resources = []
self.module = {}
self.category = {}
self.stats = {}
def start(self, tag, attrib):
if tag not in self.message_states:
if tag == 'domain':
self.domain = attrib['id']
elif tag == 'document':
self.document = attrib['id']
elif tag == 'module':
self.module_id = attrib['id']
self.module_branch = attrib['branch']
elif tag == 'category':
self.category_id = attrib['id']
elif tag == 'stats':
self.stats_release = attrib['release']
self.stats_language = attrib['language']
elif tag not in ['pofile', 'svnpath']:
# Should not be reached
#print self.tabs[:self.level], ('start %s %s' % (tag, attrib))
pass
self.push_flag(tag)
def end(self, tag):
if tag not in self.message_states:
if tag == 'domain':
self.resources.append({'id': tag, 'type': self.domain,
'pofile': self.pofile, 'vcspath' : self.vcspath })
self.domain = self.pofile = self.vcspath = None
elif tag == 'document':
self.resources.append({'id': tag, 'type': self.document,
'pofile': self.pofile, 'vcspath' : self.vcspath })
self.document = self.pofile = self.vcspath = None
elif tag == 'module':
self.module[self.module_id] = { 'branch': self.module_branch, 'resource': self.resources }
self.module_id = self.module_branch = None
self.resources = []
elif tag == 'category':
self.category[self.category_id] = self.module
self.module = {}
self.category_id = None
elif tag == 'stats':
self.stats = { 'language': self.stats_language, 'release': self.stats_release,
'categories': self.category }
self.category = {}
self.stats_release = self.stats_language = None
elif tag not in ['pofile', 'svnpath']:
# Should not be reached
#print self.tabs[:self.level], ('end %s' % tag)
pass
self.pop_flag(tag)
def data(self, data):
if not data.isspace() and not data.isdigit():
if self.flags[-1] == 'pofile':
self.pofile = data
elif self.flags[-1] == 'svnpath':
self.vcspath = data
else:
# Should not be reached
#print self.tabs[:self.level], ('data %r' % data)
pass
def comment(self, text):
pass
def close(self):
return True
def push_flag(self, tag):
self.flags.append(tag)
def pop_flag(self, tag):
if self.flags.pop() != tag:
print('ERROR, did not pop', tag)
def get_stats(self):
return self.stats