mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
Pierre-Clement Tosi
c4f6a1a85f
Instrument: Fix & restructure reset()
Calling `Instrument.reset(kinds='some string')` leaves `self.active_channels` as `[]` which is probably not the expected behaviour. This is caused by the last nested `else` which refers to the condition `if isinstance(kinds, basestring)` and might have been overlooked because of having been confused with the top-level `else`. Anyhow, an `else` does not seem to be needed there. This bug illustrates the risk of having too many nested levels and execution paths which also impact the readability of the code. We modify the implementation to solve the bug on top of which we: - Reduce the maximum order of nested levels from 4 to 3; - Express more clearly the potential paths of execution (less nested conditions); - Replace unnecessary `for`-loops by list comprehensions, removing the need for an initialisation of `active_channels` and making clearer what each path of execution ends up with; - Removed unnecessary `List` copies of `self.channels.values()`; - Used the fact that the message of a `KeyError` is the unknown key.
devlib ====== ``devlib`` exposes an interface for interacting with and collecting measurements from a variety of devices (such as mobile phones, tablets and development boards) running a Linux-based operating system. Installation ------------ :: sudo -H pip install devlib Usage ----- Please refer to the "Overview" section of the `documentation <http://devlib.readthedocs.io/en/latest/>`_. License ------- This package is distributed under `Apache v2.0 License <http://www.apache.org/licenses/LICENSE-2.0>`_. Feedback, Contrubutions and Support ----------------------------------- - Please use the GitHub Issue Tracker associated with this repository for feedback. - ARM licensees may contact ARM directly via their partner managers. - We welcome code contributions via GitHub Pull requests. Please try to stick to the style in the rest of the code for your contributions.
Description
Languages
Python
96%
Shell
1.8%
C
1.4%
Java
0.5%
Dockerfile
0.3%