Resolve pylint errors in infrastructure_api.py
This commit is contained in:
parent
e0b30adf9f
commit
70b5607d8e
1 changed files with 11 additions and 11 deletions
|
@ -46,7 +46,7 @@ class JsonFileHandler(FileHandler):
|
||||||
def parse(self) -> tuple[list[int], bool]:
|
def parse(self) -> tuple[list[int], bool]:
|
||||||
if self.config_file_path is None:
|
if self.config_file_path is None:
|
||||||
raise ValueError("No file name given.")
|
raise ValueError("No file name given.")
|
||||||
with open(self.config_file_path, 'r') as json_file:
|
with open(self.config_file_path, 'r', encoding='utf-8') as json_file:
|
||||||
json_version = json.load(json_file)['version']
|
json_version = json.load(json_file)['version']
|
||||||
is_snapshot = False
|
is_snapshot = False
|
||||||
if '-SNAPSHOT' in json_version:
|
if '-SNAPSHOT' in json_version:
|
||||||
|
@ -56,7 +56,7 @@ class JsonFileHandler(FileHandler):
|
||||||
return version, is_snapshot
|
return version, is_snapshot
|
||||||
|
|
||||||
def write(self, version_string):
|
def write(self, version_string):
|
||||||
with open(self.config_file_path, 'r+') as json_file:
|
with open(self.config_file_path, 'r+', encoding='utf-8') as json_file:
|
||||||
json_data = json.load(json_file)
|
json_data = json.load(json_file)
|
||||||
json_data['version'] = version_string
|
json_data['version'] = version_string
|
||||||
json_file.seek(0)
|
json_file.seek(0)
|
||||||
|
@ -69,7 +69,7 @@ class GradleFileHandler(FileHandler):
|
||||||
def parse(self) -> tuple[list[int], bool]:
|
def parse(self) -> tuple[list[int], bool]:
|
||||||
if self.config_file_path is None:
|
if self.config_file_path is None:
|
||||||
raise ValueError("No file name given.")
|
raise ValueError("No file name given.")
|
||||||
with open(self.config_file_path, 'r') as gradle_file:
|
with open(self.config_file_path, 'r', encoding='utf-8') as gradle_file:
|
||||||
contents = gradle_file.read()
|
contents = gradle_file.read()
|
||||||
version_line = re.search("\nversion = .*", contents)
|
version_line = re.search("\nversion = .*", contents)
|
||||||
exception = Exception("Version not found in gradle file")
|
exception = Exception("Version not found in gradle file")
|
||||||
|
@ -93,7 +93,7 @@ class GradleFileHandler(FileHandler):
|
||||||
return version, is_snapshot
|
return version, is_snapshot
|
||||||
|
|
||||||
def write(self, version_string):
|
def write(self, version_string):
|
||||||
with open(self.config_file_path, 'r+') as gradle_file:
|
with open(self.config_file_path, 'r+', encoding='utf-8') as gradle_file:
|
||||||
contents = gradle_file.read()
|
contents = gradle_file.read()
|
||||||
version_substitute = re.sub(
|
version_substitute = re.sub(
|
||||||
'\nversion = "[0-9]*\\.[0-9]*\\.[0-9]*(-SNAPSHOT)?"', f'\nversion = "{version_string}"', contents)
|
'\nversion = "[0-9]*\\.[0-9]*\\.[0-9]*(-SNAPSHOT)?"', f'\nversion = "{version_string}"', contents)
|
||||||
|
@ -107,7 +107,7 @@ class PythonFileHandler(FileHandler):
|
||||||
def parse(self) -> tuple[list[int], bool]:
|
def parse(self) -> tuple[list[int], bool]:
|
||||||
if self.config_file_path is None:
|
if self.config_file_path is None:
|
||||||
raise ValueError("No file name given.")
|
raise ValueError("No file name given.")
|
||||||
with open(self.config_file_path, 'r') as python_file:
|
with open(self.config_file_path, 'r', encoding='utf-8') as python_file:
|
||||||
contents = python_file.read()
|
contents = python_file.read()
|
||||||
version_line = re.search("\nversion = .*\n", contents)
|
version_line = re.search("\nversion = .*\n", contents)
|
||||||
exception = Exception("Version not found in gradle file")
|
exception = Exception("Version not found in gradle file")
|
||||||
|
@ -131,7 +131,7 @@ class PythonFileHandler(FileHandler):
|
||||||
return version, is_snapshot
|
return version, is_snapshot
|
||||||
|
|
||||||
def write(self, version_string):
|
def write(self, version_string):
|
||||||
with open(self.config_file_path, 'r+') as python_file:
|
with open(self.config_file_path, 'r+', encoding='utf-8') as python_file:
|
||||||
contents = python_file.read()
|
contents = python_file.read()
|
||||||
version_substitute = re.sub(
|
version_substitute = re.sub(
|
||||||
'\nversion = "[0-9]*\\.[0-9]*\\.[0-9]*(-SNAPSHOT)?"', f'\nversion = "{version_string}"', contents)
|
'\nversion = "[0-9]*\\.[0-9]*\\.[0-9]*(-SNAPSHOT)?"', f'\nversion = "{version_string}"', contents)
|
||||||
|
@ -145,7 +145,7 @@ class ClojureFileHandler(FileHandler):
|
||||||
def parse(self) -> tuple[list[int], bool]:
|
def parse(self) -> tuple[list[int], bool]:
|
||||||
if self.config_file_path is None:
|
if self.config_file_path is None:
|
||||||
raise ValueError("No file name given.")
|
raise ValueError("No file name given.")
|
||||||
with open(self.config_file_path, 'r') as clj_file:
|
with open(self.config_file_path, 'r', encoding='utf-8') as clj_file:
|
||||||
contents = clj_file.read()
|
contents = clj_file.read()
|
||||||
version_line = re.search("^\\(defproject .*\n", contents)
|
version_line = re.search("^\\(defproject .*\n", contents)
|
||||||
exception = Exception("Version not found in clj file")
|
exception = Exception("Version not found in clj file")
|
||||||
|
@ -169,7 +169,7 @@ class ClojureFileHandler(FileHandler):
|
||||||
return version, is_snapshot
|
return version, is_snapshot
|
||||||
|
|
||||||
def write(self, version_string):
|
def write(self, version_string):
|
||||||
with open(self.config_file_path, 'r+') as clj_file:
|
with open(self.config_file_path, 'r+', encoding='utf-8') as clj_file:
|
||||||
clj_first = clj_file.readline()
|
clj_first = clj_file.readline()
|
||||||
clj_rest = clj_file.read()
|
clj_rest = clj_file.read()
|
||||||
version_substitute = re.sub(
|
version_substitute = re.sub(
|
||||||
|
@ -185,6 +185,7 @@ class GitApi():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.execution_api = ExecutionApi()
|
self.execution_api = ExecutionApi()
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name
|
||||||
def get_latest_n_commits(self, n: int):
|
def get_latest_n_commits(self, n: int):
|
||||||
return self.execution_api.execute(
|
return self.execution_api.execute(
|
||||||
f'git log --oneline --format="%s %b" -n {n}')
|
f'git log --oneline --format="%s %b" -n {n}')
|
||||||
|
@ -203,11 +204,10 @@ class GitApi():
|
||||||
return self.execution_api.execute('git describe --tags --abbrev=0')
|
return self.execution_api.execute('git describe --tags --abbrev=0')
|
||||||
|
|
||||||
def get_current_branch(self):
|
def get_current_branch(self):
|
||||||
self.execution_api.execute('git branch --show-current')
|
return ''.join(self.execution_api.execute('git branch --show-current')).rstrip()
|
||||||
return ''.join(self.execution_api.stdout).rstrip()
|
|
||||||
|
|
||||||
def init(self, default_branch: str = "main"):
|
def init(self, default_branch: str = "main"):
|
||||||
self.execution_api.execute(f'git init')
|
self.execution_api.execute('git init')
|
||||||
self.execution_api.execute(f'git checkout -b {default_branch}')
|
self.execution_api.execute(f'git checkout -b {default_branch}')
|
||||||
|
|
||||||
def set_user_config(self, email: str, name: str):
|
def set_user_config(self, email: str, name: str):
|
||||||
|
|
Loading…
Reference in a new issue