You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
839 B
Python

class Config:
def __init__(self, snap: bool, flatpak: bool, apport: bool, distrobox: bool):
self.snap = snap
self.flatpak = flatpak
self.apport = apport
self.distrobox = distrobox
def get_str(self) -> str:
return "snap::{0}|flatpak::{1}|apport::{2}|distrobox::{3}".format(
self.snap, self.flatpak, self.apport, self.distrobox
)
@classmethod
def from_str(cls, config_str: str) -> 'Config':
items = config_str.split('|')
snap = items[0].split('::')[1]
flatpak = items[1].split('::')[1]
apport = items[2].split('::')[1]
distrobox = items[3].split('::')[1]
return cls(
snap=bool(snap),
flatpak=bool(flatpak),
apport=bool(apport),
distrobox=bool(distrobox)
)