[Erp5-report] r15668 - in /erp5/trunk/bt5/erp5_forge: ExtensionTemplateItem/ SkinTemplateIt...
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Aug 14 15:46:16 CEST 2007
Author: yusei
Date: Tue Aug 14 15:46:16 2007
New Revision: 15668
URL: http://svn.erp5.org?rev=15668&view=rev
Log:
2007-08-14 Yusei
* Add utility scripts to collect translation messages.
Added:
erp5/trunk/bt5/erp5_forge/ExtensionTemplateItem/PythonScriptParserUtility.py
erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Base_getFunctionFirstArgumentValue.xml
erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromPythonScriptListAsPot.xml
erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromWorkflowListAsPot.xml
Modified:
erp5/trunk/bt5/erp5_forge/bt/change_log
erp5/trunk/bt5/erp5_forge/bt/revision
erp5/trunk/bt5/erp5_forge/bt/template_extension_id_list
Added: erp5/trunk/bt5/erp5_forge/ExtensionTemplateItem/PythonScriptParserUtility.py
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_forge/ExtensionTemplateItem/PythonScriptParserUtility.py?rev=15668&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_forge/ExtensionTemplateItem/PythonScriptParserUtility.py (added)
+++ erp5/trunk/bt5/erp5_forge/ExtensionTemplateItem/PythonScriptParserUtility.py Tue Aug 14 15:46:16 2007
@@ -1,0 +1,49 @@
+import compiler
+import compiler.ast
+import compiler.visitor
+
+
+class Visitor(compiler.visitor.ASTVisitor):
+
+ def __init__(self, func_name):
+ self.func_name = func_name
+ compiler.visitor.ASTVisitor.__init__(self)
+ self.result = []
+
+ def visitCallFunc(self, node, *args):
+ if (isinstance(node.node, compiler.ast.Name) and
+ node.node.name==self.func_name):
+ arg = node.args[0]
+ value = None
+ if isinstance(arg, compiler.ast.Const):
+ value = arg.value
+ elif isinstance(arg, compiler.ast.Add):
+ value = concatenate_add_const_value(arg)
+ if value is not None:
+ self.result.append(value)
+
+
+def concatenate_add_const_value(node):
+ def iterate(nodes):
+ if not nodes:
+ return ''
+ node = nodes[0]
+ if isinstance(node, compiler.ast.Const):
+ return node.value + iterate(nodes[1:])
+ elif isinstance(node, compiler.ast.Add):
+ if getattr(node, 'nodes', None):
+ children_nodes = node.nodes
+ else:
+ children_nodes = (node.left, node.right)
+ return iterate(children_nodes)+iterate(nodes[1:])
+ elif isinstance(node, compiler.ast.Mod):
+ # we can't handle Mod node statically.
+ pass
+ return iterate((node,))
+
+
+def getFunctionFirstArgumentValue(func_name, source):
+ ast = compiler.parse(source)
+ visitor = Visitor(func_name)
+ compiler.walk(ast, visitor)
+ return visitor.result
Added: erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Base_getFunctionFirstArgumentValue.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Base_getFunctionFirstArgumentValue.xml?rev=15668&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Base_getFunctionFirstArgumentValue.xml (added)
+++ erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Base_getFunctionFirstArgumentValue.xml Tue Aug 14 15:46:16 2007
@@ -1,0 +1,46 @@
+<?xml version="1.0"?>
+<ZopeData>
+ <record id="1" aka="AAAAAAAAAAE=">
+ <pickle>
+ <tuple>
+ <tuple>
+ <string>Products.ExternalMethod.ExternalMethod</string>
+ <string>ExternalMethod</string>
+ </tuple>
+ <none/>
+ </tuple>
+ </pickle>
+ <pickle>
+ <dictionary>
+ <item>
+ <key> <string>__ac_local_roles__</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_function</string> </key>
+ <value> <string>getFunctionFirstArgumentValue</string> </value>
+ </item>
+ <item>
+ <key> <string>_module</string> </key>
+ <value> <string>PythonScriptParserUtility</string> </value>
+ </item>
+ <item>
+ <key> <string>_owner</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>id</string> </key>
+ <value> <string>Base_getFunctionFirstArgumentValue</string> </value>
+ </item>
+ <item>
+ <key> <string>title</string> </key>
+ <value> <string></string> </value>
+ </item>
+ </dictionary>
+ </pickle>
+ </record>
+</ZopeData>
Added: erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromPythonScriptListAsPot.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromPythonScriptListAsPot.xml?rev=15668&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromPythonScriptListAsPot.xml (added)
+++ erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromPythonScriptListAsPot.xml Tue Aug 14 15:46:16 2007
@@ -1,0 +1,188 @@
+<?xml version="1.0"?>
+<ZopeData>
+ <record id="1" aka="AAAAAAAAAAE=">
+ <pickle>
+ <tuple>
+ <tuple>
+ <string>Products.PythonScripts.PythonScript</string>
+ <string>PythonScript</string>
+ </tuple>
+ <none/>
+ </tuple>
+ </pickle>
+ <pickle>
+ <dictionary>
+ <item>
+ <key> <string>Python_magic</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>Script_magic</string> </key>
+ <value> <int>3</int> </value>
+ </item>
+ <item>
+ <key> <string>__ac_local_roles__</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_bind_names</string> </key>
+ <value>
+ <object>
+ <klass>
+ <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+ </klass>
+ <tuple/>
+ <state>
+ <dictionary>
+ <item>
+ <key> <string>_asgns</string> </key>
+ <value>
+ <dictionary>
+ <item>
+ <key> <string>name_container</string> </key>
+ <value> <string>container</string> </value>
+ </item>
+ <item>
+ <key> <string>name_context</string> </key>
+ <value> <string>context</string> </value>
+ </item>
+ <item>
+ <key> <string>name_m_self</string> </key>
+ <value> <string>script</string> </value>
+ </item>
+ <item>
+ <key> <string>name_subpath</string> </key>
+ <value> <string>traverse_subpath</string> </value>
+ </item>
+ </dictionary>
+ </value>
+ </item>
+ </dictionary>
+ </state>
+ </object>
+ </value>
+ </item>
+ <item>
+ <key> <string>_body</string> </key>
+ <value> <string>items = []\n
+def iterate(obj):\n
+ for i in obj.objectValues():\n
+ if i.isPrincipiaFolderish:\n
+ iterate(i)\n
+ elif i.meta_type==\'Script (Python)\':\n
+ items.append(i)\n
+\n
+iterate(context.portal_skins)\n
+\n
+FUNC_NAME = \'N_\'\n
+CALL_FUNC_NAME = \'%s(\' % FUNC_NAME\n
+\n
+result = {}\n
+for i in items:\n
+ source = i.body()\n
+ if CALL_FUNC_NAME in source:\n
+ for m in context.Base_getFunctionFirstArgumentValue(FUNC_NAME, source):\n
+ result[m] = None\n
+\n
+for i in result:\n
+ print \'msgid "%s"\' % repr(i)[1:-1]\n
+ print \'msgstr ""\'\n
+ print\n
+return printed\n
+</string> </value>
+ </item>
+ <item>
+ <key> <string>_code</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_filepath</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_owner</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_params</string> </key>
+ <value> <string></string> </value>
+ </item>
+ <item>
+ <key> <string>errors</string> </key>
+ <value>
+ <tuple/>
+ </value>
+ </item>
+ <item>
+ <key> <string>func_code</string> </key>
+ <value>
+ <object>
+ <klass>
+ <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
+ </klass>
+ <tuple/>
+ <state>
+ <dictionary>
+ <item>
+ <key> <string>co_argcount</string> </key>
+ <value> <int>0</int> </value>
+ </item>
+ <item>
+ <key> <string>co_varnames</string> </key>
+ <value>
+ <tuple>
+ <string>_print_</string>
+ <string>_print</string>
+ <string>items</string>
+ <string>iterate</string>
+ <string>_getattr_</string>
+ <string>context</string>
+ <string>FUNC_NAME</string>
+ <string>CALL_FUNC_NAME</string>
+ <string>result</string>
+ <string>_getiter_</string>
+ <string>i</string>
+ <string>source</string>
+ <string>m</string>
+ <string>None</string>
+ <string>_write_</string>
+ <string>_getitem_</string>
+ <string>repr</string>
+ </tuple>
+ </value>
+ </item>
+ </dictionary>
+ </state>
+ </object>
+ </value>
+ </item>
+ <item>
+ <key> <string>func_defaults</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>id</string> </key>
+ <value> <string>ERP5Site_getToBeTranslatedMessageListFromPythonScriptListAsPot</string> </value>
+ </item>
+ <item>
+ <key> <string>warnings</string> </key>
+ <value>
+ <tuple/>
+ </value>
+ </item>
+ </dictionary>
+ </pickle>
+ </record>
+</ZopeData>
Added: erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromWorkflowListAsPot.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromWorkflowListAsPot.xml?rev=15668&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromWorkflowListAsPot.xml (added)
+++ erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromWorkflowListAsPot.xml Tue Aug 14 15:46:16 2007
@@ -1,0 +1,183 @@
+<?xml version="1.0"?>
+<ZopeData>
+ <record id="1" aka="AAAAAAAAAAE=">
+ <pickle>
+ <tuple>
+ <tuple>
+ <string>Products.PythonScripts.PythonScript</string>
+ <string>PythonScript</string>
+ </tuple>
+ <none/>
+ </tuple>
+ </pickle>
+ <pickle>
+ <dictionary>
+ <item>
+ <key> <string>Python_magic</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>Script_magic</string> </key>
+ <value> <int>3</int> </value>
+ </item>
+ <item>
+ <key> <string>__ac_local_roles__</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_bind_names</string> </key>
+ <value>
+ <object>
+ <klass>
+ <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+ </klass>
+ <tuple/>
+ <state>
+ <dictionary>
+ <item>
+ <key> <string>_asgns</string> </key>
+ <value>
+ <dictionary>
+ <item>
+ <key> <string>name_container</string> </key>
+ <value> <string>container</string> </value>
+ </item>
+ <item>
+ <key> <string>name_context</string> </key>
+ <value> <string>context</string> </value>
+ </item>
+ <item>
+ <key> <string>name_m_self</string> </key>
+ <value> <string>script</string> </value>
+ </item>
+ <item>
+ <key> <string>name_subpath</string> </key>
+ <value> <string>traverse_subpath</string> </value>
+ </item>
+ </dictionary>
+ </value>
+ </item>
+ </dictionary>
+ </state>
+ </object>
+ </value>
+ </item>
+ <item>
+ <key> <string>_body</string> </key>
+ <value> <string>messages = {}\n
+\n
+def memo(o, t):\n
+ return \'%s:::%s\' % (t, o.aq_parent.aq_parent.id)\n
+\n
+\n
+for i in context.portal_workflow.objectValues():\n
+ if not i.states:\n
+ continue\n
+ for s in i.states.values():\n
+ if s.title:\n
+ messages[s.title] = None\n
+\n
+ if not i.transitions:\n
+ continue\n
+ for t in i.transitions.values():\n
+ if t.actbox_name:\n
+ messages[t.actbox_name] = None\n
+\n
+for i in messages.keys():\n
+ print \'msgid "%s"\' % i\n
+ print \'msgstr ""\'\n
+ print\n
+\n
+return printed\n
+</string> </value>
+ </item>
+ <item>
+ <key> <string>_code</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_filepath</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_owner</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_params</string> </key>
+ <value> <string></string> </value>
+ </item>
+ <item>
+ <key> <string>errors</string> </key>
+ <value>
+ <tuple/>
+ </value>
+ </item>
+ <item>
+ <key> <string>func_code</string> </key>
+ <value>
+ <object>
+ <klass>
+ <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
+ </klass>
+ <tuple/>
+ <state>
+ <dictionary>
+ <item>
+ <key> <string>co_argcount</string> </key>
+ <value> <int>0</int> </value>
+ </item>
+ <item>
+ <key> <string>co_varnames</string> </key>
+ <value>
+ <tuple>
+ <string>_print_</string>
+ <string>_print</string>
+ <string>messages</string>
+ <string>memo</string>
+ <string>_getiter_</string>
+ <string>_getattr_</string>
+ <string>context</string>
+ <string>i</string>
+ <string>s</string>
+ <string>None</string>
+ <string>_write_</string>
+ <string>t</string>
+ </tuple>
+ </value>
+ </item>
+ </dictionary>
+ </state>
+ </object>
+ </value>
+ </item>
+ <item>
+ <key> <string>func_defaults</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>id</string> </key>
+ <value> <string>ERP5Site_getToBeTranslatedMessageListFromWorkflowListAsPot</string> </value>
+ </item>
+ <item>
+ <key> <string>warnings</string> </key>
+ <value>
+ <tuple/>
+ </value>
+ </item>
+ </dictionary>
+ </pickle>
+ </record>
+</ZopeData>
Modified: erp5/trunk/bt5/erp5_forge/bt/change_log
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_forge/bt/change_log?rev=15668&r1=15667&r2=15668&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_forge/bt/change_log (original)
+++ erp5/trunk/bt5/erp5_forge/bt/change_log Tue Aug 14 15:46:16 2007
@@ -1,3 +1,6 @@
+2007-08-14 Yusei
+* Add utility scripts to collect translation messages.
+
2007-08-14 Yusei
* Add glossary module.
Modified: erp5/trunk/bt5/erp5_forge/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_forge/bt/revision?rev=15668&r1=15667&r2=15668&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_forge/bt/revision (original)
+++ erp5/trunk/bt5/erp5_forge/bt/revision Tue Aug 14 15:46:16 2007
@@ -1,1 +1,1 @@
-153
+158
Modified: erp5/trunk/bt5/erp5_forge/bt/template_extension_id_list
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_forge/bt/template_extension_id_list?rev=15668&r1=15667&r2=15668&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_forge/bt/template_extension_id_list (original)
+++ erp5/trunk/bt5/erp5_forge/bt/template_extension_id_list Tue Aug 14 15:46:16 2007
@@ -1,1 +1,2 @@
-Glossary
+Glossary
+PythonScriptParserUtility
More information about the Erp5-report
mailing list