From 40db466c57c4452533e1324ecbc24dc4b4921de1 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 2 May 2022 16:12:37 +0200 Subject: [PATCH] Fix some pylint warnings --- .pylintrc | 3 +++ entrypoint.py | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 .pylintrc diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..3a5e9ae --- /dev/null +++ b/.pylintrc @@ -0,0 +1,3 @@ +[MESSAGES CONTROL] +disable=locally-disabled, + redefined-outer-name, diff --git a/entrypoint.py b/entrypoint.py index 7a8c7e3..73138d6 100644 --- a/entrypoint.py +++ b/entrypoint.py @@ -1,4 +1,9 @@ #!/usr/bin/python3 +"""" +Entrypoint of a Woodpecker CI docker image plugin that permit to publish Debian +packages on a Aptly repository using its API +""" + import datetime import os import re @@ -76,8 +81,8 @@ if MAX_RETRY: def list_files_in_changes_file(filepath): """ List files included by a changes file """ dirpath = os.path.dirname(filepath) - with open(filepath, "r", encoding="utf-8") as fd: - changes_file = fd.read() + with open(filepath, "r", encoding="utf-8") as file_desc: + changes_file = file_desc.read() parser = PackagesParser(changes_file) files = [] @@ -101,8 +106,8 @@ def changes_file2package_name(changes_file): def upload_file(package_name, filepath): """ Upload a file using Aptly API """ url = f'{API_URL}/files/{package_name}' - with open(filepath, 'rb') as fd: - result = session.post(url, files={'file': fd}) + with open(filepath, 'rb') as file_desc: + result = session.post(url, files={'file': file_desc}) return ( result.status_code == 200 and f'{package_name}/{os.path.basename(filepath)}' in result.json() @@ -167,9 +172,9 @@ url = f'{API_URL}/repos/{REPO_NAME}/snapshots' payload = {'Name': snap_name} result = session.post(url, json=payload) try: - data = result.json() -except Exception: - data = {} + data = result.json() +except Exception: # pylint: disable=broad-except + data = {} error = ( result.status_code < 200 or result.status_code > 299 or