|
1 |
| -# The MIT License (MIT) |
| 1 | +# SPDX-FileCopyrightText: 2019 ladyada for Adafruit Industries |
2 | 2 | #
|
3 |
| -# Copyright (c) 2019 Adafruit for Adafruit Industries |
4 |
| -# |
5 |
| -# Permission is hereby granted, free of charge, to any person obtaining a copy |
6 |
| -# of this software and associated documentation files (the "Software"), to deal |
7 |
| -# in the Software without restriction, including without limitation the rights |
8 |
| -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
9 |
| -# copies of the Software, and to permit persons to whom the Software is |
10 |
| -# furnished to do so, subject to the following conditions: |
11 |
| -# |
12 |
| -# The above copyright notice and this permission notice shall be included in |
13 |
| -# all copies or substantial portions of the Software. |
14 |
| -# |
15 |
| -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16 |
| -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17 |
| -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
18 |
| -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19 |
| -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
20 |
| -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
21 |
| -# THE SOFTWARE. |
| 3 | +# SPDX-License-Identifier: MIT |
| 4 | + |
22 | 5 | """
|
23 | 6 | `adafruit_pyoa`
|
24 | 7 | ================================================================================
|
@@ -190,8 +173,8 @@ def load_game(self, game_directory):
|
190 | 173 | self._gamefilename = game_directory + "/cyoa.json"
|
191 | 174 | try:
|
192 | 175 | game_file = open(self._gamefilename, "r")
|
193 |
| - except OSError: |
194 |
| - raise OSError("Could not open game file " + self._gamefilename) |
| 176 | + except OSError as err: |
| 177 | + raise OSError("Could not open game file " + self._gamefilename) from err |
195 | 178 | self._game = json.load(game_file)
|
196 | 179 | game_file.close()
|
197 | 180 |
|
@@ -360,8 +343,8 @@ def play_sound(self, filename, *, wait_to_finish=True, loop=False):
|
360 | 343 | self._display.wait_for_frame()
|
361 | 344 | try:
|
362 | 345 | self._wavfile = open(filename, "rb")
|
363 |
| - except OSError: |
364 |
| - raise OSError("Could not locate sound file", filename) |
| 346 | + except OSError as err: |
| 347 | + raise OSError("Could not locate sound file", filename) from err |
365 | 348 |
|
366 | 349 | wavedata = audioio.WaveFile(self._wavfile)
|
367 | 350 | self._speaker_enable.value = True
|
@@ -434,8 +417,7 @@ def set_background(self, filename, *, with_fade=True):
|
434 | 417 | self.backlight_fade(1.0)
|
435 | 418 |
|
436 | 419 | def backlight_fade(self, to_light):
|
437 |
| - """Adjust the TFT backlight. Fade from one value to another |
438 |
| - """ |
| 420 | + """Adjust the TFT backlight. Fade from one value to another""" |
439 | 421 | from_light = self._display.brightness
|
440 | 422 | from_light = int(from_light * 100)
|
441 | 423 | to_light = max(0, min(1.0, to_light))
|
|
0 commit comments