Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/profile/profile_model.py
blob: 8c9557337dad98f1d1f076ba50483a67570b5be7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from __future__ import annotations

from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, Optional, Dict

from ..hardware import GfxDriver
from archinstall.default_profiles.profile import Profile, GreeterType

if TYPE_CHECKING:
	_: Any


@dataclass
class ProfileConfiguration:
	profile: Optional[Profile] = None
	gfx_driver: Optional[GfxDriver] = None
	greeter: Optional[GreeterType] = None

	def json(self) -> Dict[str, Any]:
		from .profiles_handler import profile_handler
		return {
			'profile': profile_handler.to_json(self.profile),
			'gfx_driver': self.gfx_driver.value if self.gfx_driver else None,
			'greeter': self.greeter.value if self.greeter else None
		}

	@classmethod
	def parse_arg(cls, arg: Dict[str, Any]) -> 'ProfileConfiguration':
		from .profiles_handler import profile_handler

		profile = profile_handler.parse_profile_config(arg['profile'])
		greeter = arg.get('greeter', None)
		gfx_driver = arg.get('gfx_driver', None)

		return ProfileConfiguration(
			profile,
			GfxDriver(gfx_driver) if gfx_driver else None,
			GreeterType(greeter) if greeter else None
		)