author | Michel Szarindar <Michel.Szarindar@Nokia.com> |
Thu, 18 Mar 2010 18:26:18 +0000 | |
changeset 1 | 82f11024044a |
parent 0 | 42188c7ea2d9 |
child 4 | 468f4c8d3d5b |
permissions | -rw-r--r-- |
0
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1 |
"""Script to generate reports on translator classes from Doxygen sources. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
2 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
3 |
The main purpose of the script is to extract the information from sources |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
4 |
related to internationalization (the translator classes). It uses the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
5 |
information to generate documentation (language.doc, |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
6 |
translator_report.txt) from templates (language.tpl, maintainers.txt). |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
7 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
8 |
Simply run the script without parameters to get the reports and |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
9 |
documentation for all supported languages. If you want to generate the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
10 |
translator report only for some languages, pass their codes as arguments |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
11 |
to the script. In that case, the language.doc will not be generated. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
12 |
Example: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
13 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
14 |
python translator.py en nl cz |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
15 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
16 |
Originally, the script was written in Perl and was known as translator.pl. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
17 |
The last Perl version was dated 2002/05/21 (plus some later corrections) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
18 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
19 |
$Id: translator.py 708 2009-10-04 20:20:24Z dimitri $ |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
20 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
21 |
Petr Prikryl (prikrylp@skil.cz) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
22 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
23 |
History: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
24 |
-------- |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
25 |
2002/05/21 - This was the last Perl version. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
26 |
2003/05/16 - List of language marks can be passed as arguments. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
27 |
2004/01/24 - Total reimplementation started: classes TrManager, and Transl. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
28 |
2004/02/05 - First version that produces translator report. No language.doc yet. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
29 |
2004/02/10 - First fully functional version that generates both the translator |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
30 |
report and the documentation. It is a bit slower than the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
31 |
Perl version, but is much less tricky and much more flexible. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
32 |
It also solves some problems that were not solved by the Perl |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
33 |
version. The translator report content should be more useful |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
34 |
for developers. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
35 |
2004/02/11 - Some tuning-up to provide more useful information. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
36 |
2004/04/16 - Added new tokens to the tokenizer (to remove some warnings). |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
37 |
2004/05/25 - Added from __future__ import generators not to force Python 2.3. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
38 |
2004/06/03 - Removed dependency on textwrap module. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
39 |
2004/07/07 - Fixed the bug in the fill() function. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
40 |
2004/07/21 - Better e-mail mangling for HTML part of language.doc. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
41 |
- Plural not used for reporting a single missing method. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
42 |
- Removal of not used translator adapters is suggested only |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
43 |
when the report is not restricted to selected languages |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
44 |
explicitly via script arguments. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
45 |
2004/07/26 - Better reporting of not-needed adapters. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
46 |
2004/10/04 - Reporting of not called translator methods added. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
47 |
2004/10/05 - Modified to check only doxygen/src sources for the previous report. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
48 |
2005/02/28 - Slight modification to generate "mailto.txt" auxiliary file. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
49 |
2005/08/15 - Doxygen's root directory determined primarily from DOXYGEN |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
50 |
environment variable. When not found, then relatively to the script. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
51 |
2007/03/20 - The "translate me!" searched in comments and reported if found. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
52 |
2008/06/09 - Warning when the MAX_DOT_GRAPH_HEIGHT is still part of trLegendDocs(). |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
53 |
2009/05/09 - Changed HTML output to fit it with XHTML DTD |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
54 |
2009/09/02 - Added percentage info to the report (implemented / to be implemented). |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
55 |
""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
56 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
57 |
from __future__ import generators |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
58 |
import os, re, sys |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
59 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
60 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
61 |
def fill(s): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
62 |
"""Returns string formated to the wrapped paragraph multiline string. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
63 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
64 |
Replaces whitespaces by one space and then uses he textwrap.fill().""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
65 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
66 |
# Replace all whitespace by spaces, remove whitespaces that are not |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
67 |
# necessary, strip the left and right whitespaces, and break the string |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
68 |
# to list of words. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
69 |
rexWS = re.compile(r'\s+') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
70 |
lst = rexWS.sub(' ', s).strip().split() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
71 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
72 |
# If the list is not empty, put the words together and form the lines |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
73 |
# of maximum 70 characters. Build the list of lines. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
74 |
lines = [] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
75 |
if lst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
76 |
line = lst.pop(0) # no separation space in front of the first word |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
77 |
for word in lst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
78 |
if len(line) + len(word) < 70: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
79 |
line += ' ' + word |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
80 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
81 |
lines.append(line) # another full line formed |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
82 |
line = word # next line started |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
83 |
lines.append(line) # the last line |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
84 |
return '\n'.join(lines) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
85 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
86 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
87 |
# The following function dedent() is the verbatim copy from the textwrap.py |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
88 |
# module. The textwrap.py was introduced in Python 2.3. To make this script |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
89 |
# working also in older Python versions, I have decided to copy it. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
90 |
# Notice that the textwrap.py is copyrighted: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
91 |
# |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
92 |
# Copyright (C) 1999-2001 Gregory P. Ward. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
93 |
# Copyright (C) 2002, 2003 Python Software Foundation. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
94 |
# Written by Greg Ward <gward@python.net> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
95 |
# |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
96 |
# The explicit permission to use the code here was sent by Guido van Rossum |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
97 |
# (4th June, 2004). |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
98 |
# |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
99 |
def dedent(text): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
100 |
"""dedent(text : string) -> string |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
101 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
102 |
Remove any whitespace than can be uniformly removed from the left |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
103 |
of every line in `text`. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
104 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
105 |
This can be used e.g. to make triple-quoted strings line up with |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
106 |
the left edge of screen/whatever, while still presenting it in the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
107 |
source code in indented form. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
108 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
109 |
For example: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
110 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
111 |
def test(): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
112 |
# end first line with \ to avoid the empty line! |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
113 |
s = '''\ |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
114 |
hello |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
115 |
world |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
116 |
''' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
117 |
print repr(s) # prints ' hello\n world\n ' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
118 |
print repr(dedent(s)) # prints 'hello\n world\n' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
119 |
""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
120 |
lines = text.expandtabs().split('\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
121 |
margin = None |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
122 |
for line in lines: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
123 |
content = line.lstrip() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
124 |
if not content: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
125 |
continue |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
126 |
indent = len(line) - len(content) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
127 |
if margin is None: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
128 |
margin = indent |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
129 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
130 |
margin = min(margin, indent) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
131 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
132 |
if margin is not None and margin > 0: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
133 |
for i in range(len(lines)): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
134 |
lines[i] = lines[i][margin:] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
135 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
136 |
return '\n'.join(lines) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
137 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
138 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
139 |
class Transl: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
140 |
"""One instance is build for each translator. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
141 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
142 |
The abbreviation of the source file--part after 'translator_'--is used as |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
143 |
the identification of the object. The empty string is used for the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
144 |
abstract Translator class from translator.h. The other information is |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
145 |
extracted from inside the source file.""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
146 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
147 |
def __init__(self, fname, manager): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
148 |
"""Bind to the manager and initialize.""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
149 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
150 |
# Store the filename and the reference to the manager object. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
151 |
self.fname = fname |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
152 |
self.manager = manager |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
153 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
154 |
# The instance is responsible for loading the source file, so it checks |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
155 |
# for its existence and quits if something goes wrong. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
156 |
if not os.path.isfile(fname): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
157 |
sys.stderr.write("\a\nFile '%s' not found!\n" % fname) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
158 |
sys.exit(1) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
159 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
160 |
# Initialize the other collected information. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
161 |
self.classId = None |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
162 |
self.baseClassId = None |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
163 |
self.readableStatus = None # 'up-to-date', '1.2.3', '1.3', etc. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
164 |
self.status = None # '', '1.2.03', '1.3.00', etc. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
165 |
self.lang = None # like 'Brasilian' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
166 |
self.langReadable = None # like 'Brasilian Portuguese' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
167 |
self.note = None # like 'should be cleaned up' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
168 |
self.prototypeDic = {} # uniPrototype -> prototype |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
169 |
self.translateMeText = 'translate me!' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
170 |
self.translateMeFlag = False # comments with "translate me!" found |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
171 |
self.txtMAX_DOT_GRAPH_HEIGHT_flag = False # found in string in trLegendDocs() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
172 |
self.obsoleteMethods = None # list of prototypes to be removed |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
173 |
self.missingMethods = None # list of prototypes to be implemented |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
174 |
self.implementedMethods = None # list of implemented required methods |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
175 |
self.adaptMinClass = None # The newest adapter class that can be used |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
176 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
177 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
178 |
def __tokenGenerator(self): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
179 |
"""Generator that reads the file and yields tokens as 4-tuples. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
180 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
181 |
The tokens have the form (tokenId, tokenString, lineNo). The |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
182 |
last returned token has the form ('eof', None, None). When trying |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
183 |
to access next token afer that, the exception would be raised.""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
184 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
185 |
# Set the dictionary for recognizing tokenId for keywords, separators |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
186 |
# and the similar categories. The key is the string to be recognized, |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
187 |
# the value says its token identification. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
188 |
tokenDic = { 'class': 'class', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
189 |
'const': 'const', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
190 |
'public': 'public', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
191 |
'protected': 'protected', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
192 |
'private': 'private', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
193 |
'static': 'static', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
194 |
'virtual': 'virtual', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
195 |
':': 'colon', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
196 |
';': 'semic', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
197 |
',': 'comma', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
198 |
'[': 'lsqbra', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
199 |
']': 'rsqbra', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
200 |
'(': 'lpar', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
201 |
')': 'rpar', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
202 |
'{': 'lcurly', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
203 |
'}': 'rcurly', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
204 |
'=': 'assign', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
205 |
'*': 'star', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
206 |
'&': 'amp', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
207 |
'+': 'plus', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
208 |
'-': 'minus', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
209 |
'!': 'excl', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
210 |
'?': 'qmark', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
211 |
'<': 'lt', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
212 |
'>': 'gt', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
213 |
"'": 'quot', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
214 |
'"': 'dquot', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
215 |
'.': 'dot', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
216 |
'%': 'perc', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
217 |
'~': 'tilde', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
218 |
'^': 'caret', |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
219 |
} |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
220 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
221 |
# Regular expression for recognizing identifiers. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
222 |
rexId = re.compile(r'^[a-zA-Z]\w*$') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
223 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
224 |
# Open the file for reading and extracting tokens until the eof. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
225 |
# Initialize the finite automaton. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
226 |
f = file(self.fname) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
227 |
lineNo = 0 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
228 |
line = '' # init -- see the pos initialization below |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
229 |
linelen = 0 # init |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
230 |
pos = 100 # init -- pos after the end of line |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
231 |
status = 0 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
232 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
233 |
tokenId = None # init |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
234 |
tokenStr = '' # init -- the characters will be appended. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
235 |
tokenLineNo = 0 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
236 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
237 |
while status != 777: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
238 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
239 |
# Get the next character. Read next line first, if necessary. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
240 |
if pos < linelen: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
241 |
c = line[pos] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
242 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
243 |
lineNo += 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
244 |
line = f.readline() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
245 |
linelen = len(line) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
246 |
pos = 0 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
247 |
if line == '': # eof |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
248 |
status = 777 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
249 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
250 |
c = line[pos] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
251 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
252 |
# Consume the character based on the status |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
253 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
254 |
if status == 0: # basic status |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
255 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
256 |
# This is the initial status. If tokenId is set, yield the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
257 |
# token here and only here (except when eof is found). |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
258 |
# Initialize the token variables after the yield. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
259 |
if tokenId: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
260 |
# If it is an unknown item, it can still be recognized |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
261 |
# here. Keywords and separators are the example. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
262 |
if tokenId == 'unknown': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
263 |
if tokenDic.has_key(tokenStr): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
264 |
tokenId = tokenDic[tokenStr] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
265 |
elif tokenStr.isdigit(): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
266 |
tokenId = 'num' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
267 |
elif rexId.match(tokenStr): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
268 |
tokenId = 'id' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
269 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
270 |
msg = '\aWarning: unknown token "' + tokenStr + '"' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
271 |
msg += '\tfound on line %d' % tokenLineNo |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
272 |
msg += ' in "' + self.fname + '".\n' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
273 |
sys.stderr.write(msg) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
274 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
275 |
yield (tokenId, tokenStr, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
276 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
277 |
# If it is a comment that contains the self.translateMeText |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
278 |
# string, set the flag -- the situation will be reported. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
279 |
if tokenId == 'comment' and tokenStr.find(self.translateMeText) >= 0: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
280 |
self.translateMeFlag = True |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
281 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
282 |
tokenId = None |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
283 |
tokenStr = '' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
284 |
tokenLineNo = 0 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
285 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
286 |
# Now process the character. When we just skip it (spaces), |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
287 |
# stay in this status. All characters that will be part of |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
288 |
# some token cause moving to the specific status. And only |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
289 |
# when moving to the status == 0 (or the final state 777), |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
290 |
# the token is yielded. With respect to that the automaton |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
291 |
# behaves as Moore's one (output bound to status). When |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
292 |
# collecting tokens, the automaton is the Mealy's one |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
293 |
# (actions bound to transitions). |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
294 |
if c.isspace(): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
295 |
pass # just skip whitespace characters |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
296 |
elif c == '/': # Possibly comment starts here, but |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
297 |
tokenId = 'unknown' # it could be only a slash in code. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
298 |
tokenStr = c |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
299 |
tokenLineNo = lineNo |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
300 |
status = 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
301 |
elif c == '#': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
302 |
tokenId = 'preproc' # preprocessor directive |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
303 |
tokenStr = c |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
304 |
tokenLineNo = lineNo |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
305 |
status = 5 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
306 |
elif c == '"': # string starts here |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
307 |
tokenId = 'string' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
308 |
tokenStr = c |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
309 |
tokenLineNo = lineNo |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
310 |
status = 6 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
311 |
elif c == "'": # char literal starts here |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
312 |
tokenId = 'charlit' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
313 |
tokenStr = c |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
314 |
tokenLineNo = lineNo |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
315 |
status = 8 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
316 |
elif tokenDic.has_key(c): # known one-char token |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
317 |
tokenId = tokenDic[c] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
318 |
tokenStr = c |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
319 |
tokenLineNo = lineNo |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
320 |
# stay in this state to yield token immediately |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
321 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
322 |
tokenId = 'unknown' # totally unknown |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
323 |
tokenStr = c |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
324 |
tokenLineNo = lineNo |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
325 |
status = 333 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
326 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
327 |
pos += 1 # move position in any case |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
328 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
329 |
elif status == 1: # possibly a comment |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
330 |
if c == '/': # ... definitely the C++ comment |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
331 |
tokenId = 'comment' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
332 |
tokenStr += c |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
333 |
pos += 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
334 |
status = 2 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
335 |
elif c == '*': # ... definitely the C comment |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
336 |
tokenId = 'comment' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
337 |
tokenStr += c |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
338 |
pos += 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
339 |
status = 3 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
340 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
341 |
status = 0 # unrecognized, don't move pos |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
342 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
343 |
elif status == 2: # inside the C++ comment |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
344 |
if c == '\n': # the end of C++ comment |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
345 |
status = 0 # yield the token |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
346 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
347 |
tokenStr += c # collect the C++ comment |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
348 |
pos += 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
349 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
350 |
elif status == 3: # inside the C comment |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
351 |
if c == '*': # possibly the end of the C comment |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
352 |
tokenStr += c |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
353 |
status = 4 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
354 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
355 |
tokenStr += c # collect the C comment |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
356 |
pos += 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
357 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
358 |
elif status == 4: # possibly the end of the C comment |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
359 |
if c == '/': # definitely the end of the C comment |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
360 |
tokenStr += c |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
361 |
status = 0 # yield the token |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
362 |
elif c == '*': # more stars inside the comment |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
363 |
tokenStr += c |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
364 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
365 |
tokenStr += c # this cannot be the end of comment |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
366 |
status = 3 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
367 |
pos += 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
368 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
369 |
elif status == 5: # inside the preprocessor directive |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
370 |
if c == '\n': # the end of the preproc. command |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
371 |
status = 0 # yield the token |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
372 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
373 |
tokenStr += c # collect the preproc |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
374 |
pos += 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
375 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
376 |
elif status == 6: # inside the string |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
377 |
if c == '\\': # escaped char inside the string |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
378 |
tokenStr += c |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
379 |
status = 7 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
380 |
elif c == '"': # end of the string |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
381 |
tokenStr += c |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
382 |
status = 0 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
383 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
384 |
tokenStr += c # collect the chars of the string |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
385 |
pos += 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
386 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
387 |
elif status == 7: # escaped char inside the string |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
388 |
tokenStr += c # collect the char of the string |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
389 |
status = 6 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
390 |
pos += 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
391 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
392 |
elif status == 8: # inside the char literal |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
393 |
tokenStr += c # collect the char of the literal |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
394 |
status = 9 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
395 |
pos += 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
396 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
397 |
elif status == 9: # end of char literal expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
398 |
if c == "'": # ... and found |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
399 |
tokenStr += c |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
400 |
status = 0 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
401 |
pos += 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
402 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
403 |
tokenId = 'error' # end of literal was expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
404 |
tokenStr += c |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
405 |
status = 0 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
406 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
407 |
elif status == 333: # start of the unknown token |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
408 |
if c.isspace(): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
409 |
pos += 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
410 |
status = 0 # tokenId may be determined later |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
411 |
elif tokenDic.has_key(c): # separator, don't move pos |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
412 |
status = 0 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
413 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
414 |
tokenStr += c # collect |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
415 |
pos += 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
416 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
417 |
# We should have finished in the final status. If some token |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
418 |
# have been extracted, yield it first. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
419 |
assert(status == 777) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
420 |
if tokenId: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
421 |
yield (tokenId, tokenStr, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
422 |
tokenId = None |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
423 |
tokenStr = '' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
424 |
tokenLineNo = 0 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
425 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
426 |
# The file content is processed. Close the file. Then always yield |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
427 |
# the eof token. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
428 |
f.close() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
429 |
yield ('eof', None, None) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
430 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
431 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
432 |
def __collectClassInfo(self, tokenIterator): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
433 |
"""Collect the information about the class and base class. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
434 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
435 |
The tokens including the opening left curly brace of the class are |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
436 |
consumed.""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
437 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
438 |
status = 0 # initial state |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
439 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
440 |
while status != 777: # final state |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
441 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
442 |
# Always assume that the previous tokens were processed. Get |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
443 |
# the next one. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
444 |
tokenId, tokenStr, tokenLineNo = tokenIterator.next() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
445 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
446 |
# Process the token and never return back. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
447 |
if status == 0: # waiting for the 'class' keyword. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
448 |
if tokenId == 'class': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
449 |
status = 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
450 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
451 |
elif status == 1: # expecting the class identification |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
452 |
if tokenId == 'id': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
453 |
self.classId = tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
454 |
status = 2 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
455 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
456 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
457 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
458 |
elif status == 2: # expecting the curly brace or base class info |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
459 |
if tokenId == 'lcurly': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
460 |
status = 777 # correctly finished |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
461 |
elif tokenId == 'colon': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
462 |
status = 3 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
463 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
464 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
465 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
466 |
elif status == 3: # expecting the 'public' in front of base class id |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
467 |
if tokenId == 'public': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
468 |
status = 4 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
469 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
470 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
471 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
472 |
elif status == 4: # expecting the base class id |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
473 |
if tokenId == 'id': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
474 |
self.baseClassId = tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
475 |
status = 5 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
476 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
477 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
478 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
479 |
elif status == 5: # expecting the curly brace and quitting |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
480 |
if tokenId == 'lcurly': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
481 |
status = 777 # correctly finished |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
482 |
elif tokenId == 'comment': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
483 |
pass |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
484 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
485 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
486 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
487 |
# Extract the status of the TranslatorXxxx class. The readable form |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
488 |
# will be used in reports the status form is a string that can be |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
489 |
# compared lexically (unified length, padding with zeros, etc.). |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
490 |
if self.baseClassId: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
491 |
lst = self.baseClassId.split('_') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
492 |
if lst[0] == 'Translator': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
493 |
self.readableStatus = 'up-to-date' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
494 |
self.status = '' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
495 |
elif lst[0] == 'TranslatorAdapter': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
496 |
self.status = lst[1] + '.' + lst[2] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
497 |
self.readableStatus = self.status |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
498 |
if len(lst) > 3: # add the last part of the number |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
499 |
self.status += '.' + ('%02d' % int(lst[3])) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
500 |
self.readableStatus += '.' + lst[3] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
501 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
502 |
self.status += '.00' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
503 |
elif lst[0] == 'TranslatorEnglish': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
504 |
# Obsolete or Based on English. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
505 |
if self.classId[-2:] == 'En': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
506 |
self.readableStatus = 'English based' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
507 |
self.status = 'En' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
508 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
509 |
self.readableStatus = 'obsolete' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
510 |
self.status = '0.0.00' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
511 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
512 |
# Check whether status was set, or set 'strange'. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
513 |
if self.status == None: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
514 |
self.status = 'strange' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
515 |
if not self.readableStatus: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
516 |
self.readableStatus = 'strange' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
517 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
518 |
# Extract the name of the language and the readable form. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
519 |
self.lang = self.classId[10:] # without 'Translator' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
520 |
if self.lang == 'Brazilian': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
521 |
self.langReadable = 'Brazilian Portuguese' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
522 |
elif self.lang == 'Chinesetraditional': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
523 |
self.langReadable = 'Chinese Traditional' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
524 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
525 |
self.langReadable = self.lang |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
526 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
527 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
528 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
529 |
def __unexpectedToken(self, status, tokenId, tokenLineNo): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
530 |
"""Reports unexpected token and quits with exit code 1.""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
531 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
532 |
import inspect |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
533 |
calledFrom = inspect.stack()[1][3] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
534 |
msg = "\a\nUnexpected token '%s' on the line %d in '%s'.\n" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
535 |
msg = msg % (tokenId, tokenLineNo, self.fname) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
536 |
msg += 'status = %d in %s()\n' % (status, calledFrom) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
537 |
sys.stderr.write(msg) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
538 |
sys.exit(1) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
539 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
540 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
541 |
def collectPureVirtualPrototypes(self): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
542 |
"""Returns dictionary 'unified prototype' -> 'full prototype'. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
543 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
544 |
The method is expected to be called only for the translator.h. It |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
545 |
extracts only the pure virtual method and build the dictionary where |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
546 |
key is the unified prototype without argument identifiers.""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
547 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
548 |
# Prepare empty dictionary that will be returned. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
549 |
resultDic = {} |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
550 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
551 |
# Start the token generator which parses the class source file. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
552 |
tokenIterator = self.__tokenGenerator() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
553 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
554 |
# Collect the class and the base class identifiers. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
555 |
self.__collectClassInfo(tokenIterator) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
556 |
assert(self.classId == 'Translator') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
557 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
558 |
# Let's collect readable form of the public virtual pure method |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
559 |
# prototypes in the readable form -- as defined in translator.h. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
560 |
# Let's collect also unified form of the same prototype that omits |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
561 |
# everything that can be omitted, namely 'virtual' and argument |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
562 |
# identifiers. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
563 |
prototype = '' # readable prototype (with everything) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
564 |
uniPrototype = '' # unified prototype (without arg. identifiers) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
565 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
566 |
# Collect the pure virtual method prototypes. Stop on the closing |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
567 |
# curly brace followed by the semicolon (end of class). |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
568 |
status = 0 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
569 |
curlyCnt = 0 # counter for the level of curly braces |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
570 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
571 |
# Loop until the final state 777 is reached. The errors are processed |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
572 |
# immediately. In this implementation, it always quits the application. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
573 |
while status != 777: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
574 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
575 |
# Get the next token. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
576 |
tokenId, tokenStr, tokenLineNo = tokenIterator.next() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
577 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
578 |
if status == 0: # waiting for 'public:' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
579 |
if tokenId == 'public': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
580 |
status = 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
581 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
582 |
elif status == 1: # colon after the 'public' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
583 |
if tokenId == 'colon': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
584 |
status = 2 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
585 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
586 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
587 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
588 |
elif status == 2: # waiting for 'virtual' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
589 |
if tokenId == 'virtual': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
590 |
prototype = tokenStr # but not to unified prototype |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
591 |
status = 3 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
592 |
elif tokenId == 'comment': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
593 |
pass |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
594 |
elif tokenId == 'rcurly': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
595 |
status = 11 # expected end of class |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
596 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
597 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
598 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
599 |
elif status == 3: # return type of the method expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
600 |
if tokenId == 'id': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
601 |
prototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
602 |
uniPrototype = tokenStr # start collecting the unified prototype |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
603 |
status = 4 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
604 |
elif tokenId == 'tilde': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
605 |
status = 4 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
606 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
607 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
608 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
609 |
elif status == 4: # method identifier expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
610 |
if tokenId == 'id': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
611 |
prototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
612 |
uniPrototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
613 |
status = 5 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
614 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
615 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
616 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
617 |
elif status == 5: # left bracket of the argument list expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
618 |
if tokenId == 'lpar': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
619 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
620 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
621 |
status = 6 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
622 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
623 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
624 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
625 |
elif status == 6: # collecting arguments of the method |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
626 |
if tokenId == 'rpar': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
627 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
628 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
629 |
status = 7 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
630 |
elif tokenId == 'const': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
631 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
632 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
633 |
status = 12 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
634 |
elif tokenId == 'id': # type identifier |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
635 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
636 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
637 |
status = 13 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
638 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
639 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
640 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
641 |
elif status == 7: # assignment expected or left curly brace |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
642 |
if tokenId == 'assign': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
643 |
status = 8 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
644 |
elif tokenId == 'lcurly': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
645 |
curlyCnt = 1 # method body entered |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
646 |
status = 10 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
647 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
648 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
649 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
650 |
elif status == 8: # zero expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
651 |
if tokenId == 'num' and tokenStr == '0': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
652 |
status = 9 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
653 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
654 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
655 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
656 |
elif status == 9: # after semicolon, produce the dic item |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
657 |
if tokenId == 'semic': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
658 |
assert(not resultDic.has_key(uniPrototype)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
659 |
resultDic[uniPrototype] = prototype |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
660 |
status = 2 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
661 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
662 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
663 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
664 |
elif status == 10: # consuming the body of the method |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
665 |
if tokenId == 'rcurly': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
666 |
curlyCnt -= 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
667 |
if curlyCnt == 0: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
668 |
status = 2 # body consumed |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
669 |
elif tokenId == 'lcurly': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
670 |
curlyCnt += 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
671 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
672 |
elif status == 11: # probably the end of class |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
673 |
if tokenId == 'semic': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
674 |
status = 777 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
675 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
676 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
677 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
678 |
elif status == 12: # type id for argument expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
679 |
if tokenId == 'id': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
680 |
prototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
681 |
uniPrototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
682 |
status = 13 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
683 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
684 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
685 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
686 |
elif status == 13: # namespace qualification or * or & expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
687 |
if tokenId == 'colon': # was namespace id |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
688 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
689 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
690 |
status = 14 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
691 |
elif tokenId == 'star' or tokenId == 'amp': # pointer or reference |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
692 |
prototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
693 |
uniPrototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
694 |
status = 16 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
695 |
elif tokenId == 'id': # argument identifier |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
696 |
prototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
697 |
# don't put this into unified prototype |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
698 |
status = 17 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
699 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
700 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
701 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
702 |
elif status == 14: # second colon for namespace:: expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
703 |
if tokenId == 'colon': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
704 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
705 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
706 |
status = 15 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
707 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
708 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
709 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
710 |
elif status == 15: # type after namespace:: expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
711 |
if tokenId == 'id': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
712 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
713 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
714 |
status = 13 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
715 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
716 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
717 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
718 |
elif status == 16: # argument identifier expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
719 |
if tokenId == 'id': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
720 |
prototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
721 |
# don't put this into unified prototype |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
722 |
status = 17 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
723 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
724 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
725 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
726 |
elif status == 17: # comma or ')' after argument identifier expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
727 |
if tokenId == 'comma': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
728 |
prototype += ', ' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
729 |
uniPrototype += ', ' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
730 |
status = 6 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
731 |
elif tokenId == 'rpar': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
732 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
733 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
734 |
status = 7 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
735 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
736 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
737 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
738 |
# Eat the rest of the source to cause closing the file. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
739 |
while tokenId != 'eof': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
740 |
tokenId, tokenStr, tokenLineNo = tokenIterator.next() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
741 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
742 |
# Return the resulting dictionary with 'uniPrototype -> prototype'. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
743 |
return resultDic |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
744 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
745 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
746 |
def __collectPublicMethodPrototypes(self, tokenIterator): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
747 |
"""Collects prototypes of public methods and fills self.prototypeDic. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
748 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
749 |
The dictionary is filled by items: uniPrototype -> prototype. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
750 |
The method is expected to be called only for TranslatorXxxx classes, |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
751 |
i.e. for the classes that implement translation to some language. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
752 |
It assumes that the openning curly brace of the class was already |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
753 |
consumed. The source is consumed until the end of the class. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
754 |
The caller should consume the source until the eof to cause closing |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
755 |
the source file.""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
756 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
757 |
assert(self.classId != 'Translator') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
758 |
assert(self.baseClassId != None) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
759 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
760 |
# The following finite automaton slightly differs from the one |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
761 |
# inside self.collectPureVirtualPrototypes(). It produces the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
762 |
# dictionary item just after consuming the body of the method |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
763 |
# (transition from from state 10 to state 2). It also does not allow |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
764 |
# definitions of public pure virtual methods, except for |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
765 |
# TranslatorAdapterBase (states 8 and 9). Argument identifier inside |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
766 |
# method argument lists can be omitted or commented. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
767 |
# |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
768 |
# Let's collect readable form of all public method prototypes in |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
769 |
# the readable form -- as defined in the source file. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
770 |
# Let's collect also unified form of the same prototype that omits |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
771 |
# everything that can be omitted, namely 'virtual' and argument |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
772 |
# identifiers. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
773 |
prototype = '' # readable prototype (with everything) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
774 |
uniPrototype = '' # unified prototype (without arg. identifiers) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
775 |
warning = '' # warning message -- if something special detected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
776 |
methodId = None # processed method id |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
777 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
778 |
# Collect the method prototypes. Stop on the closing |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
779 |
# curly brace followed by the semicolon (end of class). |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
780 |
status = 0 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
781 |
curlyCnt = 0 # counter for the level of curly braces |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
782 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
783 |
# Loop until the final state 777 is reached. The errors are processed |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
784 |
# immediately. In this implementation, it always quits the application. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
785 |
while status != 777: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
786 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
787 |
# Get the next token. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
788 |
tokenId, tokenStr, tokenLineNo = tokenIterator.next() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
789 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
790 |
if status == 0: # waiting for 'public:' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
791 |
if tokenId == 'public': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
792 |
status = 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
793 |
elif tokenId == 'eof': # non-public things until the eof |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
794 |
status = 777 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
795 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
796 |
elif status == 1: # colon after the 'public' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
797 |
if tokenId == 'colon': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
798 |
status = 2 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
799 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
800 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
801 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
802 |
elif status == 2: # waiting for 'virtual' (can be omitted) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
803 |
if tokenId == 'virtual': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
804 |
prototype = tokenStr # but not to unified prototype |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
805 |
status = 3 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
806 |
elif tokenId == 'id': # 'virtual' was omitted |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
807 |
prototype = tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
808 |
uniPrototype = tokenStr # start collecting the unified prototype |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
809 |
status = 4 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
810 |
elif tokenId == 'comment': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
811 |
pass |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
812 |
elif tokenId == 'protected' or tokenId == 'private': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
813 |
status = 0 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
814 |
elif tokenId == 'rcurly': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
815 |
status = 11 # expected end of class |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
816 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
817 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
818 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
819 |
elif status == 3: # return type of the method expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
820 |
if tokenId == 'id': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
821 |
prototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
822 |
uniPrototype = tokenStr # start collecting the unified prototype |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
823 |
status = 4 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
824 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
825 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
826 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
827 |
elif status == 4: # method identifier expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
828 |
if tokenId == 'id': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
829 |
prototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
830 |
uniPrototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
831 |
methodId = tokenStr # for reporting |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
832 |
status = 5 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
833 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
834 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
835 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
836 |
elif status == 5: # left bracket of the argument list expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
837 |
if tokenId == 'lpar': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
838 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
839 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
840 |
status = 6 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
841 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
842 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
843 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
844 |
elif status == 6: # collecting arguments of the method |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
845 |
if tokenId == 'rpar': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
846 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
847 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
848 |
status = 7 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
849 |
elif tokenId == 'const': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
850 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
851 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
852 |
status = 12 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
853 |
elif tokenId == 'id': # type identifier |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
854 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
855 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
856 |
status = 13 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
857 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
858 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
859 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
860 |
elif status == 7: # left curly brace expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
861 |
if tokenId == 'lcurly': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
862 |
curlyCnt = 1 # method body entered |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
863 |
status = 10 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
864 |
elif tokenId == 'comment': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
865 |
pass |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
866 |
elif tokenId == 'assign': # allowed only for TranslatorAdapterBase |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
867 |
assert(self.classId == 'TranslatorAdapterBase') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
868 |
status = 8 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
869 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
870 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
871 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
872 |
elif status == 8: # zero expected (TranslatorAdapterBase) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
873 |
assert(self.classId == 'TranslatorAdapterBase') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
874 |
if tokenId == 'num' and tokenStr == '0': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
875 |
status = 9 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
876 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
877 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
878 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
879 |
elif status == 9: # after semicolon (TranslatorAdapterBase) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
880 |
assert(self.classId == 'TranslatorAdapterBase') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
881 |
if tokenId == 'semic': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
882 |
status = 2 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
883 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
884 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
885 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
886 |
elif status == 10: # consuming the body of the method, then dic item |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
887 |
if tokenId == 'rcurly': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
888 |
curlyCnt -= 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
889 |
if curlyCnt == 0: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
890 |
# Insert new dictionary item. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
891 |
assert(not self.prototypeDic.has_key(uniPrototype)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
892 |
self.prototypeDic[uniPrototype] = prototype |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
893 |
status = 2 # body consumed |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
894 |
methodId = None # outside of any method |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
895 |
elif tokenId == 'lcurly': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
896 |
curlyCnt += 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
897 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
898 |
# Warn in special case. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
899 |
elif methodId == 'trLegendDocs' and tokenId == 'string' \ |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
900 |
and tokenStr.find('MAX_DOT_GRAPH_HEIGHT') >= 0: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
901 |
self.txtMAX_DOT_GRAPH_HEIGHT_flag = True |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
902 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
903 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
904 |
elif status == 11: # probably the end of class |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
905 |
if tokenId == 'semic': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
906 |
status = 777 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
907 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
908 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
909 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
910 |
elif status == 12: # type id for argument expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
911 |
if tokenId == 'id': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
912 |
prototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
913 |
uniPrototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
914 |
status = 13 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
915 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
916 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
917 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
918 |
elif status == 13: # :: or * or & or id or ) expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
919 |
if tokenId == 'colon': # was namespace id |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
920 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
921 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
922 |
status = 14 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
923 |
elif tokenId == 'star' or tokenId == 'amp': # pointer or reference |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
924 |
prototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
925 |
uniPrototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
926 |
status = 16 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
927 |
elif tokenId == 'id': # argument identifier |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
928 |
prototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
929 |
# don't put this into unified prototype |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
930 |
status = 17 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
931 |
elif tokenId == 'comment': # probably commented-out identifier |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
932 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
933 |
elif tokenId == 'rpar': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
934 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
935 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
936 |
status = 7 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
937 |
elif tokenId == 'comma': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
938 |
prototype += ', ' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
939 |
uniPrototype += ', ' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
940 |
status = 6 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
941 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
942 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
943 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
944 |
elif status == 14: # second colon for namespace:: expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
945 |
if tokenId == 'colon': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
946 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
947 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
948 |
status = 15 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
949 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
950 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
951 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
952 |
elif status == 15: # type after namespace:: expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
953 |
if tokenId == 'id': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
954 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
955 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
956 |
status = 13 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
957 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
958 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
959 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
960 |
elif status == 16: # argument identifier or ) expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
961 |
if tokenId == 'id': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
962 |
prototype += ' ' + tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
963 |
# don't put this into unified prototype |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
964 |
status = 17 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
965 |
elif tokenId == 'rpar': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
966 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
967 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
968 |
status = 7 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
969 |
elif tokenId == 'comment': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
970 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
971 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
972 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
973 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
974 |
elif status == 17: # comma or ')' after argument identifier expected |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
975 |
if tokenId == 'comma': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
976 |
prototype += ', ' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
977 |
uniPrototype += ', ' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
978 |
status = 6 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
979 |
elif tokenId == 'rpar': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
980 |
prototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
981 |
uniPrototype += tokenStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
982 |
status = 7 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
983 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
984 |
self.__unexpectedToken(status, tokenId, tokenLineNo) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
985 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
986 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
987 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
988 |
def collectAdapterPrototypes(self): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
989 |
"""Returns the dictionary of prototypes implemented by adapters. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
990 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
991 |
It is created to process the translator_adapter.h. The returned |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
992 |
dictionary has the form: unifiedPrototype -> (version, classId) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
993 |
thus by looking for the prototype, we get the information what is |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
994 |
the newest (least adapting) adapter that is sufficient for |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
995 |
implementing the method.""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
996 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
997 |
# Start the token generator which parses the class source file. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
998 |
assert(os.path.split(self.fname)[1] == 'translator_adapter.h') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
999 |
tokenIterator = self.__tokenGenerator() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1000 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1001 |
# Get the references to the involved dictionaries. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1002 |
reqDic = self.manager.requiredMethodsDic |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1003 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1004 |
# Create the empty dictionary that will be returned. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1005 |
adaptDic = {} |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1006 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1007 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1008 |
# Loop through the source of the adapter file until no other adapter |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1009 |
# class is found. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1010 |
while True: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1011 |
try: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1012 |
# Collect the class and the base class identifiers. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1013 |
self.__collectClassInfo(tokenIterator) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1014 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1015 |
# Extract the comparable version of the adapter class. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1016 |
# Note: The self.status as set by self.__collectClassInfo() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1017 |
# contains similar version, but is related to the base class, |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1018 |
# not to the class itself. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1019 |
lst = self.classId.split('_') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1020 |
version = '' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1021 |
if lst[0] == 'TranslatorAdapter': # TranslatorAdapterBase otherwise |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1022 |
version = lst[1] + '.' + lst[2] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1023 |
if len(lst) > 3: # add the last part of the number |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1024 |
version += '.' + ('%02d' % int(lst[3])) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1025 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1026 |
version += '.00' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1027 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1028 |
# Collect the prototypes of implemented public methods. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1029 |
self.__collectPublicMethodPrototypes(tokenIterator) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1030 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1031 |
# For the required methods, update the dictionary of methods |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1032 |
# implemented by the adapter. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1033 |
for protoUni in self.prototypeDic: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1034 |
if reqDic.has_key(protoUni): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1035 |
# This required method will be marked as implemented |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1036 |
# by this adapter class. This implementation assumes |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1037 |
# that newer adapters do not reimplement any required |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1038 |
# methods already implemented by older adapters. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1039 |
assert(not adaptDic.has_key(protoUni)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1040 |
adaptDic[protoUni] = (version, self.classId) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1041 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1042 |
# Clear the dictionary object and the information related |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1043 |
# to the class as the next adapter class is to be processed. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1044 |
self.prototypeDic.clear() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1045 |
self.classId = None |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1046 |
self.baseClassId = None |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1047 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1048 |
except StopIteration: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1049 |
break |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1050 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1051 |
# Return the result dictionary. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1052 |
return adaptDic |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1053 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1054 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1055 |
def processing(self): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1056 |
"""Processing of the source file -- only for TranslatorXxxx classes.""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1057 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1058 |
# Start the token generator which parses the class source file. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1059 |
tokenIterator = self.__tokenGenerator() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1060 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1061 |
# Collect the class and the base class identifiers. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1062 |
self.__collectClassInfo(tokenIterator) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1063 |
assert(self.classId != 'Translator') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1064 |
assert(self.classId[:17] != 'TranslatorAdapter') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1065 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1066 |
# Collect the prototypes of implemented public methods. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1067 |
self.__collectPublicMethodPrototypes(tokenIterator) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1068 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1069 |
# Eat the rest of the source to cause closing the file. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1070 |
while True: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1071 |
try: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1072 |
t = tokenIterator.next() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1073 |
except StopIteration: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1074 |
break |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1075 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1076 |
# Shorthands for the used dictionaries. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1077 |
reqDic = self.manager.requiredMethodsDic |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1078 |
adaptDic = self.manager.adaptMethodsDic |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1079 |
myDic = self.prototypeDic |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1080 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1081 |
# Build the list of obsolete methods. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1082 |
self.obsoleteMethods = [] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1083 |
for p in myDic: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1084 |
if not reqDic.has_key(p): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1085 |
self.obsoleteMethods.append(p) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1086 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1087 |
# Build the list of missing methods and the list of implemented |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1088 |
# required methods. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1089 |
self.missingMethods = [] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1090 |
self.implementedMethods = [] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1091 |
for p in reqDic: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1092 |
if myDic.has_key(p): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1093 |
self.implementedMethods.append(p) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1094 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1095 |
self.missingMethods.append(p) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1096 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1097 |
# Check whether adapter must be used or suggest the newest one. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1098 |
# Change the status and set the note accordingly. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1099 |
if self.baseClassId != 'Translator': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1100 |
if not self.missingMethods: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1101 |
self.note = 'Change the base class to Translator.' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1102 |
self.status = '' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1103 |
self.readableStatus = 'up-to-date' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1104 |
elif self.baseClassId != 'TranslatorEnglish': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1105 |
# The translator uses some of the adapters. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1106 |
# Look at the missing methods and check what adapter |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1107 |
# implements them. Remember the one with the lowest version. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1108 |
adaptMinVersion = '9.9.99' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1109 |
adaptMinClass = 'TranslatorAdapter_9_9_99' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1110 |
for uniProto in self.missingMethods: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1111 |
if adaptDic.has_key(uniProto): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1112 |
version, cls = adaptDic[uniProto] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1113 |
if version < adaptMinVersion: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1114 |
adaptMinVersion = version |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1115 |
adaptMinClass = cls |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1116 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1117 |
# Test against the current status -- preserve the self.status. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1118 |
# Possibly, the translator implements enough methods to |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1119 |
# use some newer adapter. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1120 |
status = self.status |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1121 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1122 |
# If the version of the used adapter is smaller than |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1123 |
# the required, set the note and update the status as if |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1124 |
# the newer adapter was used. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1125 |
if adaptMinVersion > status: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1126 |
self.note = 'Change the base class to %s.' % adaptMinClass |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1127 |
self.status = adaptMinVersion |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1128 |
self.adaptMinClass = adaptMinClass |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1129 |
self.readableStatus = adaptMinVersion # simplified |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1130 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1131 |
# If everything seems OK, some explicit warning flags still could |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1132 |
# be set. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1133 |
if not self.note and self.status == '' and \ |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1134 |
(self.translateMeFlag or self.txtMAX_DOT_GRAPH_HEIGHT_flag): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1135 |
self.note = '' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1136 |
if self.translateMeFlag: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1137 |
self.note += 'The "%s" found in a comment.' % self.translateMeText |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1138 |
if self.note != '': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1139 |
self.note += '\n\t\t' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1140 |
if self.txtMAX_DOT_GRAPH_HEIGHT_flag: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1141 |
self.note += 'The MAX_DOT_GRAPH_HEIGHT found in trLegendDocs()' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1142 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1143 |
# If everything seems OK, but there are obsolete methods, set |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1144 |
# the note to clean-up source. This note will be used only when |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1145 |
# the previous code did not set another note (priority). |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1146 |
if not self.note and self.status == '' and self.obsoleteMethods: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1147 |
self.note = 'Remove the obsolete methods (never used).' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1148 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1149 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1150 |
def report(self, fout): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1151 |
"""Returns the report part for the source as a multiline string. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1152 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1153 |
No output for up-to-date translators without problem.""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1154 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1155 |
# If there is nothing to report, return immediately. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1156 |
if self.status == '' and not self.note: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1157 |
return |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1158 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1159 |
# Report the number of not implemented methods. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1160 |
fout.write('\n\n\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1161 |
fout.write(self.classId + ' (' + self.baseClassId + ')') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1162 |
percentImplemented = 100 # init |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1163 |
allNum = len(self.manager.requiredMethodsDic) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1164 |
if self.missingMethods: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1165 |
num = len(self.missingMethods) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1166 |
percentImplemented = 100 * (allNum - num) / allNum |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1167 |
fout.write(' %d' % num) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1168 |
fout.write(' method') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1169 |
if num > 1: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1170 |
fout.write('s') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1171 |
fout.write(' to implement (%d %%)' % (100 * num / allNum)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1172 |
fout.write('\n' + '-' * len(self.classId)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1173 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1174 |
# Write the info about the implemented required methods. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1175 |
fout.write('\n\n Implements %d' % len(self.implementedMethods)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1176 |
fout.write(' of the required methods (%d %%).' % percentImplemented) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1177 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1178 |
# Report the missing method, but only when it is not English-based |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1179 |
# translator. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1180 |
if self.missingMethods and self.status != 'En': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1181 |
fout.write('\n\n Missing methods (should be implemented):\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1182 |
reqDic = self.manager.requiredMethodsDic |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1183 |
for p in self.missingMethods: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1184 |
fout.write('\n ' + reqDic[p]) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1185 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1186 |
# Always report obsolete methods. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1187 |
if self.obsoleteMethods: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1188 |
fout.write('\n\n Obsolete methods (should be removed, never used):\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1189 |
myDic = self.prototypeDic |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1190 |
for p in self.obsoleteMethods: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1191 |
fout.write('\n ' + myDic[p]) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1192 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1193 |
# For English-based translator, report the implemented methods. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1194 |
if self.status == 'En' and self.implementedMethods: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1195 |
fout.write('\n\n This English-based translator implements ') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1196 |
fout.write('the following methods:\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1197 |
reqDic = self.manager.requiredMethodsDic |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1198 |
for p in self.implementedMethods: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1199 |
fout.write('\n ' + reqDic[p]) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1200 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1201 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1202 |
def getmtime(self): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1203 |
"""Returns the last modification time of the source file.""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1204 |
assert(os.path.isfile(self.fname)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1205 |
return os.path.getmtime(self.fname) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1206 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1207 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1208 |
class TrManager: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1209 |
"""Collects basic info and builds subordinate Transl objects.""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1210 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1211 |
def __init__(self): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1212 |
"""Determines paths, creates and initializes structures. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1213 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1214 |
The arguments of the script may explicitly say what languages should |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1215 |
be processed. Write the two letter identifications that are used |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1216 |
for composing the source filenames, so... |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1217 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1218 |
python translator.py cz |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1219 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1220 |
this will process only translator_cz.h source. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1221 |
""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1222 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1223 |
# Determine the path to the script and its name. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1224 |
self.script = os.path.abspath(sys.argv[0]) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1225 |
self.script_path, self.script_name = os.path.split(self.script) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1226 |
self.script_path = os.path.abspath(self.script_path) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1227 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1228 |
# Determine the absolute path to the Doxygen's root subdirectory. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1229 |
# If DOXYGEN environment variable is not found, the directory is |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1230 |
# determined from the path of the script. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1231 |
doxy_default = os.path.join(self.script_path, '..') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1232 |
self.doxy_path = os.path.abspath(os.getenv('DOXYGEN', doxy_default)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1233 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1234 |
# Get the explicit arguments of the script. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1235 |
self.script_argLst = sys.argv[1:] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1236 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1237 |
# Build the path names based on the Doxygen's root knowledge. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1238 |
self.doc_path = os.path.join(self.doxy_path, 'doc') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1239 |
self.src_path = os.path.join(self.doxy_path, 'src') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1240 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1241 |
# Create the empty dictionary for Transl object identitied by the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1242 |
# class identifier of the translator. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1243 |
self.__translDic = {} |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1244 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1245 |
# Create the None dictionary of required methods. The key is the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1246 |
# unified prototype, the value is the full prototype. Set inside |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1247 |
# the self.__build(). |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1248 |
self.requiredMethodsDic = None |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1249 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1250 |
# Create the empty dictionary that says what method is implemented |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1251 |
# by what adapter. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1252 |
self.adaptMethodsDic = {} |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1253 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1254 |
# The last modification time will capture the modification of this |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1255 |
# script, of the translator.h, of the translator_adapter.h (see the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1256 |
# self.__build() for the last two) of all the translator_xx.h files |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1257 |
# and of the template for generating the documentation. So, this |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1258 |
# time can be compared with modification time of the generated |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1259 |
# documentation to decide, whether the doc should be re-generated. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1260 |
self.lastModificationTime = os.path.getmtime(self.script) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1261 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1262 |
# Set the names of the translator report text file, of the template |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1263 |
# for generating "Internationalization" document, for the generated |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1264 |
# file itself, and for the maintainers list. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1265 |
self.translatorReportFileName = 'translator_report.txt' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1266 |
self.maintainersFileName = 'maintainers.txt' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1267 |
self.languageTplFileName = 'language.tpl' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1268 |
self.languageDocFileName = 'language.doc' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1269 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1270 |
# The information about the maintainers will be stored |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1271 |
# in the dictionary with the following name. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1272 |
self.__maintainersDic = None |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1273 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1274 |
# Define the other used structures and variables for information. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1275 |
self.langLst = None # including English based |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1276 |
self.supportedLangReadableStr = None # coupled En-based as a note |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1277 |
self.numLang = None # excluding coupled En-based |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1278 |
self.doxVersion = None # Doxygen version |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1279 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1280 |
# Build objects where each one is responsible for one translator. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1281 |
self.__build() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1282 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1283 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1284 |
def __build(self): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1285 |
"""Find the translator files and build the objects for translators.""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1286 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1287 |
# The translator.h must exist (the Transl object will check it), |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1288 |
# create the object for it and let it build the dictionary of |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1289 |
# required methods. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1290 |
tr = Transl(os.path.join(self.src_path, 'translator.h'), self) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1291 |
self.requiredMethodsDic = tr.collectPureVirtualPrototypes() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1292 |
tim = tr.getmtime() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1293 |
if tim > self.lastModificationTime: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1294 |
self.lastModificationTime = tim |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1295 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1296 |
# The translator_adapter.h must exist (the Transl object will check it), |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1297 |
# create the object for it and store the reference in the dictionary. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1298 |
tr = Transl(os.path.join(self.src_path, 'translator_adapter.h'), self) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1299 |
self.adaptMethodsDic = tr.collectAdapterPrototypes() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1300 |
tim = tr.getmtime() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1301 |
if tim > self.lastModificationTime: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1302 |
self.lastModificationTime = tim |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1303 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1304 |
# Create the list of the filenames with language translator sources. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1305 |
# If the explicit arguments of the script were typed, process only |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1306 |
# those files. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1307 |
if self.script_argLst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1308 |
lst = ['translator_' + x + '.h' for x in self.script_argLst] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1309 |
for fname in lst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1310 |
if not os.path.isfile(os.path.join(self.src_path, fname)): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1311 |
sys.stderr.write("\a\nFile '%s' not found!\n" % fname) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1312 |
sys.exit(1) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1313 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1314 |
lst = os.listdir(self.src_path) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1315 |
lst = filter(lambda x: x[:11] == 'translator_' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1316 |
and x[-2:] == '.h' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1317 |
and x != 'translator_adapter.h', lst) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1318 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1319 |
# Build the object for the translator_xx.h files, and process the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1320 |
# content of the file. Then insert the object to the dictionary |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1321 |
# accessed via classId. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1322 |
for fname in lst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1323 |
fullname = os.path.join(self.src_path, fname) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1324 |
tr = Transl(fullname, self) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1325 |
tr.processing() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1326 |
assert(tr.classId != 'Translator') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1327 |
self.__translDic[tr.classId] = tr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1328 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1329 |
# Extract the global information of the processed info. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1330 |
self.__extractProcessedInfo() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1331 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1332 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1333 |
def __extractProcessedInfo(self): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1334 |
"""Build lists and strings of the processed info.""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1335 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1336 |
# Build the auxiliary list with strings compound of the status, |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1337 |
# readable form of the language, and classId. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1338 |
statLst = [] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1339 |
for obj in self.__translDic.values(): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1340 |
assert(obj.classId != 'Translator') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1341 |
s = obj.status + '|' + obj.langReadable + '|' + obj.classId |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1342 |
statLst.append(s) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1343 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1344 |
# Sort the list and extract the object identifiers (classId's) for |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1345 |
# the up-to-date translators and English-based translators. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1346 |
statLst.sort() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1347 |
self.upToDateIdLst = [x.split('|')[2] for x in statLst if x[0] == '|'] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1348 |
self.EnBasedIdLst = [x.split('|')[2] for x in statLst if x[:2] == 'En'] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1349 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1350 |
# Reverse the list and extract the TranslatorAdapter based translators. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1351 |
statLst.reverse() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1352 |
self.adaptIdLst = [x.split('|')[2] for x in statLst if x[0].isdigit()] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1353 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1354 |
# Build the list of tuples that contain (langReadable, obj). |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1355 |
# Sort it by readable name. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1356 |
self.langLst = [] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1357 |
for obj in self.__translDic.values(): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1358 |
self.langLst.append((obj.langReadable, obj)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1359 |
self.langLst.sort(lambda a, b: cmp(a[0], b[0])) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1360 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1361 |
# Create the list with readable language names. If the language has |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1362 |
# also the English-based version, modify the item by appending |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1363 |
# the note. Number of the supported languages is equal to the length |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1364 |
# of the list. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1365 |
langReadableLst = [] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1366 |
for name, obj in self.langLst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1367 |
if obj.status == 'En': continue |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1368 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1369 |
# Append the 'En' to the classId to possibly obtain the classId |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1370 |
# of the English-based object. If the object exists, modify the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1371 |
# name for the readable list of supported languages. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1372 |
classIdEn = obj.classId + 'En' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1373 |
if self.__translDic.has_key(classIdEn): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1374 |
name += ' (+En)' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1375 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1376 |
# Append the result name of the language, possibly with note. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1377 |
langReadableLst.append(name) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1378 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1379 |
# Create the multiline string of readable language names, |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1380 |
# with punctuation, wrapped to paragraph. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1381 |
if len(langReadableLst) == 1: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1382 |
s = langReadableLst[0] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1383 |
elif len(langReadableLst) == 2: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1384 |
s = ' and '.join(langReadableLst) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1385 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1386 |
s = ', '.join(langReadableLst[:-1]) + ', and ' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1387 |
s += langReadableLst[-1] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1388 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1389 |
self.supportedLangReadableStr = fill(s + '.') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1390 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1391 |
# Find the number of the supported languages. The English based |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1392 |
# languages are not counted if the non-English based also exists. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1393 |
self.numLang = len(self.langLst) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1394 |
for name, obj in self.langLst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1395 |
if obj.status == 'En': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1396 |
classId = obj.classId[:-2] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1397 |
if self.__translDic.has_key(classId): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1398 |
self.numLang -= 1 # the couple will be counted as one |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1399 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1400 |
# Extract the version of Doxygen. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1401 |
f = file(os.path.join(self.doxy_path, 'VERSION')) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1402 |
self.doxVersion = f.readline().strip() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1403 |
f.close() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1404 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1405 |
# Update the last modification time. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1406 |
for tr in self.__translDic.values(): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1407 |
tim = tr.getmtime() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1408 |
if tim > self.lastModificationTime: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1409 |
self.lastModificationTime = tim |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1410 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1411 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1412 |
def __getNoTrSourceFilesLst(self): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1413 |
"""Returns the list of sources to be checked. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1414 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1415 |
All .cpp files and also .h files that do not declare or define |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1416 |
the translator methods are included in the list. The file names |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1417 |
are searched in doxygen/src directory. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1418 |
""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1419 |
files = [] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1420 |
for item in os.listdir(self.src_path): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1421 |
# Split the bare name to get the extension. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1422 |
name, ext = os.path.splitext(item) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1423 |
ext = ext.lower() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1424 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1425 |
# Include only .cpp and .h files (case independent) and exclude |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1426 |
# the files where the checked identifiers are defined. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1427 |
if ext == '.cpp' or (ext == '.h' and name.find('translator') == -1): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1428 |
fname = os.path.join(self.src_path, item) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1429 |
assert os.path.isfile(fname) # assumes no directory with the ext |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1430 |
files.append(fname) # full name |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1431 |
return files |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1432 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1433 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1434 |
def __removeUsedInFiles(self, fname, dic): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1435 |
"""Removes items for method identifiers that are found in fname. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1436 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1437 |
The method reads the content of the file as one string and searches |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1438 |
for all identifiers from dic. The identifiers that were found in |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1439 |
the file are removed from the dictionary. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1440 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1441 |
Note: If more files is to be checked, the files where most items are |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1442 |
probably used should be checked first and the resulting reduced |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1443 |
dictionary should be used for checking the next files (speed up). |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1444 |
""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1445 |
lst_in = dic.keys() # identifiers to be searched for |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1446 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1447 |
# Read content of the file as one string. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1448 |
assert os.path.isfile(fname) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1449 |
f = file(fname) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1450 |
cont = f.read() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1451 |
f.close() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1452 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1453 |
# Remove the items for identifiers that were found in the file. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1454 |
while lst_in: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1455 |
item = lst_in.pop(0) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1456 |
if cont.find(item) != -1: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1457 |
del dic[item] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1458 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1459 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1460 |
def __checkForNotUsedTrMethods(self): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1461 |
"""Returns the dictionary of not used translator methods. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1462 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1463 |
The method can be called only after self.requiredMethodsDic has been |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1464 |
built. The stripped prototypes are the values, the method identifiers |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1465 |
are the keys. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1466 |
""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1467 |
# Build the dictionary of the required method prototypes with |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1468 |
# method identifiers used as keys. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1469 |
trdic = {} |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1470 |
for prototype in self.requiredMethodsDic.keys(): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1471 |
ri = prototype.split('(')[0] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1472 |
identifier = ri.split()[1].strip() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1473 |
trdic[identifier] = prototype |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1474 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1475 |
# Build the list of source files where translator method identifiers |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1476 |
# can be used. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1477 |
files = self.__getNoTrSourceFilesLst() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1478 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1479 |
# Loop through the files and reduce the dictionary of id -> proto. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1480 |
for fname in files: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1481 |
self.__removeUsedInFiles(fname, trdic) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1482 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1483 |
# Return the dictionary of not used translator methods. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1484 |
return trdic |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1485 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1486 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1487 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1488 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1489 |
def __email(self, classId): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1490 |
"""Returns the first maintainer for the translator class""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1491 |
return self.__maintainersDic[classId][0][1] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1492 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1493 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1494 |
def generateTranslatorReport(self): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1495 |
"""Generates the translator report.""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1496 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1497 |
output = os.path.join(self.doc_path, self.translatorReportFileName) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1498 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1499 |
# Open the textual report file for the output. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1500 |
f = file(output, 'w') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1501 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1502 |
# Output the information about the version. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1503 |
f.write('(' + self.doxVersion + ')\n\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1504 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1505 |
# Output the information about the number of the supported languages |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1506 |
# and the list of the languages, or only the note about the explicitly |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1507 |
# given languages to process. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1508 |
if self.script_argLst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1509 |
f.write('The report was generated for the following, explicitly') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1510 |
f.write(' identified languages:\n\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1511 |
f.write(self.supportedLangReadableStr + '\n\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1512 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1513 |
f.write('Doxygen supports the following ') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1514 |
f.write(str(self.numLang)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1515 |
f.write(' languages (sorted alphabetically):\n\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1516 |
f.write(self.supportedLangReadableStr + '\n\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1517 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1518 |
# Write the summary about the status of language translators (how |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1519 |
# many translators) are up-to-date, etc. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1520 |
s = 'Of them, %d translators are up-to-date, ' % len(self.upToDateIdLst) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1521 |
s += '%d translators are based on some adapter class, ' % len(self.adaptIdLst) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1522 |
s += 'and %d are English based.' % len(self.EnBasedIdLst) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1523 |
f.write(fill(s) + '\n\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1524 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1525 |
# The e-mail addresses of the maintainers will be collected to |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1526 |
# the auxiliary file in the order of translator classes listed |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1527 |
# in the translator report. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1528 |
fmail = file('mailto.txt', 'w') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1529 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1530 |
# Write the list of up-to-date translator classes. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1531 |
if self.upToDateIdLst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1532 |
s = '''The following translator classes are up-to-date (sorted |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1533 |
alphabetically). This means that they derive from the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1534 |
Translator class and they implement all %d of the required |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1535 |
methods. Anyway, there still may be some details listed even |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1536 |
for them:''' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1537 |
s = s % len(self.requiredMethodsDic) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1538 |
f.write('-' * 70 + '\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1539 |
f.write(fill(s) + '\n\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1540 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1541 |
mailtoLst = [] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1542 |
for x in self.upToDateIdLst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1543 |
obj = self.__translDic[x] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1544 |
f.write(' ' + obj.classId) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1545 |
if obj.note: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1546 |
f.write(' -- ' + obj.note) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1547 |
f.write('\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1548 |
mailtoLst.append(self.__email(obj.classId)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1549 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1550 |
fmail.write('up-to-date\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1551 |
fmail.write('; '.join(mailtoLst)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1552 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1553 |
# Write the list of the adapter based classes. The very obsolete |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1554 |
# translators that derive from TranslatorEnglish are included. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1555 |
if self.adaptIdLst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1556 |
s = '''The following translator classes need some maintenance |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1557 |
(the most obsolete at the end). The other info shows the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1558 |
estimation of Doxygen version when the class was last |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1559 |
updated and number of methods that must be implemented to |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1560 |
become up-to-date:''' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1561 |
f.write('\n' + '-' * 70 + '\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1562 |
f.write(fill(s) + '\n\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1563 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1564 |
# Find also whether some adapter classes may be removed. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1565 |
adaptMinVersion = '9.9.99' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1566 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1567 |
mailtoLst = [] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1568 |
numRequired = len(self.requiredMethodsDic) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1569 |
for x in self.adaptIdLst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1570 |
obj = self.__translDic[x] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1571 |
f.write(' %-30s' % obj.classId) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1572 |
f.write(' %-6s' % obj.readableStatus) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1573 |
numimpl = len(obj.missingMethods) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1574 |
pluralS = '' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1575 |
if numimpl > 1: pluralS = 's' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1576 |
percent = 100 * numimpl / numRequired |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1577 |
f.write('\t%2d method%s to implement (%d %%)' % ( |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1578 |
numimpl, pluralS, percent)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1579 |
if obj.note: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1580 |
f.write('\n\tNote: ' + obj.note + '\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1581 |
f.write('\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1582 |
mailtoLst.append(self.__email(obj.classId)) # to maintainer |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1583 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1584 |
# Check the level of required adapter classes. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1585 |
if obj.status != '0.0.00' and obj.status < adaptMinVersion: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1586 |
adaptMinVersion = obj.status |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1587 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1588 |
fmail.write('\n\ntranslator based\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1589 |
fmail.write('; '.join(mailtoLst)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1590 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1591 |
# Set the note if some old translator adapters are not needed |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1592 |
# any more. Do it only when the script is called without arguments, |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1593 |
# i.e. all languages were checked against the needed translator |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1594 |
# adapters. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1595 |
if not self.script_argLst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1596 |
to_remove = {} |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1597 |
for version, adaptClassId in self.adaptMethodsDic.values(): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1598 |
if version < adaptMinVersion: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1599 |
to_remove[adaptClassId] = True |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1600 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1601 |
if to_remove: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1602 |
lst = to_remove.keys() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1603 |
lst.sort() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1604 |
plural = len(lst) > 1 |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1605 |
note = 'Note: The adapter class' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1606 |
if plural: note += 'es' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1607 |
note += ' ' + ', '.join(lst) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1608 |
if not plural: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1609 |
note += ' is' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1610 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1611 |
note += ' are' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1612 |
note += ' not used and can be removed.' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1613 |
f.write('\n' + fill(note) + '\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1614 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1615 |
# Write the list of the English-based classes. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1616 |
if self.EnBasedIdLst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1617 |
s = '''The following translator classes derive directly from the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1618 |
TranslatorEnglish. The class identifier has the suffix 'En' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1619 |
that says that this is intentional. Usually, there is also |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1620 |
a non-English based version of the translator for |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1621 |
the language:''' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1622 |
f.write('\n' + '-' * 70 + '\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1623 |
f.write(fill(s) + '\n\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1624 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1625 |
for x in self.EnBasedIdLst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1626 |
obj = self.__translDic[x] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1627 |
f.write(' ' + obj.classId) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1628 |
f.write('\timplements %d methods' % len(obj.implementedMethods)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1629 |
if obj.note: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1630 |
f.write(' -- ' + obj.note) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1631 |
f.write('\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1632 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1633 |
# Check for not used translator methods and generate warning if found. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1634 |
# The check is rather time consuming, so it is not done when report |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1635 |
# is restricted to explicitly given language identifiers. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1636 |
if not self.script_argLst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1637 |
dic = self.__checkForNotUsedTrMethods() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1638 |
if dic: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1639 |
s = '''WARNING: The following translator methods are declared |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1640 |
in the Translator class but their identifiers do not appear |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1641 |
in source files. The situation should be checked. The .cpp |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1642 |
files and .h files excluding the '*translator*' files |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1643 |
in doxygen/src directory were simply searched for occurence |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1644 |
of the method identifiers:''' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1645 |
f.write('\n' + '=' * 70 + '\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1646 |
f.write(fill(s) + '\n\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1647 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1648 |
keys = dic.keys() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1649 |
keys.sort() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1650 |
for key in keys: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1651 |
f.write(' ' + dic[key] + '\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1652 |
f.write('\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1653 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1654 |
# Write the details for the translators. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1655 |
f.write('\n' + '=' * 70) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1656 |
f.write('\nDetails for translators (classes sorted alphabetically):\n') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1657 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1658 |
cls = self.__translDic.keys() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1659 |
cls.sort() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1660 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1661 |
for c in cls: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1662 |
obj = self.__translDic[c] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1663 |
assert(obj.classId != 'Translator') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1664 |
obj.report(f) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1665 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1666 |
# Close the report file and the auxiliary file with e-mails. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1667 |
f.close() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1668 |
fmail.close() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1669 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1670 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1671 |
def __loadMaintainers(self): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1672 |
"""Load and process the file with the maintainers. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1673 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1674 |
Fills the dictionary classId -> [(name, e-mail), ...].""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1675 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1676 |
fname = os.path.join(self.doc_path, self.maintainersFileName) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1677 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1678 |
# Include the maintainers file to the group of files checked with |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1679 |
# respect to the modification time. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1680 |
tim = os.path.getmtime(fname) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1681 |
if tim > self.lastModificationTime: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1682 |
self.lastModificationTime = tim |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1683 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1684 |
# Process the content of the maintainers file. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1685 |
f = file(fname) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1686 |
inside = False # inside the record for the language |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1687 |
lineReady = True |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1688 |
classId = None |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1689 |
maintainersLst = None |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1690 |
self.__maintainersDic = {} |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1691 |
while lineReady: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1692 |
line = f.readline() # next line |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1693 |
lineReady = line != '' # when eof, then line == '' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1694 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1695 |
line = line.strip() # eof should also behave as separator |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1696 |
if line != '' and line[0] == '%': # skip the comment line |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1697 |
continue |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1698 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1699 |
if not inside: # if outside of the record |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1700 |
if line != '': # should be language identifier |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1701 |
classId = line |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1702 |
maintainersLst = [] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1703 |
inside = True |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1704 |
# Otherwise skip empty line that do not act as separator. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1705 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1706 |
else: # if inside the record |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1707 |
if line == '': # separator found |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1708 |
inside = False |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1709 |
else: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1710 |
# If it is the first maintainer, create the empty list. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1711 |
if not self.__maintainersDic.has_key(classId): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1712 |
self.__maintainersDic[classId] = [] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1713 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1714 |
# Split the information about the maintainer and append |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1715 |
# the tuple. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1716 |
lst = line.split(':', 1) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1717 |
assert(len(lst) == 2) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1718 |
t = (lst[0].strip(), lst[1].strip()) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1719 |
self.__maintainersDic[classId].append(t) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1720 |
f.close() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1721 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1722 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1723 |
def generateLanguageDoc(self): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1724 |
"""Checks the modtime of files and generates language.doc.""" |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1725 |
self.__loadMaintainers() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1726 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1727 |
# Check the last modification time of the template file. It is the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1728 |
# last file from the group that decide whether the documentation |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1729 |
# should or should not be generated. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1730 |
fTplName = os.path.join(self.doc_path, self.languageTplFileName) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1731 |
tim = os.path.getmtime(fTplName) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1732 |
if tim > self.lastModificationTime: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1733 |
self.lastModificationTime = tim |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1734 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1735 |
# If the generated documentation exists and is newer than any of |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1736 |
# the source files from the group, do not generate it and quit |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1737 |
# quietly. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1738 |
fDocName = os.path.join(self.doc_path, self.languageDocFileName) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1739 |
if os.path.isfile(fDocName): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1740 |
if os.path.getmtime(fDocName) > self.lastModificationTime: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1741 |
return |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1742 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1743 |
# The document or does not exist or is older than some of the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1744 |
# sources. It must be generated again. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1745 |
# |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1746 |
# Read the template of the documentation, and remove the first |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1747 |
# attention lines. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1748 |
f = file(fTplName) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1749 |
line = f.readline() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1750 |
while line[0] != '/': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1751 |
line = f.readline() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1752 |
doctpl = line + f.read() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1753 |
f.close() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1754 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1755 |
# Fill the tplDic by symbols that will be inserted into the |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1756 |
# document template. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1757 |
tplDic = {} |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1758 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1759 |
s = 'Do not edit this file. It was generated by the %s script.' % self.script_name |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1760 |
tplDic['editnote'] = s |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1761 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1762 |
tplDic['doxVersion'] = self.doxVersion |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1763 |
tplDic['supportedLangReadableStr'] = self.supportedLangReadableStr |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1764 |
tplDic['translatorReportFileName'] = self.translatorReportFileName |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1765 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1766 |
ahref = '<a href="../doc/' + self.translatorReportFileName |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1767 |
ahref += '"\n><code>doxygen/doc/' + self.translatorReportFileName |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1768 |
ahref += '</code></a>' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1769 |
tplDic['translatorReportLink'] = ahref |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1770 |
tplDic['numLangStr'] = str(self.numLang) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1771 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1772 |
# Define templates for HTML table parts of the documentation. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1773 |
htmlTableTpl = '''\ |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1774 |
\\htmlonly |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1775 |
<table align="center" cellspacing="0" cellpadding="0" border="0"> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1776 |
<tr bgcolor="#000000"> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1777 |
<td> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1778 |
<table cellspacing="1" cellpadding="2" border="0"> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1779 |
<tr bgcolor="#4040c0"> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1780 |
<td ><b><font size="+1" color="#ffffff"> Language </font></b></td> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1781 |
<td ><b><font size="+1" color="#ffffff"> Maintainer </font></b></td> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1782 |
<td ><b><font size="+1" color="#ffffff"> Contact address </font> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1783 |
<font size="-2" color="#ffffff">(replace the at and dot)</font></b></td> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1784 |
<td ><b><font size="+1" color="#ffffff"> Status </font></b></td> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1785 |
</tr> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1786 |
<!-- table content begin --> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1787 |
%s |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1788 |
<!-- table content end --> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1789 |
</table> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1790 |
</td> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1791 |
</tr> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1792 |
</table> |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1793 |
\\endhtmlonly |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1794 |
''' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1795 |
htmlTableTpl = dedent(htmlTableTpl) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1796 |
htmlTrTpl = '\n <tr bgcolor="#ffffff">%s\n </tr>' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1797 |
htmlTdTpl = '\n <td>%s</td>' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1798 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1799 |
# Loop through transl objects in the order of sorted readable names |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1800 |
# and add generate the content of the HTML table. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1801 |
trlst = [] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1802 |
for name, obj in self.langLst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1803 |
# Fill the table data elements for one row. The first element |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1804 |
# contains the readable name of the language. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1805 |
lst = [ htmlTdTpl % obj.langReadable ] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1806 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1807 |
# The next two elements contain the list of maintainers |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1808 |
# and the list of their mangled e-mails. For English-based |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1809 |
# translators that are coupled with the non-English based, |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1810 |
# insert the 'see' note. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1811 |
mm = None # init |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1812 |
ee = None # init |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1813 |
if obj.status == 'En': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1814 |
# Check whether there is the coupled non-English. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1815 |
classId = obj.classId[:-2] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1816 |
if self.__translDic.has_key(classId): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1817 |
lang = self.__translDic[classId].langReadable |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1818 |
mm = 'see the %s language' % lang |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1819 |
ee = ' ' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1820 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1821 |
if not mm and self.__maintainersDic.has_key(obj.classId): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1822 |
lm = [ m[0] for m in self.__maintainersDic[obj.classId] ] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1823 |
mm = '<br/>'.join(lm) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1824 |
le = [ m[1] for m in self.__maintainersDic[obj.classId] ] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1825 |
ee = '<br/>'.join(le) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1826 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1827 |
# Mangle the e-mail and replace the entity references. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1828 |
if ee and ee != ' ': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1829 |
# More than one maintainer address separated by <br> can be used. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1830 |
emails = ee.split('<br/>') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1831 |
mangled_list = [] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1832 |
for email in emails: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1833 |
name, domain = email.split('@') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1834 |
domain = domain.replace('.', ' dot ') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1835 |
mangled_list.append(name + ' at ' + domain) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1836 |
ee = '<br/>'.join(mangled_list) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1837 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1838 |
if mm: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1839 |
mm = mm.replace('č', 'č') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1840 |
mm = mm.replace('ř', 'ř') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1841 |
mm = mm.replace('š', 'š') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1842 |
mm = mm.replace('ž', 'ž') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1843 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1844 |
# Append the maintainer and e-mail elements. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1845 |
lst.append(htmlTdTpl % mm) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1846 |
lst.append(htmlTdTpl % ee) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1847 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1848 |
# The last element contains the readable form of the status. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1849 |
lst.append(htmlTdTpl % obj.readableStatus) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1850 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1851 |
# Join the table data to one table row. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1852 |
trlst.append(htmlTrTpl % (''.join(lst))) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1853 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1854 |
# Join the table rows and insert into the template. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1855 |
htmlTable = htmlTableTpl % (''.join(trlst)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1856 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1857 |
# Define templates for LaTeX table parts of the documentation. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1858 |
latexTableTpl = r''' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1859 |
\latexonly |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1860 |
\begin{tabular}{|l|l|l|l|} |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1861 |
\hline |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1862 |
{\bf Language} & {\bf Maintainer} & {\bf Contact address} & {\bf Status} \\ |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1863 |
\hline |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1864 |
%s |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1865 |
\hline |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1866 |
\end{tabular} |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1867 |
\endlatexonly |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1868 |
''' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1869 |
latexTableTpl = dedent(latexTableTpl) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1870 |
latexLineTpl = '\n' + r' %s & %s & {\tt\tiny %s} & %s \\' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1871 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1872 |
# Loop through transl objects in the order of sorted readable names |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1873 |
# and add generate the content of the LaTeX table. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1874 |
trlst = [] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1875 |
for name, obj in self.langLst: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1876 |
# For LaTeX, more maintainers for the same language are |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1877 |
# placed on separate rows in the table. The line separator |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1878 |
# in the table is placed explicitly above the first |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1879 |
# maintainer. Prepare the arguments for the LaTeX row template. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1880 |
maintainers = [] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1881 |
if self.__maintainersDic.has_key(obj.classId): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1882 |
maintainers = self.__maintainersDic[obj.classId] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1883 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1884 |
lang = obj.langReadable |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1885 |
maintainer = None # init |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1886 |
email = None # init |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1887 |
if obj.status == 'En': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1888 |
# Check whether there is the coupled non-English. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1889 |
classId = obj.classId[:-2] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1890 |
if self.__translDic.has_key(classId): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1891 |
langNE = self.__translDic[classId].langReadable |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1892 |
maintainer = 'see the %s language' % langNE |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1893 |
email = '~' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1894 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1895 |
if not maintainer and self.__maintainersDic.has_key(obj.classId): |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1896 |
lm = [ m[0] for m in self.__maintainersDic[obj.classId] ] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1897 |
maintainer = maintainers[0][0] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1898 |
email = maintainers[0][1] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1899 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1900 |
status = obj.readableStatus |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1901 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1902 |
# Use the template to produce the line of the table and insert |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1903 |
# the hline plus the constructed line into the table content. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1904 |
trlst.append('\n \\hline') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1905 |
trlst.append(latexLineTpl % (lang, maintainer, email, status)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1906 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1907 |
# List the other maintainers for the language. Do not set |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1908 |
# lang and status for them. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1909 |
lang = '~' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1910 |
status = '~' |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1911 |
for m in maintainers[1:]: |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1912 |
maintainer = m[0] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1913 |
email = m[1] |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1914 |
trlst.append(latexLineTpl % (lang, maintainer, email, status)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1915 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1916 |
# Join the table lines and insert into the template. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1917 |
latexTable = latexTableTpl % (''.join(trlst)) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1918 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1919 |
# Do the LaTeX replacements. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1920 |
latexTable = latexTable.replace('á', "\\'{a}") |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1921 |
latexTable = latexTable.replace('Á', "\\'{A}") |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1922 |
latexTable = latexTable.replace('ä', '\\"{a}') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1923 |
latexTable = latexTable.replace('ö', '\\"{o}') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1924 |
latexTable = latexTable.replace('ø', '\\o{}') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1925 |
latexTable = latexTable.replace('č', '\\v{c}') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1926 |
latexTable = latexTable.replace('ř', '\\v{r}') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1927 |
latexTable = latexTable.replace('š', '\\v{s}') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1928 |
latexTable = latexTable.replace('ž', '\\v{z}') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1929 |
latexTable = latexTable.replace('_', '\\_') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1930 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1931 |
# Put the HTML and LaTeX parts together and define the dic item. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1932 |
tplDic['informationTable'] = htmlTable + '\n' + latexTable |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1933 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1934 |
# Insert the symbols into the document template and write it down. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1935 |
f = file(fDocName, 'w') |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1936 |
f.write(doctpl % tplDic) |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1937 |
f.close() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1938 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1939 |
if __name__ == '__main__': |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1940 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1941 |
# Create the manager, build the transl objects, and parse the related |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1942 |
# sources. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1943 |
trMan = TrManager() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1944 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1945 |
# Generate the language.doc. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1946 |
trMan.generateLanguageDoc() |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1947 |
|
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1948 |
# Generate the translator report. |
42188c7ea2d9
Initial contribution of ORB delivering Feature bug 1460
szarinda <>
parents:
diff
changeset
|
1949 |
trMan.generateTranslatorReport() |