~lgs/zcadoc/book

« back to all changes in this revision

Viewing changes to TODO-fr-generator.py

  • Committer: Lorenzo Gil Sanchez
  • Date: 2007-12-18 19:10:32 UTC
  • mfrom: (31.1.17 book)
  • Revision ID: lgs@sicem.biz-20071218191032-18dsf0fltgjc2vzn
Merged from Baiju's branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from text_table import TextTable
 
2
from enum import Enum
 
3
 
 
4
TRANSLATED_STATUS = Enum("WIP", "Y", "N")
 
5
REREADED_STATUS = Enum("WIP", "Y", "N")
 
6
DONE_STATUS = Enum("Y", "N")
 
7
NOTE_LEVEL = Enum("-", "1", "2", "3", "4", "5")
 
8
 
 
9
 
 
10
heading_content = ("Chapter or section name", "TRANSLATED", "REREADED", "DONE", "NOTE")
 
11
 
 
12
table_content = (
 
13
    (" * Getting started",                          TRANSLATED_STATUS.WIP, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
14
    ("       o Introduction",                       TRANSLATED_STATUS.Y, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]), 
 
15
    ("       o A brief history",                    TRANSLATED_STATUS.Y, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
16
    ("       o Installation",                       TRANSLATED_STATUS.Y, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
17
    ("       o Experimenting with code",            TRANSLATED_STATUS.Y, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
18
    (" * An example",                               TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
19
    ("       o Introduction",                       TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
20
    ("       o Procedural approach",                TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
21
    ("       o Object oriented approach",           TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
22
    ("       o The adapter pattern",                TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
23
    (" * Interfaces",                               TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
24
    ("       o Introduction",                       TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
25
    ("       o Declaring interfaces",               TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
26
    ("       o Implementing interfaces",            TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
27
    ("       o Example revisited",                  TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
28
    ("       o Marker interfaces",                  TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
29
    ("       o Invariants",                         TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
30
    (" * Adapters",                                 TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
31
    ("       o Implementation",                     TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
32
    ("       o Registration",                       TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
33
    ("       o Querying adapter",                   TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
34
    ("       o Retrieving adapter using interface", TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
35
    ("       o Adapter pattern",                    TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
36
    (" * Utility",                                  TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
37
    ("       o Introduction",                       TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
38
    ("       o Simple utility",                     TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
39
    ("       o Named utility",                      TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
40
    ("       o Factory",                            TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
41
    (" * Advanced adapters",                        TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
42
    ("       o Multi adapter",                      TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
43
    ("       o Subscription adapter",               TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
44
    ("       o Handler",                            TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
45
    (" * ZCA usage in Zope",                        TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
46
    ("       o ZCML",                               TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
47
    ("       o Overrides",                          TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
48
    ("       o NameChooser",                        TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
49
    ("       o LocationPhysicallyLocatable",        TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
50
    ("       o DefaultSized",                       TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
51
    ("       o ZopeVersionUtility",                 TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
52
    (" * Reference",                                TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
53
    ("       o Attribute",                          TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
54
    ("       o Declaration",                        TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
55
    ("       o Interface",                          TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
56
    ("       o adapts",                             TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
57
    ("       o alsoProvides",                       TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
58
    ("       o classImplements",                    TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
59
    ("       o classImplementsOnly",                TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
60
    ("       o classProvides",                      TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
61
    ("       o ComponentLookupError",               TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
62
    ("       o createObject",                       TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
63
    ("       o directlyProvidedBy",                 TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
64
    ("       o directlyProvides",                   TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
65
    ("       o getAdapter",                         TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
66
    ("       o getAdapterInContext",                TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
67
    ("       o getAdapters",                        TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
68
    ("       o getAllUtilitiesRegisteredFor",       TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
69
    ("       o getFactoriesFor",                    TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
70
    ("       o getFactoryInterfaces",               TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
71
    ("       o getGlobalSiteManager",               TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
72
    ("       o getMultiAdapter",                    TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
73
    ("       o getSiteManager",                     TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
74
    ("       o getUtilitiesFor",                    TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
75
    ("       o getUtility",                         TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
76
    ("       o handle",                             TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
77
    ("       o implementedBy",                      TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
78
    ("       o implementer",                        TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
79
    ("       o implements",                         TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
80
    ("       o implementsOnly",                     TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
81
    ("       o moduleProvides",                     TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
82
    ("       o noLongerProvides",                   TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
83
    ("       o provideAdapter",                     TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
84
    ("       o provideHandler",                     TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
85
    ("       o provideSubscriptionAdapter",         TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
86
    ("       o provideUtility",                     TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
87
    ("       o providedBy",                         TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
88
    ("       o queryAdapter",                       TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
89
    ("       o queryAdapterInContext",              TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
90
    ("       o queryMultiAdapter",                  TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
91
    ("       o queryUtility",                       TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
92
    ("       o registerAdapter",                    TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
93
    ("       o registeredAdapters",                 TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
94
    ("       o registeredHandlers",                 TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
95
    ("       o registeredSubscriptionAdapters",     TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
96
    ("       o registeredUtilities",                TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
97
    ("       o registerHandler",                    TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
98
    ("       o registerSubscriptionAdapter",        TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
99
    ("       o registerUtility",                    TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
100
    ("       o subscribers",                        TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
101
    ("       o unregisterAdapter",                  TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
102
    ("       o unregisterHandler",                  TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
103
    ("       o unregisterSubscriptionAdapter",      TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0]),
 
104
    ("       o unregisterUtility",                  TRANSLATED_STATUS.N, REREADED_STATUS.N, DONE_STATUS.N, NOTE_LEVEL[0])
 
105
)
 
106
 
 
107
column_greater_size_content = [0, 0, 0, 0, 0]
 
108
 
 
109
#summary_value = {
 
110
#    "TRANSLATED" : { "YES" : 0, "WIP": 0 },
 
111
#    "REREADED" :  { "YES" : 0 },
 
112
#    "DONE" : { "YES" : 0 }
 
113
#}
 
114
 
 
115
summary_value = {
 
116
    TRANSLATED_STATUS.Y : 0,
 
117
    TRANSLATED_STATUS.WIP : 0,
 
118
    REREADED_STATUS.Y : 0,
 
119
    REREADED_STATUS.WIP : 0,
 
120
    DONE_STATUS.Y: 0
 
121
}
 
122
 
 
123
for row in (heading_content,) + table_content:
 
124
    for col_index in range(0, len(row)):
 
125
        if (len(str(row[col_index])) > column_greater_size_content[col_index]):
 
126
            column_greater_size_content[col_index] = len(str(row[col_index]))
 
127
       
 
128
        if (summary_value.has_key(row[col_index])):
 
129
            summary_value[row[col_index]] = summary_value[row[col_index]] + 1
 
130
 
 
131
ascii_table_content = TextTable(
 
132
    *tuple([(column_greater_size_content[i], heading_content[i]) for i in range(0, 5)])
 
133
)
 
134
 
 
135
for row in table_content:
 
136
    ascii_table_content.row(*(((row[0]),) + tuple([str(row[col_index]).center(column_greater_size_content[col_index]) for col_index in range(1, len(row))])))
 
137
 
 
138
 
 
139
summary_content = (
 
140
    ("Translated", str(str(summary_value[TRANSLATED_STATUS.Y]) + " / " + str(len(table_content)) + " (" + str((summary_value[TRANSLATED_STATUS.Y] * 100) / len(table_content)) + " %) , " + str(summary_value[TRANSLATED_STATUS.WIP]) + " in WIP")),
 
141
    ("Rereaded", str(str(summary_value[REREADED_STATUS.Y]) + " / " + str(len(table_content)) + " (" + str((summary_value[REREADED_STATUS.Y] * 100) / len(table_content)) + " %) , " + str(summary_value[REREADED_STATUS.WIP]) + " in WIP")),
 
142
    ("Done", str(str(summary_value[DONE_STATUS.Y]) + " / " + str(len(table_content)) + " (" + str((summary_value[DONE_STATUS.Y] * 100) / len(table_content)) + " %)"))
 
143
)
 
144
 
 
145
ascii_summary_content = TextTable((12), (28))
 
146
for row in summary_content:
 
147
    ascii_summary_content.row(*row)
 
148
 
 
149
print(
 
150
"""
 
151
This file contain some informations about the growth of french
 
152
translation.
 
153
 
 
154
This file is generate by TODO-fr-generator.py script file.
 
155
 
 
156
Summary
 
157
=======
 
158
""")
 
159
 
 
160
 
 
161
print(ascii_summary_content.draw())
 
162
 
 
163
print("""
 
164
Detail table
 
165
============
 
166
 
 
167
Fields values :
 
168
 
 
169
 * Translated column can be Yes, No, WIP (Work In Progress)
 
170
 * Rereaded column can be Yes, No, WIP (Work In Progress)
 
171
 * Done column can be Yes, No
 
172
 * Note column can be "-" or 1 to 5, it's quality note
 
173
 
 
174
""")
 
175
 
 
176
print ascii_table_content.draw()
 
177
 
 
178