Commit 00e1736b authored by Jérome Perrin's avatar Jérome Perrin

administration: fixes for pylint

parent 592e3eae
Pipeline #6857 failed with stage
in 0 seconds
...@@ -102,8 +102,8 @@ def MessageCatalog_getNotTranslatedMessageDict(self): ...@@ -102,8 +102,8 @@ def MessageCatalog_getNotTranslatedMessageDict(self):
""" """
not_translated_message_dict = {} not_translated_message_dict = {}
messages = MessageCatalog_getMessageDict(self) messages = MessageCatalog_getMessageDict(self)
for k,v in messages.iteritems(): for k, v in messages.iteritems():
if not len(v) or not len(filter(lambda x:x, v.values())): if not [x for x in v.values() if x]:
not_translated_message_dict[k] = v not_translated_message_dict[k] = v
return not_translated_message_dict return not_translated_message_dict
...@@ -153,7 +153,7 @@ def checkConversionToolAvailability(self): ...@@ -153,7 +153,7 @@ def checkConversionToolAvailability(self):
_, html_result = temp_document.convert(format='html') _, html_result = temp_document.convert(format='html')
except ConflictError: except ConflictError:
raise raise
except: #Which Errors should we catch ? except Exception:
#Transformation failed #Transformation failed
message = 'Conversion tool got unexpected error:\n%s' % ''.join(ExceptionFormatter.format_exception(*sys.exc_info())) message = 'Conversion tool got unexpected error:\n%s' % ''.join(ExceptionFormatter.format_exception(*sys.exc_info()))
else: else:
......
...@@ -45,10 +45,7 @@ ...@@ -45,10 +45,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:106, 29: map/filter on lambda could be replaced by comprehension (deprecated-lambda)</string>
<string>W:156, 2: No exception type(s) specified (bare-except)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
from zpprofile import getProfiler, getStatisticalProfilerAndThread # these names are used in external methods
from zpprofile import getProfiler, getStatisticalProfilerAndThread # pylint: disable=unused-import
\ No newline at end of file
...@@ -43,10 +43,7 @@ ...@@ -43,10 +43,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: 1, 0: Unused getProfiler imported from zpprofile (unused-import)</string>
<string>W: 1, 0: Unused getStatisticalProfilerAndThread imported from zpprofile (unused-import)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
...@@ -6,13 +6,13 @@ alarm_warn_ratio = 0.25 ...@@ -6,13 +6,13 @@ alarm_warn_ratio = 0.25
localizer = context.Localizer localizer = context.Localizer
for message_catalog in localizer.objectValues('MessageCatalog'): for message_catalog in localizer.objectValues('MessageCatalog'):
all = len(message_catalog.MessageCatalog_getMessageDict().keys()) all_messages = len(message_catalog.MessageCatalog_getMessageDict().keys())
not_translated = len(message_catalog.MessageCatalog_getNotTranslatedMessageDict().keys()) not_translated = len(message_catalog.MessageCatalog_getNotTranslatedMessageDict().keys())
enable_warning = not_translated > all*alarm_warn_ratio enable_warning = not_translated > all_messages * alarm_warn_ratio
if enable_warning: if enable_warning:
# we have more than allowed number of untranslated messages, # we have more than allowed number of untranslated messages,
# fire alarm # fire alarm
context.log("Too many untranslated Localizer messages for %s %s/%s" %(message_catalog, all, not_translated)) context.log("Too many untranslated Localizer messages for %s %s/%s" %(message_catalog, all_messages, not_translated))
return True return True
return False return False
...@@ -8,13 +8,14 @@ def getDefaultSecurityCategoryMapping(): ...@@ -8,13 +8,14 @@ def getDefaultSecurityCategoryMapping():
'ERP5Type_getSecurityCategoryFromAssignment', 'ERP5Type_getSecurityCategoryFromAssignment',
context.getPortalObject().getPortalAssignmentBaseCategoryList() context.getPortalObject().getPortalAssignmentBaseCategoryList()
),) ),)
getSecurityCategoryMapping = getattr(context, 'ERP5Type_getSecurityCategoryMapping', getDefaultSecurityCategoryMapping) getSecurityCategoryMapping = getattr(context, 'ERP5Type_getSecurityCategoryMapping', getDefaultSecurityCategoryMapping)
# XXX end of code duplication # XXX end of code duplication
for method_id, base_category_list in getSecurityCategoryMapping(): for method_id, base_category_list in getSecurityCategoryMapping():
try: try:
security_category_dict.setdefault(tuple(base_category_list), []).extend( security_category_dict.setdefault(tuple(base_category_list), []).extend(
getattr(context, method_id)(base_category_list, login, context, '')) getattr(context, method_id)(base_category_list, login, context, ''))
except: # XXX: it is not possible to log message with traceback from python script except Exception: # XXX: it is not possible to log message with traceback from python script
print 'It was not possible to invoke method %s with base_category_list %s'%(method_id, base_category_list) print 'It was not possible to invoke method %s with base_category_list %s'%(method_id, base_category_list)
for base_category_list, category_value_list in security_category_dict.items(): for base_category_list, category_value_list in security_category_dict.items():
......
...@@ -21,11 +21,11 @@ field_library_id_dict = { ...@@ -21,11 +21,11 @@ field_library_id_dict = {
modified_object_dict = {} modified_object_dict = {}
def calculateFieldLibraryID(id): def calculateFieldLibraryID(bt_title):
# The field library name could be automatically calculated or hardcoded in # The field library name could be automatically calculated or hardcoded in
# the script # the script
return field_library_id_dict.get(id) or 'Base_view%sFieldLibrary' % \ return field_library_id_dict.get(bt_title) or 'Base_view%sFieldLibrary' % \
''.join([x.capitalize() for x in id.split('_')[1:]]) ''.join([x.capitalize() for x in bt_title.split('_')[1:]])
def getForm(skin_folder, form_id): def getForm(skin_folder, form_id):
try: try:
......
...@@ -54,7 +54,7 @@ if catalog_uid_list is None: ...@@ -54,7 +54,7 @@ if catalog_uid_list is None:
'tag': tag, 'tag': tag,
'fixit': fixit, 'fixit': fixit,
} }
for activity in xrange(activity_count): for _ in xrange(activity_count):
if len(catalog_uid_list) == 0: if len(catalog_uid_list) == 0:
result_list.append('No more uids to check, stop spawning activities.') result_list.append('No more uids to check, stop spawning activities.')
break break
......
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