diff --git a/.forgejo/workflows/config/.pylintrc b/.forgejo/workflows/config/.pylintrc index e69de29..6b82ceb 100644 --- a/.forgejo/workflows/config/.pylintrc +++ b/.forgejo/workflows/config/.pylintrc @@ -0,0 +1,6 @@ + [MESSAGES CONTROL] + disable= + missing-module-docstring, + missing-function-docstring, + line-too-long, + too-many-arguments, diff --git a/stellarismodparser/stellarismodparser.py b/stellarismodparser/stellarismodparser.py index 5fef8f8..3f3fdf8 100644 --- a/stellarismodparser/stellarismodparser.py +++ b/stellarismodparser/stellarismodparser.py @@ -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: