From 7ac06d75d0785da07d270dc38a7581d74c285cc5 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 22 Oct 2021 20:43:01 +0200 Subject: Restructured disk.py into lib/disk/.py instead. Shouldn't be any broken links as we expose all the functions through __init__.py - but you never know so I'll keep an eye for issues with this. --- archinstall/lib/disk/validators.py | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 archinstall/lib/disk/validators.py (limited to 'archinstall/lib/disk/validators.py') diff --git a/archinstall/lib/disk/validators.py b/archinstall/lib/disk/validators.py new file mode 100644 index 00000000..0c9f5a74 --- /dev/null +++ b/archinstall/lib/disk/validators.py @@ -0,0 +1,42 @@ +def valid_parted_position(pos :str): + if not len(pos): + return False + + if pos.isdigit(): + return True + + if pos[-1] == '%' and pos[:-1].isdigit(): + return True + + if pos[-3:].lower() in ['mib', 'kib', 'b', 'tib'] and pos[:-3].replace(".", "", 1).isdigit(): + return True + + if pos[-2:].lower() in ['kb', 'mb', 'gb', 'tb'] and pos[:-2].replace(".", "", 1).isdigit(): + return True + + return False + +def valid_fs_type(fstype :str) -> bool: + # https://www.gnu.org/software/parted/manual/html_node/mkpart.html + # Above link doesn't agree with `man parted` /mkpart documentation: + """ + fs-type can + be one of "btrfs", "ext2", + "ext3", "ext4", "fat16", + "fat32", "hfs", "hfs+", + "linux-swap", "ntfs", "reis‐ + erfs", "udf", or "xfs". + """ + + return fstype.lower() in [ + "btrfs", + "ext2", + "ext3", "ext4", # `man parted` allows these + "fat16", "fat32", + "hfs", "hfs+", # "hfsx", not included in `man parted` + "linux-swap", + "ntfs", + "reiserfs", + "udf", # "ufs", not included in `man parted` + "xfs", # `man parted` allows this + ] \ No newline at end of file -- cgit v1.2.3-54-g00ecf