Skip to content

Commit

Permalink
Format lftools code with the Black code formatter
Browse files Browse the repository at this point in the history
This patch auto-formats most files contained in the lftools software.
Format changes are trivial, such as replacing a single quote with
double-quotes, and rearranging the length of certain lines. Lftools
will use Black for code formatting once this patch, and the test
harness overhaul patch, are merged.

Issue-ID: RELENG-2766
Signed-off-by: DW Talton <[email protected]>
Change-Id: I74318e0685aa44617af4575016c84caafa68b5c5
  • Loading branch information
DW Talton committed Mar 10, 2020
1 parent a316ec9 commit 0d5b572
Show file tree
Hide file tree
Showing 74 changed files with 2,414 additions and 2,634 deletions.
13 changes: 7 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@
import os
import sys
import sphinx_bootstrap_theme
sys.path.insert(0, os.path.abspath('..'))

sys.path.insert(0, os.path.abspath(".."))

from pbr.version import VersionInfo

from docs_conf.conf import *

version = str(VersionInfo('lftools'))
release = str(VersionInfo('lftools'))
version = str(VersionInfo("lftools"))
release = str(VersionInfo("lftools"))

# Linkcheck Options
linkcheck_ignore= [
r'https://testing\.googleblog\.com/.*',
r'https://nexus\.example\.com',
linkcheck_ignore = [
r"https://testing\.googleblog\.com/.*",
r"https://nexus\.example\.com",
]
11 changes: 5 additions & 6 deletions lftools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
##############################################################################
"""lftools package."""

__author__ = 'Thanh Ha'
__summary__ = 'Linux Foundation Release Engineering Tools'
__author__ = "Thanh Ha"
__summary__ = "Linux Foundation Release Engineering Tools"

import logging
import sys
Expand All @@ -22,10 +22,9 @@
class LogFormatter(logging.Formatter):
"""Custom log formatter."""

default_fmt = logging.Formatter('%(levelname)s: %(message)s')
debug_fmt = logging.Formatter(
'%(levelname)s: %(name)s:%(lineno)d: %(message)s')
info_fmt = logging.Formatter('%(message)s')
default_fmt = logging.Formatter("%(levelname)s: %(message)s")
debug_fmt = logging.Formatter("%(levelname)s: %(name)s:%(lineno)d: %(message)s")
info_fmt = logging.Formatter("%(message)s")

def format(self, record):
"""Format log messages depending on log level."""
Expand Down
14 changes: 3 additions & 11 deletions lftools/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,17 @@ def __init__(self, **params):
self.password = self.creds["password"]
self.r = requests.Session()
self.r.auth = (self.username, self.password)
self.r.headers.update({
"Content-Type": "application/json; charset=UTF-8",
"Accept": "application/json"
})
self.r.headers.update({"Content-Type": "application/json; charset=UTF-8", "Accept": "application/json"})

if self.creds["authtype"] == "token":
self.token = self.creds["token"]
self.r = requests.Session()
self.r.headers.update(
{"Authorization": "Token {}".format(self.token)}
)
self.r.headers.update({"Authorization": "Token {}".format(self.token)})
self.r.headers.update({"Content-Type": "application/json"})

def _request(self, url, method, data=None, timeout=30):
"""Execute the request."""
resp = self.r.request(method,
self.endpoint + url,
data=data,
timeout=timeout)
resp = self.r.request(method, self.endpoint + url, data=data, timeout=timeout)

# Some massaging to make our gerrit python code work
if resp.status_code == 409:
Expand Down
Loading

0 comments on commit 0d5b572

Please sign in to comment.