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