Fix some pylint warnings

This commit is contained in:
Benjamin Renard 2022-05-02 16:12:37 +02:00
parent 909c726c75
commit 40db466c57
2 changed files with 15 additions and 7 deletions

3
.pylintrc Normal file
View file

@ -0,0 +1,3 @@
[MESSAGES CONTROL]
disable=locally-disabled,
redefined-outer-name,

View file

@ -1,4 +1,9 @@
#!/usr/bin/python3 #!/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 datetime
import os import os
import re import re
@ -76,8 +81,8 @@ if MAX_RETRY:
def list_files_in_changes_file(filepath): def list_files_in_changes_file(filepath):
""" List files included by a changes file """ """ List files included by a changes file """
dirpath = os.path.dirname(filepath) dirpath = os.path.dirname(filepath)
with open(filepath, "r", encoding="utf-8") as fd: with open(filepath, "r", encoding="utf-8") as file_desc:
changes_file = fd.read() changes_file = file_desc.read()
parser = PackagesParser(changes_file) parser = PackagesParser(changes_file)
files = [] files = []
@ -101,8 +106,8 @@ def changes_file2package_name(changes_file):
def upload_file(package_name, filepath): def upload_file(package_name, filepath):
""" Upload a file using Aptly API """ """ Upload a file using Aptly API """
url = f'{API_URL}/files/{package_name}' url = f'{API_URL}/files/{package_name}'
with open(filepath, 'rb') as fd: with open(filepath, 'rb') as file_desc:
result = session.post(url, files={'file': fd}) result = session.post(url, files={'file': file_desc})
return ( return (
result.status_code == 200 and result.status_code == 200 and
f'{package_name}/{os.path.basename(filepath)}' in result.json() 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} payload = {'Name': snap_name}
result = session.post(url, json=payload) result = session.post(url, json=payload)
try: try:
data = result.json() data = result.json()
except Exception: except Exception: # pylint: disable=broad-except
data = {} data = {}
error = ( error = (
result.status_code < 200 or result.status_code < 200 or
result.status_code > 299 or result.status_code > 299 or