--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/eric7/MultiProject/MultiProjectProjectMeta.py Fri Dec 15 15:28:54 2023 +0100 @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2023 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module defining a class containing the individual project metadata. +""" + +from dataclasses import asdict, dataclass + + +@dataclass +class MultiProjectProjectMeta: + """ + Class containing the individual project metadata. + """ + + name: str # name of the project + file: str # project file name + uid: str # unique identifier + master: bool = False # flag indicating the main project + description: str = "" # description of the project + category: str = "" # name of the group + removed: bool = False # flag indicating a (re-)moved project + + def as_dict(self): + """ + Public method to convert the metadata into a dictionary. + + @return dictionary containing the metadata + @rtype dict + """ + return asdict(self) + + @classmethod + def from_dict(cls, data): + """ + Class method to create a metadata object from the given dictionary. + + @param data dictionary containing the metadata + @type dict + @return created project metadata object + @rtype MultiProjectProjectMeta + """ + return cls( + name=data["name"], + file=data["file"], + uid=data["uid"], + master=data.get("master", False), + description=data.get("description", ""), + category=data.get("category", ""), + removed=data.get("removed", False), + )