File size: 2,278 Bytes
44bafb2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

windows = ['Windows', 'NTFS', 'FAT32', 'exFAT', 'ReFS']
linux = ['Linux', 'ext2', 'ext3', 'ext4', 'Btrfs', 'XFS', 'ZFS']
macOS = ['macOS', 'APFS', 'HFS+']
bsd_unix = ['BSD', 'UFS']
network_filesystems = ['CIFS', 'SMB']


windows_translation = str.maketrans({
            '\\': '',
            '/': '',
            '?': '',
            ':': '',
            '*': '',
            '"': '',
            '<': '',
            '>': '',
            '|': '',
        })

linux_translation = str.maketrans({
            '/': '',
        })

macos_translation = str.maketrans({
            '/': '',
        })

bsd_translation = str.maketrans({
            '/': '',
        })

network_filesystems_translation = str.maketrans({
            '\\': '',
            '/': '',
            '?': '',
            ':': '',
            '*': '',
            '"': '',
            '<': '',
            '>': '',
            '|': '',
        })

def file_system_verify(file_type) -> dict:
    """
    Returns a translation table to remove invalid characters for a specified file system type.

    This function identifies the file system type and returns a translation table for removing 
    characters that are not allowed in filenames for that specific file system.

    Args:
        file_type (str): The type of file system being checked. Supported file systems include:
                         - Windows: NTFS, FAT32, exFAT, ReFS
                         - Linux: ext2, ext3, ext4, Btrfs, XFS, ZFS
                         - macOS: APFS, HFS+
                         - BSD/UNIX: UFS
                         - Network Filesystems: CIFS, SMB

    Returns:
        dict: A translation table where invalid characters are mapped to an empty string.

    Example:
        >>> ys = yt.streams.get_highest_resolution()
        >>> ys.download(file_system='ext4')

    Raises:
        None, but prints a message if the file system type is not recognized.
    """

    if file_type in windows:
        return windows_translation
    elif file_type in linux:
        return linux_translation
    elif file_type in macOS:
        return macos_translation
    elif file_type in bsd_unix:
        return bsd_translation
    elif file_type in network_filesystems:
        return network_filesystems_translation