src/eric7/MultiProject/MultiProjectProjectMeta.py

Fri, 15 Dec 2023 15:28:54 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 15 Dec 2023 15:28:54 +0100
branch
eric7
changeset 10410
da82156f44e9
child 10439
21c28b0f9e41
permissions
-rw-r--r--

Multiproject
- Added the capability to indicate externally removed projects and actions to clear them out (see issue 522).

# -*- 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),
        )

eric ide

mercurial