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

forge: fix pylint warnings and enable coding style test

parent 6f622d9b
Pipeline #9633 failed with stage
in 0 seconds
......@@ -60,10 +60,10 @@ from zope.tal.talgenerator import TALGenerator
from zope.tal.dummyengine import name_match
def findStaticTranslationText(page_template, func_name_list):
def iterate(node, target_name, function):
if type(node) is list:
if isinstance(node, list):
for i in node:
iterate(i, target_name, function)
elif type(node) is tuple and node:
elif isinstance(node, tuple) and node:
if node[0]==target_name:
function(node)
else:
......@@ -100,8 +100,8 @@ def findStaticTranslationText(page_template, func_name_list):
tal_expression = tal_expression[1:-1]
match = name_match(tal_expression)
if match:
type, expression = match.group(1, 2)
if type=='python':
type_, expression = match.group(1, 2)
if type_=='python':
# clean up expression
expression = expression.strip()
expression = expression.replace('\n', ' ')
......@@ -139,7 +139,7 @@ class MyDummyTALInterpreter(TALInterpreter):
_i18n_message_id_dict = 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:
self._i18n_message_id_dict[msgid] = None
except TypeError:
......
......@@ -6,10 +6,22 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>Glossary</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>extension.erp5.Glossary</string> </value>
......@@ -24,6 +36,18 @@
<none/>
</value>
</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>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
......@@ -31,13 +55,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<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>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -50,7 +89,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -59,7 +98,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......
# -*- coding: utf-8 -*-
# pylint: disable-all
##############################################################################
#
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
......
......@@ -80,7 +80,7 @@ class SubversionLoginError(SubversionError):
"""
# Declarative Security
security = ClassSecurityInfo()
def __init__(self, realm = None):
def __init__(self, realm = None): # pylint:disable=super-init-not-called
self._realm = realm
security.declarePublic('getRealm')
......@@ -96,7 +96,7 @@ class SubversionSSLTrustError(SubversionError):
# Declarative Security
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
security.declarePublic('getTrustDict')
......@@ -134,7 +134,7 @@ try:
return False, ''
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)
if not username or not password:
self.client.setException(SubversionLoginError(realm))
......@@ -147,12 +147,12 @@ try:
return True, user, password, False
class NotifyCallback(Callback):
def __call__(self, event_dict):
def __call__(self, event_dict): # pylint:disable=arguments-differ
# FIXME: should accumulate information for the user
pass
class SSLServerTrustPromptCallback(Callback):
def __call__(self, trust_dict):
def __call__(self, trust_dict): # pylint:disable=arguments-differ
if not self.client.trustSSLServer(trust_dict):
self.client.setException(SubversionSSLTrustError(trust_dict))
return False, 0, False
......
......@@ -6,6 +6,12 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SubversionClient</string> </value>
......@@ -43,13 +49,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<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>
<tuple/>
</value>
</item>
<item>
......@@ -59,13 +59,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<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>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -78,7 +93,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -87,7 +102,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
......
......@@ -36,7 +36,7 @@ from AccessControl import Unauthorized
from AccessControl.SecurityManagement import getSecurityManager
from AccessControl.SecurityInfo import ModuleSecurityInfo
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 ZTUtils import make_query
from Products.ERP5.Document.BusinessTemplate import BusinessTemplateFolder
......
from erp5.component.module.SubversionClient import SubversionSSLTrustError
from Products.ERP5Type.Document import newTempBase
portal = context.getPortalObject()
......
......@@ -18,10 +18,10 @@ if from_url is None:
user = context.portal_membership.getAuthenticatedMember().getUserName()
from_url = '"%s" <%s>' % (user,
context.email_from_address)
# Return-Path
# Return-Path. TODO: this is not implemented
if reply_url is None:
reply_url = context.portal_preferences.getPreferredEventSenderEmail()
additional_headers = None
additional_headers = None # pylint: disable=unused-variable
if reply_url:
additional_headers = {'Return-Path':reply_url}
......@@ -44,7 +44,6 @@ elif same_type(to_url, ''):
# Attachments
if attachment_list is None:
attachment_list = []
document_type_list = context.getPortalDocumentTypeList()
for attachment in context.getAggregateValueList():
mime_type, content = attachment.getMimeTypeAndContent()
name = attachment.getReference()
......
......@@ -2,6 +2,9 @@
This script creates a new event with given metadata and
attaches it to the current ticket.
"""
# pylint:disable=redefined-builtin
# this script uses file= argument
translateString = context.Base_translateString
default_bug_line = getattr(context, "default_bug_line", None)
......
"""Return a po file from a spreadsheet of categories."""
from Products.ERP5Type.Message import translateString
from Products.ERP5Type.Document import newTempBase
# Initialise some general variables
detailed_report_result = []
detailed_report_append = detailed_report_result.append
category_dict = {}
translation_dict = {}
translated_attributes_list = ["title", "description", "short_title"]
import_filename = getattr(import_file, 'filename', '?')
......@@ -31,14 +29,11 @@ def invalid_category_spreadsheet_handler(message):
category_list_mapping = context.Base_getCategoriesSpreadSheetMapping(import_file,
invalid_spreadsheet_error_handler=invalid_category_spreadsheet_handler)
if category_list_mapping.has_key('error_list'):
context.REQUEST.other['category_import_report'] = initial_category_list_mapping['error_list']
return context.CategoryTool_viewImportReport()
assert 'error_list' not in category_list_mapping
#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:
#Take only needed attributes
for attribute in translated_attributes_list:
......
......@@ -6,8 +6,7 @@ for o in template_tool.contentValues(portal_type='Business Template'):
if portal_type in o.getTemplatePortalTypeIdList():
matching.append(o.getUid())
else:
allowed_content_type_list = o.getTemplatePortalTypeAllowedContentTypeList()
allowed_content_type_list = map(lambda x: x and x.split('|')[1].strip(), allowed_content_type_list)
allowed_content_type_list = [x for x in o.getTemplatePortalTypeAllowedContentTypeList() if x and x.split('|')[1].strip()]
if portal_type in allowed_content_type_list:
matching.append(o.getUid())
......
......@@ -17,7 +17,7 @@ for i in catalog(portal_type='Glossary Term',
language_id=language) is not None:
continue
new_term = glossary_module.newContent(portal_type='Glossary Term',
glossary_module.newContent(portal_type='Glossary Term',
reference=reference,
business_field=business_field,
language=language,
......
......@@ -2,10 +2,10 @@ result = context.GlossaryModule_getTermDictListFromPortalType(portal_type_list)
if export_tsv:
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['title'], i['description'],
i['field_path'])))
i['field_path'])])
return printed
else:
portal_catalog = context.portal_catalog
......
......@@ -2,10 +2,10 @@ result = context.GlossaryModule_getTermDictListFromPropertySheet(property_sheet_
if export_tsv:
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['title'], i['description'],
i['field_path'])))
i['field_path'])])
return printed
else:
portal_catalog = context.portal_catalog
......
......@@ -2,9 +2,11 @@ result = context.GlossaryModule_getTermDictListFromWorkflow(template_list)
if export_tsv:
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['title'], i['description'], i['workflow_id'])))
i['title'], i['description'],
i['workflow_id'])])
return printed
else:
portal_catalog = context.portal_catalog
......
from Products.ERP5Type.Document import newTempBase
result = []
portal_catalog = context.portal_catalog
portal_skins = context.portal_skins
......
from Products.ERP5Type.Document import newTempBase
result = []
portal_catalog = context.portal_catalog
portal_skins = context.portal_skins
def get_term_list(reference):
reference = reference.rsplit(' Module', 1)[0]
......
from Products.ERP5Type.Document import newTempBase
marker = []
result = []
portal_catalog = context.portal_catalog
portal_workflow = context.portal_workflow
......@@ -40,7 +39,7 @@ line_list = []
c = 0
item_dict = {}
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)
#if not term_list:
# continue
......@@ -49,21 +48,21 @@ for business_field in business_field_list:
item_dict[wf_item] = True
c += 1
if type == 'workflow':
if type_ == 'workflow':
wf_item_path = wf_item.id
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_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_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_title = wf_item.actbox_name
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 \
term_list[0].getTitle() + ' Action' == wf_item_title and \
term_list[0].getDescription() == wf_item_description:
......@@ -76,7 +75,7 @@ for business_field in business_field_list:
line = newTempBase(context, 'tmp_glossary_wf_item_%s' % c)
line.edit(wf_item_path=wf_item_path,
wf_item_type=type,
wf_item_type=type_,
wf_item_title=wf_item_title,
wf_item_edit_url = "%s/manage_properties" % wf_item.absolute_url(),
wf_item_description = wf_item_description,
......
......@@ -14,13 +14,13 @@ msgstr %s
return MESSAGE_TEMPLATE % dict(english=english, translation=translation)
def format(string):
def formatString(string):
line_list = string.splitlines(True)
length = len(line_list)
if length==1:
return '"%s"' % string.replace('"', '\\"').replace('\n', '\\n')
else:
return '\n'.join(['""']+[format(i) for i in line_list])
return '\n'.join(['""']+[formatString(i) for i in line_list])
# po header
now = DateTime().toZone('UTC').strftime("%Y-%m-%d %H:%M+0000")
......@@ -43,7 +43,6 @@ for i in catalog(portal_type='Glossary Term',
language_id=language):
term = i.getObject()
reference = term.getReference()
business_field = term.getBusinessField()
english_term = catalog.getResultValue(portal_type='Glossary Term',
validation_state='validated',
......@@ -52,7 +51,6 @@ for i in catalog(portal_type='Glossary Term',
business_field_uid=term.getBusinessFieldUid())
if english_term is None:
continue
raise ValueError, 'Corresponding English term to "%s" does not exist in glossary.' % term.Title()
translated_title = term.getTitle()
translated_description = term.getDescription()
......@@ -65,8 +63,8 @@ for i in catalog(portal_type='Glossary Term',
if not english_title:
raise ValueError, 'Title of corresponding English term(%s) to "%s" is empty.' % (english_relative_url, translated_title)
if translated_title!=english_title:
print formatMessage(english=format(english_title),
translation=format(translated_title),
print formatMessage(english=formatString(english_title),
translation=formatString(translated_title),
term=term)
if translated_description:
......@@ -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)
if translated_description!=english_description:
print formatMessage(english=format(english_description),
translation=format(translated_description),
print formatMessage(english=formatString(english_description),
translation=formatString(translated_description),
term=term)
RESPONSE = context.REQUEST.RESPONSE
......
......@@ -17,20 +17,20 @@ for i in property_sheet_list:
dic = {}
for i in all_field_list:
id = i.getId()
id_ = i.getId()
title = i.get_value('title') or ''
skin_id = i.aq_parent.aq_parent.getId()
prefix = 'erp5_'
if skin_id.startswith(prefix):
skin_id = skin_id[len(prefix):]
if id.startswith('my_'):
if id_.startswith('my_'):
for p in properties:
if id=='my_%s' % p:
if id_=='my_%s' % p:
key = (p, skin_id, title)
dic[key] = i
if id.startswith('your_'):
if id_.startswith('your_'):
for p in properties:
if id=='your_%s' % p:
if id_=='your_%s' % p:
key = (p, skin_id, title)
dic[key] = i
......
prefix = 'field_listbox_term_'
prefix_length = len(prefix)
portal_types = context.portal_types
portal_catalog = context.portal_catalog
for i in kw.keys():
......
......@@ -2,11 +2,11 @@
# Author: Lukasz Nowak <lukasz.nowak@ventis.com.pl>
# Copyright 2007 Ventis s. c.
# 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.
def getByRecurse(obj,rv=[]):
def getByRecurse(obj):
rv = []
for o in [q.getObject() for q in obj.searchFolder()]:
rv.append(getByRecurse(o))
......
......@@ -74,10 +74,10 @@ for i in form_list:
if (i.getId().endswith('FieldLibrary')):
continue
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':
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))
if j.get_value('editable'):
add_message(j.get_value('description'), portal_url.getRelativeContentURL(j))
......@@ -104,7 +104,6 @@ for i in page_template_list:
#
# Workflow
#
s_title_list = []
for i in context.portal_workflow.objectValues():
add_message(i.title_or_id(), portal_url.getRelativeContentURL(i))
......@@ -164,13 +163,13 @@ for property_sheet in context.portal_property_sheets.objectValues():
#
# Output
#
def format(string):
def formatString(string):
line_list = string.split('\n')
length = len(line_list)
if length==1:
return '"%s"' % string.replace('"', '\\"')
else:
return '\n'.join(['""']+[format(i) for i in line_list])
return '\n'.join(['""']+[formatString(i) for i in line_list])
print '''msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
......@@ -188,7 +187,7 @@ for message in message_list:
comment_list = message_dict[message]
comment_list.sort()
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.setHeader('Content-disposition', 'attachment;filename=translation.pot')
......
......@@ -4,9 +4,9 @@ result = []
def setCache(skin):
for o in skin.objectValues():
id = o.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'):
id_ = o.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.ZCacheable_getManagerId() != cache_manager_id:
o.ZCacheable_setManagerId(cache_manager_id)
result.append(o.absolute_url(relative=1))
......
......@@ -6,7 +6,7 @@ for form_path, form in context.ZopeFind(
context.portal_skins, obj_metatypes=['ERP5 Form'], search_sub=1):
try:
groups = form.get_groups()
except AttributeError, e:
except AttributeError as e:
print "%s is broken: %s" % (form_path, e)
if 'not_assigned' in groups:
print 'Not assigned fields in %s: %s' % (form_path,
......
......@@ -10,4 +10,3 @@ except SubversionLoginError, error1 :
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 entry_dict
return context.asContext(entry_dict=entry_dict).BusinessTemplate_viewSvnInfos()
request = context.REQUEST
if caller_kw is None:
caller_kw = {}
trust_dict=dict((x, request[x]) for x in (
'valid_until', 'hostname', 'realm', 'finger_print', 'valid_from', 'issuer_dname', 'failures'))
......
......@@ -50,7 +50,7 @@
</item>
<item>
<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>
<key> <string>id</string> </key>
......
from erp5.component.module.SubversionClient import SubversionSSLTrustError, SubversionLoginError
from Products.ERP5Type.Document import newTempBase
# get selected business templates
p = context.getPortalObject()
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)
return context.restrictedTraverse(caller)(**caller_kw)
......@@ -50,7 +50,7 @@
</item>
<item>
<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>
<key> <string>id</string> </key>
......
request = context.REQUEST
try:
files_list = context.REQUEST['uids']
files_list = request['uids']
except KeyError:
message = 'You MUST select at least one file.'
else:
context.getVcsTool().resolved(files_list)
message = 'Conflicted files resolved successfully.'
request.set("portal_status_message", message)
return context.BusinessTemplate_viewConflicted()
if "files" in context.REQUEST.keys():
files = context.REQUEST["files"];
else:
files = None;
return '''
var tree = null;
var business_template;
......
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