Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion archinstall/lib/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def safe_json(self) -> dict[str, Any]:

@classmethod
def from_config(cls, args_config: dict[str, Any], args: Arguments) -> 'ArchConfig':
arch_config = ArchConfig()
arch_config = cls()

arch_config.locale_config = LocaleConfiguration.parse_arg(args_config)

Expand Down
10 changes: 5 additions & 5 deletions archinstall/lib/models/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,25 @@ def get_default(cls) -> Bootloader:
from ..args import arch_config_handler

if arch_config_handler.args.skip_boot:
return Bootloader.NO_BOOTLOADER
return cls.NO_BOOTLOADER
elif SysInfo.has_uefi():
return Bootloader.Systemd
return cls.Systemd
else:
return Bootloader.Grub
return cls.Grub

@classmethod
def from_arg(cls, bootloader: str, skip_boot: bool) -> Bootloader:
# to support old configuration files
bootloader = bootloader.capitalize()

bootloader_options = [e.value for e in Bootloader if e != Bootloader.NO_BOOTLOADER or skip_boot is True]
bootloader_options = [e.value for e in cls if e != cls.NO_BOOTLOADER or skip_boot is True]

if bootloader not in bootloader_options:
values = ', '.join(bootloader_options)
warn(f'Invalid bootloader value "{bootloader}". Allowed values: {values}')
sys.exit(1)

return Bootloader(bootloader)
return cls(bootloader)


