pylint fixes
Some checks failed
Actions / Lint Code (Ruff & Pylint) (push) Failing after 16s
Actions / Build (push) Successful in 26s

This commit is contained in:
Seaswimmer 2024-06-22 02:03:44 -04:00
parent 352e087518
commit b4b5b672c6
Signed by: cswimr
GPG key ID: 3813315477F26F82
2 changed files with 37 additions and 9 deletions

View file

@ -0,0 +1,6 @@
[MESSAGES CONTROL]
disable=
missing-module-docstring,
missing-function-docstring,
line-too-long,
too-many-arguments,

View file

@ -7,6 +7,19 @@ from semver import Version
logger = getLogger(__name__)
class Mod:
"""This class represents a Stellaris mod's descriptor file.
Attributes:
name (str): The name of the mod.
path (PathLike): The path to the mod's directory.
dependencies (List[str]): A list of the mod's dependencies.
picture (PathLike): The path to the mod's thumbnail picture.
tags (List[str]): A list of the mod's tags.
version (str): The mod's version.
supported_version (StellarisVersion): The version of Stellaris the mod supports.
remote_file_id (int): The mod's remote file ID.
"""
def __init__(
self,
name: str,
@ -61,6 +74,14 @@ class Mod:
}
class StellarisVersion(Version):
"""This class represents a Stellaris version.
Attributes:
major (int): The major version number.
minor (int): The minor version number.
patch (int): The patch version number.
codename (str): The codename of the version.
"""
def __init__(self, **kwargs) -> None:
# Build a dictionary of the arguments except prerelease and build
super().__init__(**kwargs)
@ -117,22 +138,23 @@ class StellarisVersion(Version):
return (self.codename, self.major, self.minor, self.patch, self.prerelease, self.build)
def to_dict(self) -> dict:
return dict(
codename=self.codename,
major=self.major,
minor=self.minor,
patch=self.patch,
prerelease=self.prerelease,
build=self.build,
)
return {
"codename": self.codename,
"major": self.major,
"minor": self.minor,
"patch": self.patch,
"prerelease": self.prerelease,
"build": self.build
}
def parse(path: PathLike) -> Mod:
"""Parse a Stellaris mod descriptor file into a Mod object."""
config = {}
current_key = None
in_multiline_value = False
multiline_value = []
with open(path, 'r') as file:
with open(path, 'r', encoding='UTF-8') as file:
lines = file.readlines()
for line in lines: