You can replace lines 142-144 with:
```python
if device in partitions:
   return partitions[device] == ptype
```