@dataclass
Expand Down
32 changes: 16 additions & 16 deletions archinstall/lib/models/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def parse_arg(
if not config_type:
raise ValueError('Missing disk layout configuration: config_type')

config = DiskLayoutConfiguration(
config = cls(
config_type=DiskLayoutType(config_type),
device_modifications=device_modifications,
)
Expand Down Expand Up @@ -294,7 +294,7 @@ def json(self) -> _SectorSizeSerialization:

@classmethod
def parse_args(cls, arg: _SectorSizeSerialization) -> SectorSize:
return SectorSize(
return cls(
arg['value'],
Unit[arg['unit']],
)
Expand Down Expand Up @@ -333,7 +333,7 @@ def json(self) -> _SizeSerialization:
def parse_args(cls, size_arg: _SizeSerialization) -> Size:
sector_size = size_arg['sector_size']

return Size(
return cls(
size_arg['value'],
Unit[size_arg['unit']],
SectorSize.parse_args(sector_size),
Expand Down Expand Up @@ -553,7 +553,7 @@ def from_partition(
SectorSize(partition.disk.device.sectorSize, Unit.B),
)

return _PartitionInfo(
return cls(
partition=partition,
name=partition.get_name(),
type=partition_type,
Expand Down Expand Up @@ -608,7 +608,7 @@ def from_disk(cls, disk: Disk) -> _DeviceInfo:
sector_size = SectorSize(device.sectorSize, Unit.B)
free_space = [DeviceGeometry(g, sector_size) for g in disk.getFreeSpaceRegions()]

return _DeviceInfo(
return cls(
model=device.model.strip(),
path=Path(device.path),
type=device_type,
Expand All @@ -632,7 +632,7 @@ class SubvolumeModification:

@classmethod
def from_existing_subvol_info(cls, info: _BtrfsSubvolumeInfo) -> SubvolumeModification:
return SubvolumeModification(info.name, mountpoint=info.mountpoint)
return cls(info.name, mountpoint=info.mountpoint)

@classmethod
def parse_args(cls, subvol_args: list[_SubvolumeModificationSerialization]) -> list[SubvolumeModification]:
Expand All @@ -644,7 +644,7 @@ def parse_args(cls, subvol_args: list[_SubvolumeModificationSerialization]) -> l

mountpoint = Path(entry['mountpoint']) if entry['mountpoint'] else None

mods.append(SubvolumeModification(entry['name'], mountpoint))
mods.append(cls(entry['name'], mountpoint))

return mods

Expand Down Expand Up @@ -723,10 +723,10 @@ class PartitionType(Enum):
@classmethod
def get_type_from_code(cls, code: int) -> PartitionType:
if code == parted.PARTITION_NORMAL:
return PartitionType.Primary
return cls.Primary
else:
debug(f'Partition code not supported: {code}')
return PartitionType._Unknown
return cls._Unknown

def get_partition_code(self) -> int | None:
if self == PartitionType.Primary:
Expand Down Expand Up @@ -923,7 +923,7 @@ def from_existing_partition(cls, partition_info: _PartitionInfo) -> PartitionMod
mountpoint = partition_info.mountpoints[0] if partition_info.mountpoints else None
subvol_mods = []

return PartitionModification(
return cls(
status=ModificationStatus.Exist,
type=partition_info.type,
start=partition_info.start,
Expand Down Expand Up @@ -1433,10 +1433,10 @@ class EncryptionType(Enum):
@classmethod
def _encryption_type_mapper(cls) -> dict[str, 'EncryptionType']:
return {
tr('No Encryption'): EncryptionType.NoEncryption,
tr('LUKS'): EncryptionType.Luks,
tr('LVM on LUKS'): EncryptionType.LvmOnLuks,
tr('LUKS on LVM'): EncryptionType.LuksOnLvm,
tr('No Encryption'): cls.NoEncryption,
tr('LUKS'): cls.Luks,
tr('LVM on LUKS'): cls.LvmOnLuks,
tr('LUKS on LVM'): cls.LuksOnLvm,
}

@classmethod
Expand Down Expand Up @@ -1539,7 +1539,7 @@ def parse_arg(
if vol.obj_id in disk_encryption.get('lvm_volumes', []):
volumes.append(vol)

enc = DiskEncryption(
enc = cls(
EncryptionType(disk_encryption['encryption_type']),
password,
enc_partitions,
Expand Down Expand Up @@ -1583,7 +1583,7 @@ def table_data(self) -> dict[str, str]:

@classmethod
def parse_arg(cls, arg: _Fido2DeviceSerialization) -> 'Fido2Device':
return Fido2Device(
return cls(
Path(arg['path']),
arg['manufacturer'],
arg['product'],
Expand Down
6 changes: 3 additions & 3 deletions archinstall/lib/models/mirrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def parse_args(cls, args: list[dict[str, str]]) -> list['CustomRepository']:
configs = []
for arg in args:
configs.append(
CustomRepository(
cls(
arg['name'],
arg['url'],
SignCheck(arg['sign_check']),
Expand All @@ -221,7 +221,7 @@ def parse_args(cls, args: list[dict[str, str]]) -> list['CustomServer']:
configs = []
for arg in args:
configs.append(
CustomServer(arg['url']),
cls(arg['url']),
)

return configs
Expand Down Expand Up @@ -305,7 +305,7 @@ def parse_args(
args: dict[str, Any],
backwards_compatible_repo: list[Repository] = [],
) -> 'MirrorConfiguration':
config = MirrorConfiguration()
config = cls()

mirror_regions = args.get('mirror_regions', [])
if mirror_regions:
Expand Down
2 changes: 1 addition & 1 deletion archinstall/lib/models/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def from_wpa_cli_output(cls, list_networks: str) -> list[WifiConfiguredNetwork]:
flags: list[str] = []

networks.append(
WifiConfiguredNetwork(
cls(
network_id=int(parts[0]),
ssid=parts[1],
bssid=parts[2],
Expand Down
2 changes: 1 addition & 1 deletion archinstall/lib/models/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def from_available_packages(
if len(group) == 0:
continue

pkg_groups.setdefault(group, PackageGroup(group))
pkg_groups.setdefault(group, cls(group))
pkg_groups[group].packages.append(pkg.name)

return pkg_groups
Expand Down
2 changes: 1 addition & 1 deletion archinstall/lib/models/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def parse_arg(cls, arg: _ProfileConfigurationSerialization) -> 'ProfileConfigura
greeter = arg.get('greeter', None)
gfx_driver = arg.get('gfx_driver', None)

return ProfileConfiguration(
return cls(
profile,
GfxDriver(gfx_driver) if gfx_driver else None,
GreeterType(greeter) if greeter else None,
Expand Down
36 changes: 18 additions & 18 deletions archinstall/lib/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,45 +59,45 @@ def _check_password_strength(
if digit and upper and lower and symbol:
match length:
case num if 13 <= num:
return PasswordStrength.STRONG
return cls.STRONG
case num if 11 <= num <= 12:
return PasswordStrength.MODERATE
return cls.MODERATE
case num if 7 <= num <= 10:
return PasswordStrength.WEAK
return cls.WEAK
case num if num <= 6:
return PasswordStrength.VERY_WEAK
return cls.VERY_WEAK
elif digit and upper and lower:
match length:
case num if 14 <= num:
return PasswordStrength.STRONG
return cls.STRONG
case num if 11 <= num <= 13:
return PasswordStrength.MODERATE
return cls.MODERATE
case num if 7 <= num <= 10:
return PasswordStrength.WEAK
return cls.WEAK
case num if num <= 6:
return PasswordStrength.VERY_WEAK
return cls.VERY_WEAK
elif upper and lower:
match length:
case num if 15 <= num:
return PasswordStrength.STRONG
return cls.STRONG
case num if 12 <= num <= 14:
return PasswordStrength.MODERATE
return cls.MODERATE
case num if 7 <= num <= 11:
return PasswordStrength.WEAK
return cls.WEAK
case num if num <= 6:
return PasswordStrength.VERY_WEAK
return cls.VERY_WEAK
elif lower or upper:
match length:
case num if 18 <= num:
return PasswordStrength.STRONG
return cls.STRONG
case num if 14 <= num <= 17:
return PasswordStrength.MODERATE
return cls.MODERATE
case num if 9 <= num <= 13:
return PasswordStrength.WEAK
return cls.WEAK
case num if num <= 8:
return PasswordStrength.VERY_WEAK
return cls.VERY_WEAK

return PasswordStrength.VERY_WEAK
return cls.VERY_WEAK


UserSerialization = TypedDict(
Expand Down Expand Up @@ -204,7 +204,7 @@ def parse_arguments(
if not username or password is None:
continue

user = User(
user = cls(
username=username,
password=password,
sudo=entry.get('sudo', False) is True,
Expand Down
4 changes: 2 additions & 2 deletions archinstall/tui/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ class FrameProperties:

@classmethod
def max(cls, header: str) -> 'FrameProperties':
return FrameProperties(
return cls(
header,
FrameStyle.MAX,
FrameStyle.MAX,
)

@classmethod
def min(cls, header: str) -> 'FrameProperties':
return FrameProperties(
return cls(
header,
FrameStyle.MIN,
FrameStyle.MIN,
Expand Down