From 49236cedce94e3383c3650b654a22412dc647f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Thu, 24 Dec 2020 10:36:48 +0100 Subject: [PATCH] run_my_doc: fix pylint messages --- .../erp5_run_my_doc/Review_editAnnotationList.py | 4 ++-- .../erp5_run_my_doc/Review_getAnnotationList.py | 3 ++- .../erp5_run_my_doc/Review_getAnnotationList.xml | 2 +- .../erp5_run_my_doc/TestPageModule_convertPage.py | 3 +-- .../erp5_run_my_doc/TestPageModule_createChapter.py | 4 ++-- .../erp5_run_my_doc/TestPageModule_finishCreation.py | 3 +-- .../TestPageModule_getPreviousChapterList.xml | 2 +- .../erp5_run_my_doc/TestPage_getNextImageID.py | 8 +++----- .../portal_skins/erp5_run_my_doc/TestPage_uploadImage.py | 6 +++--- .../review_workflow/scripts/checkConsistency.py | 3 +-- 10 files changed, 17 insertions(+), 21 deletions(-) diff --git a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/Review_editAnnotationList.py b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/Review_editAnnotationList.py index aad4937cc7..9dfc847e63 100644 --- a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/Review_editAnnotationList.py +++ b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/Review_editAnnotationList.py @@ -1,8 +1,8 @@ -annotation_list = context.getAnnotation().split('\n'); +annotation_list = context.getAnnotation().split('\n') user_name = context.getPortalObject().portal_membership.getAuthenticatedMember().getId() for uid in listbox_uid: i = int(uid) - old_comment, locator, context_url, author, color = annotation_list[i][1:-1].split("},{"); + old_comment, locator, context_url, author, color = annotation_list[i][1:-1].split("},{") new_comment = context.REQUEST['field_listbox_title_' + uid] #print('Old title: ' + old_comment + ' -> ' + new_comment) if old_comment != new_comment: diff --git a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/Review_getAnnotationList.py b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/Review_getAnnotationList.py index 2058a45a8e..be0c0a67f3 100644 --- a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/Review_getAnnotationList.py +++ b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/Review_getAnnotationList.py @@ -2,7 +2,7 @@ Fetches Commentaries to display them in a listbox """ from Products.ERP5Type.Document import newTempBase -annotation_list = context.getAnnotation().split('\n'); +annotation_list = context.getAnnotation().split('\n') element_list = [] relative_url = context.getRelativeUrl() @@ -27,6 +27,7 @@ if len(annotation_list) > 0 and annotation_list[0] != "": counter += 1 for sorted_element in sort_on: + # pylint:disable=cell-var-from-loop element_list = sorted(element_list, key = lambda x: x.getProperty(sorted_element[0]), reverse = sorted_element[1] == 'descending') return element_list diff --git a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/Review_getAnnotationList.xml b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/Review_getAnnotationList.xml index 16c5b5f9b1..645014de1c 100644 --- a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/Review_getAnnotationList.xml +++ b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/Review_getAnnotationList.xml @@ -50,7 +50,7 @@ </item> <item> <key> <string>_params</string> </key> - <value> <string>sort_on = [], **kw</string> </value> + <value> <string>sort_on=(), **kw</string> </value> </item> <item> <key> <string>id</string> </key> diff --git a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPageModule_convertPage.py b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPageModule_convertPage.py index 0ec64932f3..e3e44f99b9 100644 --- a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPageModule_convertPage.py +++ b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPageModule_convertPage.py @@ -23,8 +23,7 @@ for uid in uids: contributor_list = obj.getContributorList()) conv_obj = conv_obj.manage_pasteObjects( - obj.manage_copyObjects( - map(lambda x: x.getId(), obj.objectValues()))) + obj.manage_copyObjects(list(obj.objectIds()))) return conv_obj_module.Base_redirect('', dict(portal_status_message=context.Base_translateString(str(counter) + " object(s) converted."))) diff --git a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPageModule_createChapter.py b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPageModule_createChapter.py index 773605bff4..1aaa7d8160 100644 --- a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPageModule_createChapter.py +++ b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPageModule_createChapter.py @@ -1,10 +1,10 @@ +# pylint:disable=redefined-builtin """ Adds a chapter in the listbox, and upload an image if necessary (it doesn't generate the html code corresponding to the text) """ from Products.ERP5Type.Document import newTempBase -translateString = context.Base_translateString portal_status_message = "" if image_caption in [None, ""]: @@ -29,7 +29,7 @@ if slide_type in ['Illustration', 'Screenshot']: image_id = image_url else: image_id = test_page.TestPage_getNextImageID(chapter_title, slide_type) - image = test_page.TestPage_uploadImage(image_id, file, batch_mode=True, image_caption=image_caption) + test_page.TestPage_uploadImage(image_id, file, batch_mode=True, image_caption=image_caption) listbox.append(newTempBase(context.getPortalObject(), '', diff --git a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPageModule_finishCreation.py b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPageModule_finishCreation.py index 9691cd56fa..f125e85042 100644 --- a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPageModule_finishCreation.py +++ b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPageModule_finishCreation.py @@ -1,13 +1,12 @@ +# pylint:disable=redefined-builtin """ Generate the html code from the listbox after adding the current chapter to the listbox """ -from Products.ERP5Type.Document import newTempBase # Add the last chapter to the listbox context.TestPageModule_createChapter(chapter_title, slide_type, image_url, image_caption, file, text_content, slide_content, tested, **kw) -translateString = context.Base_translateString portal_status_message = "" session = context.ERP5RunMyDocs_acquireSession() diff --git a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPageModule_getPreviousChapterList.xml b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPageModule_getPreviousChapterList.xml index ccd24e60cd..f54c0084f0 100644 --- a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPageModule_getPreviousChapterList.xml +++ b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPageModule_getPreviousChapterList.xml @@ -50,7 +50,7 @@ </item> <item> <key> <string>_params</string> </key> - <value> <string>sort_on = [], **kw</string> </value> + <value> <string>sort_on=(), **kw</string> </value> </item> <item> <key> <string>id</string> </key> diff --git a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPage_getNextImageID.py b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPage_getNextImageID.py index 604976cb08..71f67d11b4 100644 --- a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPage_getNextImageID.py +++ b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPage_getNextImageID.py @@ -11,10 +11,8 @@ image_id = ''.join(c for c in ('_'.join(image_id.split(' '))) if c.isalnum() or found = True while found: image_path = path + '/' + image_id - try: - image = context.restrictedTraverse(image_path) - except: - image = None + image = context.restrictedTraverse(image_path, None) + if image is None: found = False break # If there's already an image with the same url @@ -22,7 +20,7 @@ while found: # Check if the end is a number and increment in that case try: end_number = int(image_id.split('_')[-1]) - except: + except IndexError: end_number = -1 if end_number > 0: image_id = image_id.split('_')[0:-1] diff --git a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPage_uploadImage.py b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPage_uploadImage.py index a599d1f838..e366d7721a 100644 --- a/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPage_uploadImage.py +++ b/bt5/erp5_run_my_doc/SkinTemplateItem/portal_skins/erp5_run_my_doc/TestPage_uploadImage.py @@ -1,3 +1,4 @@ +#pylint:disable=redefined-builtin """ Create an image object and upload the image if necessary """ @@ -20,9 +21,8 @@ def createImage(image_id): if slide_type in ['Screenshot', 'Illustration'] and upload_image: if not(file is None or not file): if edit_mode: - try: - image = context.restrictedTraverse(context.getPath() + '/' + image_id) - except: + image = context.restrictedTraverse(context.getPath() + '/' + image_id, None) + if image is None: image = createImage(image_id) msg += ' Image %s created.' % image_id else: diff --git a/bt5/erp5_run_my_doc/WorkflowTemplateItem/portal_workflow/review_workflow/scripts/checkConsistency.py b/bt5/erp5_run_my_doc/WorkflowTemplateItem/portal_workflow/review_workflow/scripts/checkConsistency.py index b9c9cc9a8e..8823d28571 100644 --- a/bt5/erp5_run_my_doc/WorkflowTemplateItem/portal_workflow/review_workflow/scripts/checkConsistency.py +++ b/bt5/erp5_run_my_doc/WorkflowTemplateItem/portal_workflow/review_workflow/scripts/checkConsistency.py @@ -1,2 +1 @@ -object = state_change['object'] -object.Base_checkConsistency() +state_change['object'].Base_checkConsistency() -- 2.30.9