Conditions | 6 |
Total Lines | 25 |
Code Lines | 17 |
Lines | 25 |
Ratio | 100 % |
Changes | 0 |
1 | """ |
||
29 | def scan(self, pc_dir: str) -> List[Dict]: |
||
30 | """ |
||
31 | Scans recursively a directory for auxiliary of hosts. |
||
32 | |||
33 | :param str pc_dir: The PC dir, i.e. the directory where the host backups are stored. |
||
34 | """ |
||
35 | self.__io.writeln(' Scanning <fso>{}</fso>'.format(pc_dir)) |
||
36 | |||
37 | hosts = [] |
||
38 | files = [] |
||
39 | for entry in os.scandir(pc_dir): |
||
40 | if entry.is_dir(): |
||
41 | hosts.append(entry.name) |
||
42 | |||
43 | for host in hosts: |
||
44 | host_dir = os.path.join(pc_dir, host) |
||
45 | for entry in os.scandir(host_dir): |
||
46 | if entry.is_file(): |
||
47 | stats = os.stat(os.path.join(host_dir, entry.name)) |
||
48 | files.append({'host': host, |
||
49 | 'name': entry.name, |
||
50 | 'size': stats.st_size, |
||
51 | 'mtime': stats.st_mtime}) |
||
52 | |||
53 | return files |
||
54 | |||
56 |