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
29 lines
839 B
Python
2 years ago
|
class Config:
|
||
|
|
||
2 years ago
|
def __init__(self, snap: bool, flatpak: bool, apport: bool, distrobox: bool):
|
||
2 years ago
|
self.snap = snap
|
||
|
self.flatpak = flatpak
|
||
|
self.apport = apport
|
||
2 years ago
|
self.distrobox = distrobox
|
||
2 years ago
|
|
||
|
def get_str(self) -> str:
|
||
2 years ago
|
return "snap::{0}|flatpak::{1}|apport::{2}|distrobox::{3}".format(
|
||
|
self.snap, self.flatpak, self.apport, self.distrobox
|
||
2 years ago
|
)
|
||
2 years ago
|
|
||
2 years ago
|
@classmethod
|
||
|
def from_str(cls, config_str: str) -> 'Config':
|
||
|
items = config_str.split('|')
|
||
2 years ago
|
|
||
2 years ago
|
snap = items[0].split('::')[1]
|
||
|
flatpak = items[1].split('::')[1]
|
||
|
apport = items[2].split('::')[1]
|
||
2 years ago
|
distrobox = items[3].split('::')[1]
|
||
2 years ago
|
|
||
|
return cls(
|
||
|
snap=bool(snap),
|
||
|
flatpak=bool(flatpak),
|
||
2 years ago
|
apport=bool(apport),
|
||
|
distrobox=bool(distrobox)
|
||
2 years ago
|
)
|