Commit 9f2fa835 authored by Jérome Perrin's avatar Jérome Perrin

forge: fix pylint warnings and enable coding style test

parent 6f622d9b
...@@ -49,7 +49,7 @@ def getActionTitleListFromAllActionProvider(portal): ...@@ -49,7 +49,7 @@ def getActionTitleListFromAllActionProvider(portal):
for provider in provider_list: for provider in provider_list:
for action in provider.listActions(): for action in provider.listActions():
result.append((action.title, provider.getId())) result.append((action.title, provider.getId()))
return result return result
...@@ -60,10 +60,10 @@ from zope.tal.talgenerator import TALGenerator ...@@ -60,10 +60,10 @@ from zope.tal.talgenerator import TALGenerator
from zope.tal.dummyengine import name_match from zope.tal.dummyengine import name_match
def findStaticTranslationText(page_template, func_name_list): def findStaticTranslationText(page_template, func_name_list):
def iterate(node, target_name, function): def iterate(node, target_name, function):
if type(node) is list: if isinstance(node, list):
for i in node: for i in node:
iterate(i, target_name, function) iterate(i, target_name, function)
elif type(node) is tuple and node: elif isinstance(node, tuple) and node:
if node[0]==target_name: if node[0]==target_name:
function(node) function(node)
else: else:
...@@ -100,8 +100,8 @@ def findStaticTranslationText(page_template, func_name_list): ...@@ -100,8 +100,8 @@ def findStaticTranslationText(page_template, func_name_list):
tal_expression = tal_expression[1:-1] tal_expression = tal_expression[1:-1]
match = name_match(tal_expression) match = name_match(tal_expression)
if match: if match:
type, expression = match.group(1, 2) type_, expression = match.group(1, 2)
if type=='python': if type_=='python':
# clean up expression # clean up expression
expression = expression.strip() expression = expression.strip()
expression = expression.replace('\n', ' ') expression = expression.replace('\n', ' ')
...@@ -139,7 +139,7 @@ class MyDummyTALInterpreter(TALInterpreter): ...@@ -139,7 +139,7 @@ class MyDummyTALInterpreter(TALInterpreter):
_i18n_message_id_dict = None _i18n_message_id_dict = None
_currentTag = None _currentTag = None
def translate(self, msgid, default=None, i18ndict=None, obj=None): def translate(self, msgid, default=None, i18ndict=None, obj=None): # pylint:disable=arguments-differ
try: try:
self._i18n_message_id_dict[msgid] = None self._i18n_message_id_dict[msgid] = None
except TypeError: except TypeError:
......
...@@ -6,10 +6,22 @@ ...@@ -6,10 +6,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>Glossary</string> </value> <value> <string>Glossary</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>extension.erp5.Glossary</string> </value> <value> <string>extension.erp5.Glossary</string> </value>
...@@ -24,6 +36,18 @@ ...@@ -24,6 +36,18 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item> <item>
<key> <string>version</string> </key> <key> <string>version</string> </key>
<value> <string>erp5</string> </value> <value> <string>erp5</string> </value>
...@@ -31,13 +55,28 @@ ...@@ -31,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -50,7 +89,7 @@ ...@@ -50,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -59,7 +98,7 @@ ...@@ -59,7 +98,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle> </pickle>
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# pylint: disable-all
############################################################################## ##############################################################################
# #
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
......
...@@ -80,7 +80,7 @@ class SubversionLoginError(SubversionError): ...@@ -80,7 +80,7 @@ class SubversionLoginError(SubversionError):
""" """
# Declarative Security # Declarative Security
security = ClassSecurityInfo() security = ClassSecurityInfo()
def __init__(self, realm = None): def __init__(self, realm = None): # pylint:disable=super-init-not-called
self._realm = realm self._realm = realm
security.declarePublic('getRealm') security.declarePublic('getRealm')
...@@ -96,7 +96,7 @@ class SubversionSSLTrustError(SubversionError): ...@@ -96,7 +96,7 @@ class SubversionSSLTrustError(SubversionError):
# Declarative Security # Declarative Security
security = ClassSecurityInfo() security = ClassSecurityInfo()
def __init__(self, trust_dict = None): def __init__(self, trust_dict = None): # pylint:disable=super-init-not-called
self._trust_dict = trust_dict self._trust_dict = trust_dict
security.declarePublic('getTrustDict') security.declarePublic('getTrustDict')
...@@ -134,7 +134,7 @@ try: ...@@ -134,7 +134,7 @@ try:
return False, '' return False, ''
class GetLoginCallback(Callback): class GetLoginCallback(Callback):
def __call__(self, realm, username, may_save): def __call__(self, realm, username, may_save): # pylint:disable=arguments-differ
user, password = self.client.getLogin(realm) user, password = self.client.getLogin(realm)
if not username or not password: if not username or not password:
self.client.setException(SubversionLoginError(realm)) self.client.setException(SubversionLoginError(realm))
...@@ -147,12 +147,12 @@ try: ...@@ -147,12 +147,12 @@ try:
return True, user, password, False return True, user, password, False
class NotifyCallback(Callback): class NotifyCallback(Callback):
def __call__(self, event_dict): def __call__(self, event_dict): # pylint:disable=arguments-differ
# FIXME: should accumulate information for the user # FIXME: should accumulate information for the user
pass pass
class SSLServerTrustPromptCallback(Callback): class SSLServerTrustPromptCallback(Callback):
def __call__(self, trust_dict): def __call__(self, trust_dict): # pylint:disable=arguments-differ
if not self.client.trustSSLServer(trust_dict): if not self.client.trustSSLServer(trust_dict):
self.client.setException(SubversionSSLTrustError(trust_dict)) self.client.setException(SubversionSSLTrustError(trust_dict))
return False, 0, False return False, 0, False
......
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>SubversionClient</string> </value> <value> <string>SubversionClient</string> </value>
...@@ -43,13 +49,7 @@ ...@@ -43,13 +49,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W: 83, 2: __init__ method from base class \'SubversionError\' is not called (super-init-not-called)</string>
<string>W: 99, 2: __init__ method from base class \'SubversionError\' is not called (super-init-not-called)</string>
<string>W:137, 4: Arguments number differs from overridden \'__call__\' method (arguments-differ)</string>
<string>W:150, 4: Arguments number differs from overridden \'__call__\' method (arguments-differ)</string>
<string>W:155, 4: Arguments number differs from overridden \'__call__\' method (arguments-differ)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -59,13 +59,28 @@ ...@@ -59,13 +59,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -78,7 +93,7 @@ ...@@ -78,7 +93,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -87,7 +102,7 @@ ...@@ -87,7 +102,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
...@@ -36,7 +36,7 @@ from AccessControl import Unauthorized ...@@ -36,7 +36,7 @@ from AccessControl import Unauthorized
from AccessControl.SecurityManagement import getSecurityManager from AccessControl.SecurityManagement import getSecurityManager
from AccessControl.SecurityInfo import ModuleSecurityInfo from AccessControl.SecurityInfo import ModuleSecurityInfo
from Acquisition import aq_base, Implicit from Acquisition import aq_base, Implicit
from App.config import getConfiguration from App.config import getConfiguration # pylint:disable=no-name-in-module,import-error
from DateTime import DateTime from DateTime import DateTime
from ZTUtils import make_query from ZTUtils import make_query
from Products.ERP5.Document.BusinessTemplate import BusinessTemplateFolder from Products.ERP5.Document.BusinessTemplate import BusinessTemplateFolder
......
from erp5.component.module.SubversionClient import SubversionSSLTrustError
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
portal = context.getPortalObject() portal = context.getPortalObject()
......
...@@ -18,10 +18,10 @@ if from_url is None: ...@@ -18,10 +18,10 @@ if from_url is None:
user = context.portal_membership.getAuthenticatedMember().getUserName() user = context.portal_membership.getAuthenticatedMember().getUserName()
from_url = '"%s" <%s>' % (user, from_url = '"%s" <%s>' % (user,
context.email_from_address) context.email_from_address)
# Return-Path # Return-Path. TODO: this is not implemented
if reply_url is None: if reply_url is None:
reply_url = context.portal_preferences.getPreferredEventSenderEmail() reply_url = context.portal_preferences.getPreferredEventSenderEmail()
additional_headers = None additional_headers = None # pylint: disable=unused-variable
if reply_url: if reply_url:
additional_headers = {'Return-Path':reply_url} additional_headers = {'Return-Path':reply_url}
...@@ -44,7 +44,6 @@ elif same_type(to_url, ''): ...@@ -44,7 +44,6 @@ elif same_type(to_url, ''):
# Attachments # Attachments
if attachment_list is None: if attachment_list is None:
attachment_list = [] attachment_list = []
document_type_list = context.getPortalDocumentTypeList()
for attachment in context.getAggregateValueList(): for attachment in context.getAggregateValueList():
mime_type, content = attachment.getMimeTypeAndContent() mime_type, content = attachment.getMimeTypeAndContent()
name = attachment.getReference() name = attachment.getReference()
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
This script creates a new event with given metadata and This script creates a new event with given metadata and
attaches it to the current ticket. attaches it to the current ticket.
""" """
# pylint:disable=redefined-builtin
# this script uses file= argument
translateString = context.Base_translateString translateString = context.Base_translateString
default_bug_line = getattr(context, "default_bug_line", None) default_bug_line = getattr(context, "default_bug_line", None)
......
"""Return a po file from a spreadsheet of categories.""" """Return a po file from a spreadsheet of categories."""
from Products.ERP5Type.Message import translateString
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
# Initialise some general variables # Initialise some general variables
detailed_report_result = [] detailed_report_result = []
detailed_report_append = detailed_report_result.append detailed_report_append = detailed_report_result.append
category_dict = {}
translation_dict = {} translation_dict = {}
translated_attributes_list = ["title", "description", "short_title"] translated_attributes_list = ["title", "description", "short_title"]
import_filename = getattr(import_file, 'filename', '?') import_filename = getattr(import_file, 'filename', '?')
...@@ -31,14 +29,11 @@ def invalid_category_spreadsheet_handler(message): ...@@ -31,14 +29,11 @@ def invalid_category_spreadsheet_handler(message):
category_list_mapping = context.Base_getCategoriesSpreadSheetMapping(import_file, category_list_mapping = context.Base_getCategoriesSpreadSheetMapping(import_file,
invalid_spreadsheet_error_handler=invalid_category_spreadsheet_handler) invalid_spreadsheet_error_handler=invalid_category_spreadsheet_handler)
if category_list_mapping.has_key('error_list'): assert 'error_list' not in category_list_mapping
context.REQUEST.other['category_import_report'] = initial_category_list_mapping['error_list']
return context.CategoryTool_viewImportReport()
#Process on each category #Process on each category
for base_category, category_list in category_list_mapping.items(): for category_list in category_list_mapping.values():
for category in category_list: for category in category_list:
#Take only needed attributes #Take only needed attributes
for attribute in translated_attributes_list: for attribute in translated_attributes_list:
......
...@@ -6,8 +6,7 @@ for o in template_tool.contentValues(portal_type='Business Template'): ...@@ -6,8 +6,7 @@ for o in template_tool.contentValues(portal_type='Business Template'):
if portal_type in o.getTemplatePortalTypeIdList(): if portal_type in o.getTemplatePortalTypeIdList():
matching.append(o.getUid()) matching.append(o.getUid())
else: else:
allowed_content_type_list = o.getTemplatePortalTypeAllowedContentTypeList() allowed_content_type_list = [x for x in o.getTemplatePortalTypeAllowedContentTypeList() if x and x.split('|')[1].strip()]
allowed_content_type_list = map(lambda x: x and x.split('|')[1].strip(), allowed_content_type_list)
if portal_type in allowed_content_type_list: if portal_type in allowed_content_type_list:
matching.append(o.getUid()) matching.append(o.getUid())
......
...@@ -17,7 +17,7 @@ for i in catalog(portal_type='Glossary Term', ...@@ -17,7 +17,7 @@ for i in catalog(portal_type='Glossary Term',
language_id=language) is not None: language_id=language) is not None:
continue continue
new_term = glossary_module.newContent(portal_type='Glossary Term', glossary_module.newContent(portal_type='Glossary Term',
reference=reference, reference=reference,
business_field=business_field, business_field=business_field,
language=language, language=language,
......
...@@ -2,10 +2,10 @@ result = context.GlossaryModule_getTermDictListFromPortalType(portal_type_list) ...@@ -2,10 +2,10 @@ result = context.GlossaryModule_getTermDictListFromPortalType(portal_type_list)
if export_tsv: if export_tsv:
for i in result: for i in result:
print '\t'.join(map(lambda x:'"%s"'%x, (i['reference'], i['language'], print '\t'.join(['"%s"' % x for x in (i['reference'], i['language'],
i['business_field'], i['business_field'],
i['title'], i['description'], i['title'], i['description'],
i['field_path']))) i['field_path'])])
return printed return printed
else: else:
portal_catalog = context.portal_catalog portal_catalog = context.portal_catalog
......
...@@ -2,10 +2,10 @@ result = context.GlossaryModule_getTermDictListFromPropertySheet(property_sheet_ ...@@ -2,10 +2,10 @@ result = context.GlossaryModule_getTermDictListFromPropertySheet(property_sheet_
if export_tsv: if export_tsv:
for i in result: for i in result:
print '\t'.join(map(lambda x:'"%s"'%x, (i['reference'], i['language'], print '\t'.join(['"%s"' % x for x in (i['reference'], i['language'],
i['business_field'], i['business_field'],
i['title'], i['description'], i['title'], i['description'],
i['field_path']))) i['field_path'])])
return printed return printed
else: else:
portal_catalog = context.portal_catalog portal_catalog = context.portal_catalog
......
...@@ -2,9 +2,11 @@ result = context.GlossaryModule_getTermDictListFromWorkflow(template_list) ...@@ -2,9 +2,11 @@ result = context.GlossaryModule_getTermDictListFromWorkflow(template_list)
if export_tsv: if export_tsv:
for i in result: for i in result:
print '\t'.join(map(lambda x:'"%s"'%x, (i['reference'], i['language'],
print '\t'.join(['"%s"' % x for x in (i['reference'], i['language'],
i['business_field'], i['business_field'],
i['title'], i['description'], i['workflow_id']))) i['title'], i['description'],
i['workflow_id'])])
return printed return printed
else: else:
portal_catalog = context.portal_catalog portal_catalog = context.portal_catalog
......
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
result = []
portal_catalog = context.portal_catalog portal_catalog = context.portal_catalog
portal_skins = context.portal_skins portal_skins = context.portal_skins
......
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
result = []
portal_catalog = context.portal_catalog portal_catalog = context.portal_catalog
portal_skins = context.portal_skins
def get_term_list(reference): def get_term_list(reference):
reference = reference.rsplit(' Module', 1)[0] reference = reference.rsplit(' Module', 1)[0]
...@@ -26,7 +23,7 @@ for reference in portal_type_list: ...@@ -26,7 +23,7 @@ for reference in portal_type_list:
field_description = portal_type.description field_description = portal_type.description
if len(term_list) == 1 and \ if len(term_list) == 1 and \
term_list[0].getDescription() == field_description: term_list[0].getDescription() == field_description:
continue continue
line = newTempBase(context, 'tmp_glossary_field_%s' % c) line = newTempBase(context, 'tmp_glossary_field_%s' % c)
line.edit(field_path=reference, line.edit(field_path=reference,
......
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
marker = [] marker = []
result = []
portal_catalog = context.portal_catalog portal_catalog = context.portal_catalog
portal_workflow = context.portal_workflow portal_workflow = context.portal_workflow
...@@ -40,7 +39,7 @@ line_list = [] ...@@ -40,7 +39,7 @@ line_list = []
c = 0 c = 0
item_dict = {} item_dict = {}
for business_field in business_field_list: for business_field in business_field_list:
for wf_item, reference, type in get_obj_and_reference_list(business_field): for wf_item, reference, type_ in get_obj_and_reference_list(business_field):
term_list = get_term_list(business_field, reference) term_list = get_term_list(business_field, reference)
#if not term_list: #if not term_list:
# continue # continue
...@@ -49,21 +48,21 @@ for business_field in business_field_list: ...@@ -49,21 +48,21 @@ for business_field in business_field_list:
item_dict[wf_item] = True item_dict[wf_item] = True
c += 1 c += 1
if type == 'workflow': if type_ == 'workflow':
wf_item_path = wf_item.id wf_item_path = wf_item.id
wf_item_title = wf_item.title wf_item_title = wf_item.title
elif type == 'state': elif type_ == 'state':
wf_item_path = '%s/states/%s' % (wf_item.aq_parent.aq_parent.id, wf_item.id) wf_item_path = '%s/states/%s' % (wf_item.aq_parent.aq_parent.id, wf_item.id)
wf_item_title = wf_item.title wf_item_title = wf_item.title
elif type == 'transition': elif type_ == 'transition':
wf_item_path = '%s/transitions/%s' % (wf_item.aq_parent.aq_parent.id, wf_item.id) wf_item_path = '%s/transitions/%s' % (wf_item.aq_parent.aq_parent.id, wf_item.id)
wf_item_title = wf_item.title wf_item_title = wf_item.title
else: # type == 'action' else: # type_ == 'action'
wf_item_path = '%s/transitions/%s_actbox_name' % (wf_item.aq_parent.aq_parent.id, wf_item.id) wf_item_path = '%s/transitions/%s_actbox_name' % (wf_item.aq_parent.aq_parent.id, wf_item.id)
wf_item_title = wf_item.actbox_name wf_item_title = wf_item.actbox_name
wf_item_description = wf_item.description wf_item_description = wf_item.description
if type == 'transition' and wf_item_path.endswith('_action'): if type_ == 'transition' and wf_item_path.endswith('_action'):
if len(term_list) == 1 and \ if len(term_list) == 1 and \
term_list[0].getTitle() + ' Action' == wf_item_title and \ term_list[0].getTitle() + ' Action' == wf_item_title and \
term_list[0].getDescription() == wf_item_description: term_list[0].getDescription() == wf_item_description:
...@@ -76,7 +75,7 @@ for business_field in business_field_list: ...@@ -76,7 +75,7 @@ for business_field in business_field_list:
line = newTempBase(context, 'tmp_glossary_wf_item_%s' % c) line = newTempBase(context, 'tmp_glossary_wf_item_%s' % c)
line.edit(wf_item_path=wf_item_path, line.edit(wf_item_path=wf_item_path,
wf_item_type=type, wf_item_type=type_,
wf_item_title=wf_item_title, wf_item_title=wf_item_title,
wf_item_edit_url = "%s/manage_properties" % wf_item.absolute_url(), wf_item_edit_url = "%s/manage_properties" % wf_item.absolute_url(),
wf_item_description = wf_item_description, wf_item_description = wf_item_description,
......
...@@ -14,13 +14,13 @@ msgstr %s ...@@ -14,13 +14,13 @@ msgstr %s
return MESSAGE_TEMPLATE % dict(english=english, translation=translation) return MESSAGE_TEMPLATE % dict(english=english, translation=translation)
def format(string): def formatString(string):
line_list = string.splitlines(True) line_list = string.splitlines(True)
length = len(line_list) length = len(line_list)
if length==1: if length==1:
return '"%s"' % string.replace('"', '\\"').replace('\n', '\\n') return '"%s"' % string.replace('"', '\\"').replace('\n', '\\n')
else: else:
return '\n'.join(['""']+[format(i) for i in line_list]) return '\n'.join(['""']+[formatString(i) for i in line_list])
# po header # po header
now = DateTime().toZone('UTC').strftime("%Y-%m-%d %H:%M+0000") now = DateTime().toZone('UTC').strftime("%Y-%m-%d %H:%M+0000")
...@@ -43,7 +43,6 @@ for i in catalog(portal_type='Glossary Term', ...@@ -43,7 +43,6 @@ for i in catalog(portal_type='Glossary Term',
language_id=language): language_id=language):
term = i.getObject() term = i.getObject()
reference = term.getReference() reference = term.getReference()
business_field = term.getBusinessField()
english_term = catalog.getResultValue(portal_type='Glossary Term', english_term = catalog.getResultValue(portal_type='Glossary Term',
validation_state='validated', validation_state='validated',
...@@ -52,7 +51,6 @@ for i in catalog(portal_type='Glossary Term', ...@@ -52,7 +51,6 @@ for i in catalog(portal_type='Glossary Term',
business_field_uid=term.getBusinessFieldUid()) business_field_uid=term.getBusinessFieldUid())
if english_term is None: if english_term is None:
continue continue
raise ValueError, 'Corresponding English term to "%s" does not exist in glossary.' % term.Title()
translated_title = term.getTitle() translated_title = term.getTitle()
translated_description = term.getDescription() translated_description = term.getDescription()
...@@ -65,8 +63,8 @@ for i in catalog(portal_type='Glossary Term', ...@@ -65,8 +63,8 @@ for i in catalog(portal_type='Glossary Term',
if not english_title: if not english_title:
raise ValueError, 'Title of corresponding English term(%s) to "%s" is empty.' % (english_relative_url, translated_title) raise ValueError, 'Title of corresponding English term(%s) to "%s" is empty.' % (english_relative_url, translated_title)
if translated_title!=english_title: if translated_title!=english_title:
print formatMessage(english=format(english_title), print formatMessage(english=formatString(english_title),
translation=format(translated_title), translation=formatString(translated_title),
term=term) term=term)
if translated_description: if translated_description:
...@@ -74,8 +72,8 @@ for i in catalog(portal_type='Glossary Term', ...@@ -74,8 +72,8 @@ for i in catalog(portal_type='Glossary Term',
raise ValueError, 'Description of corresponding English term(%s) to "%s" is empty.' % (english_relative_url, translated_description) raise ValueError, 'Description of corresponding English term(%s) to "%s" is empty.' % (english_relative_url, translated_description)
if translated_description!=english_description: if translated_description!=english_description:
print formatMessage(english=format(english_description), print formatMessage(english=formatString(english_description),
translation=format(translated_description), translation=formatString(translated_description),
term=term) term=term)
RESPONSE = context.REQUEST.RESPONSE RESPONSE = context.REQUEST.RESPONSE
......
...@@ -17,20 +17,20 @@ for i in property_sheet_list: ...@@ -17,20 +17,20 @@ for i in property_sheet_list:
dic = {} dic = {}
for i in all_field_list: for i in all_field_list:
id = i.getId() id_ = i.getId()
title = i.get_value('title') or '' title = i.get_value('title') or ''
skin_id = i.aq_parent.aq_parent.getId() skin_id = i.aq_parent.aq_parent.getId()
prefix = 'erp5_' prefix = 'erp5_'
if skin_id.startswith(prefix): if skin_id.startswith(prefix):
skin_id = skin_id[len(prefix):] skin_id = skin_id[len(prefix):]
if id.startswith('my_'): if id_.startswith('my_'):
for p in properties: for p in properties:
if id=='my_%s' % p: if id_=='my_%s' % p:
key = (p, skin_id, title) key = (p, skin_id, title)
dic[key] = i dic[key] = i
if id.startswith('your_'): if id_.startswith('your_'):
for p in properties: for p in properties:
if id=='your_%s' % p: if id_=='your_%s' % p:
key = (p, skin_id, title) key = (p, skin_id, title)
dic[key] = i dic[key] = i
......
prefix = 'field_listbox_term_' prefix = 'field_listbox_term_'
prefix_length = len(prefix) prefix_length = len(prefix)
portal_types = context.portal_types
portal_catalog = context.portal_catalog portal_catalog = context.portal_catalog
for i in kw.keys(): for i in kw.keys():
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
# Author: Lukasz Nowak <lukasz.nowak@ventis.com.pl> # Author: Lukasz Nowak <lukasz.nowak@ventis.com.pl>
# Copyright 2007 Ventis s. c. # Copyright 2007 Ventis s. c.
# SYNOPSIS # SYNOPSIS
# This script exctracts simulations (Applied Rule and Simulation Movement) for context. # This script extracts simulations (Applied Rule and Simulation Movement) for context.
# If start_path is given it instead extracts tree with root as given start_path. # If start_path is given it instead extracts tree with root as given start_path.
def getByRecurse(obj,rv=[]): def getByRecurse(obj):
rv = [] rv = []
for o in [q.getObject() for q in obj.searchFolder()]: for o in [q.getObject() for q in obj.searchFolder()]:
rv.append(getByRecurse(o)) rv.append(getByRecurse(o))
......
...@@ -74,10 +74,10 @@ for i in form_list: ...@@ -74,10 +74,10 @@ for i in form_list:
if (i.getId().endswith('FieldLibrary')): if (i.getId().endswith('FieldLibrary')):
continue continue
add_message(i.title, portal_url.getRelativeContentURL(i)) add_message(i.title, portal_url.getRelativeContentURL(i))
for group, list in i.groups.items(): for group, list_ in i.groups.items():
if group == 'hidden': if group == 'hidden':
continue continue
for j in (i[x] for x in list): for j in (i[x] for x in list_):
add_message(j.get_value('title'), portal_url.getRelativeContentURL(j)) add_message(j.get_value('title'), portal_url.getRelativeContentURL(j))
if j.get_value('editable'): if j.get_value('editable'):
add_message(j.get_value('description'), portal_url.getRelativeContentURL(j)) add_message(j.get_value('description'), portal_url.getRelativeContentURL(j))
...@@ -104,20 +104,19 @@ for i in page_template_list: ...@@ -104,20 +104,19 @@ for i in page_template_list:
# #
# Workflow # Workflow
# #
s_title_list = []
for i in context.portal_workflow.objectValues(): for i in context.portal_workflow.objectValues():
add_message(i.title_or_id(), portal_url.getRelativeContentURL(i)) add_message(i.title_or_id(), portal_url.getRelativeContentURL(i))
if not i.states: if not i.states:
continue continue
for s in i.states.values(): for s in i.states.values():
s_title = s.title s_title = s.title
if s_title: if s_title:
# adding a context in msg_id for more precise translation # adding a context in msg_id for more precise translation
msg_id = getMessageIdWithContext(s_title,'state',i.id) msg_id = getMessageIdWithContext(s_title,'state',i.id)
add_message(msg_id, portal_url.getRelativeContentURL(s)) add_message(msg_id, portal_url.getRelativeContentURL(s))
# also use state title as msg_id for compatibility # also use state title as msg_id for compatibility
add_message(s_title, portal_url.getRelativeContentURL(s)) add_message(s_title, portal_url.getRelativeContentURL(s))
if not i.transitions: if not i.transitions:
continue continue
...@@ -164,13 +163,13 @@ for property_sheet in context.portal_property_sheets.objectValues(): ...@@ -164,13 +163,13 @@ for property_sheet in context.portal_property_sheets.objectValues():
# #
# Output # Output
# #
def format(string): def formatString(string):
line_list = string.split('\n') line_list = string.split('\n')
length = len(line_list) length = len(line_list)
if length==1: if length==1:
return '"%s"' % string.replace('"', '\\"') return '"%s"' % string.replace('"', '\\"')
else: else:
return '\n'.join(['""']+[format(i) for i in line_list]) return '\n'.join(['""']+[formatString(i) for i in line_list])
print '''msgid "" print '''msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8" msgstr "Content-Type: text/plain; charset=UTF-8"
...@@ -188,7 +187,7 @@ for message in message_list: ...@@ -188,7 +187,7 @@ for message in message_list:
comment_list = message_dict[message] comment_list = message_dict[message]
comment_list.sort() comment_list.sort()
comment = '\n'.join([('#: %s' % i) for i in comment_list]) comment = '\n'.join([('#: %s' % i) for i in comment_list])
print MESSAGE_TEMPLATE % (comment, format(message)) print MESSAGE_TEMPLATE % (comment, formatString(message))
RESPONSE = context.REQUEST.RESPONSE RESPONSE = context.REQUEST.RESPONSE
RESPONSE.setHeader('Content-disposition', 'attachment;filename=translation.pot') RESPONSE.setHeader('Content-disposition', 'attachment;filename=translation.pot')
......
...@@ -4,9 +4,9 @@ result = [] ...@@ -4,9 +4,9 @@ result = []
def setCache(skin): def setCache(skin):
for o in skin.objectValues(): for o in skin.objectValues():
id = o.id id_ = o.id
if callable(id): id = id() if callable(id_): id_ = id_()
if o.meta_type in ('Image', 'File', 'Filesystem Image', 'Filesystem File') or id.endswith('.css') or id.endswith('.js'): if o.meta_type in ('Image', 'File', 'Filesystem Image', 'Filesystem File') or id_.endswith('.css') or id_.endswith('.js'):
if o.ZCacheable_getManagerId() != cache_manager_id: if o.ZCacheable_getManagerId() != cache_manager_id:
o.ZCacheable_setManagerId(cache_manager_id) o.ZCacheable_setManagerId(cache_manager_id)
result.append(o.absolute_url(relative=1)) result.append(o.absolute_url(relative=1))
......
...@@ -6,7 +6,7 @@ for form_path, form in context.ZopeFind( ...@@ -6,7 +6,7 @@ for form_path, form in context.ZopeFind(
context.portal_skins, obj_metatypes=['ERP5 Form'], search_sub=1): context.portal_skins, obj_metatypes=['ERP5 Form'], search_sub=1):
try: try:
groups = form.get_groups() groups = form.get_groups()
except AttributeError, e: except AttributeError as e:
print "%s is broken: %s" % (form_path, e) print "%s is broken: %s" % (form_path, e)
if 'not_assigned' in groups: if 'not_assigned' in groups:
print 'Not assigned fields in %s: %s' % (form_path, print 'Not assigned fields in %s: %s' % (form_path,
......
...@@ -10,4 +10,3 @@ except SubversionLoginError, error1 : ...@@ -10,4 +10,3 @@ except SubversionLoginError, error1 :
context.REQUEST.set('portal_status_message', 'Server needs authentication, no cookie found') context.REQUEST.set('portal_status_message', 'Server needs authentication, no cookie found')
return context.asContext(caller='info', realm = error1.getRealm(), username = vcs_tool.getPreferredUsername()).BusinessTemplate_viewSvnLogin() return context.asContext(caller='info', realm = error1.getRealm(), username = vcs_tool.getPreferredUsername()).BusinessTemplate_viewSvnLogin()
return entry_dict return entry_dict
return context.asContext(entry_dict=entry_dict).BusinessTemplate_viewSvnInfos()
request = context.REQUEST request = context.REQUEST
if caller_kw is None:
caller_kw = {}
trust_dict=dict((x, request[x]) for x in ( trust_dict=dict((x, request[x]) for x in (
'valid_until', 'hostname', 'realm', 'finger_print', 'valid_from', 'issuer_dname', 'failures')) 'valid_until', 'hostname', 'realm', 'finger_print', 'valid_from', 'issuer_dname', 'failures'))
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>caller, caller_kw={}, added=(), removed=(), modified=(), changelog=None, **kw</string> </value> <value> <string>caller, caller_kw=None, added=(), removed=(), modified=(), changelog=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
from erp5.component.module.SubversionClient import SubversionSSLTrustError, SubversionLoginError
from Products.ERP5Type.Document import newTempBase
# get selected business templates # get selected business templates
p = context.getPortalObject() p = context.getPortalObject()
selection_name = 'business_template_selection' # harcoded because we can also get delete_selection selection_name = 'business_template_selection' # harcoded because we can also get delete_selection
......
if caller_kw is None:
caller_kw = {}
context.getVcsTool().setLogin(auth, user, password) context.getVcsTool().setLogin(auth, user, password)
return context.restrictedTraverse(caller)(**caller_kw) return context.restrictedTraverse(caller)(**caller_kw)
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>user, password, auth, caller, caller_kw={}, added=(), modified=(), removed=(), changelog=None, **kw</string> </value> <value> <string>user, password, auth, caller, caller_kw=None, added=(), modified=(), removed=(), changelog=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
request = context.REQUEST
try: try:
files_list = context.REQUEST['uids'] files_list = request['uids']
except KeyError: except KeyError:
message = 'You MUST select at least one file.' message = 'You MUST select at least one file.'
else: else:
context.getVcsTool().resolved(files_list) context.getVcsTool().resolved(files_list)
message = 'Conflicted files resolved successfully.' message = 'Conflicted files resolved successfully.'
request.set("portal_status_message", message)
return context.BusinessTemplate_viewConflicted() return context.BusinessTemplate_viewConflicted()
if "files" in context.REQUEST.keys():
files = context.REQUEST["files"];
else:
files = None;
return ''' return '''
var tree = null; var tree = null;
var business_template; var business_template;
......
...@@ -56,9 +56,9 @@ lines_list = bug.searchFolder(portal_type='Bug Line', sort_on=(("id", "DESC"),), ...@@ -56,9 +56,9 @@ lines_list = bug.searchFolder(portal_type='Bug Line', sort_on=(("id", "DESC"),),
bug_message_list.extend(lines_list) bug_message_list.extend(lines_list)
message_count = len(bug_message_list)+1 message_count = len(bug_message_list)+1
for message in bug_message_list: for message in bug_message_list:
message_count -= 1 message_count -= 1
text = message.asText() text = message.asText()
body += """ body += """
++++++ Message #%s submitted by %s on %s ++++++ ++++++ Message #%s submitted by %s on %s ++++++
%s %s
""" % (message_count, message.getSourceTitle(''), """ % (message_count, message.getSourceTitle(''),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment