diff options
author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-08-05 15:36:54 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-08-05 15:57:38 +0700 |
commit | 8166f2665aa46beb842202821fdc2cfff4a01954 (patch) | |
tree | b45fe233900af26d51d8e98c741941d09b158a46 /brutalmaze/misc.py | |
parent | 91e5d148da7e6ef4488c08c284ef4b770352d413 (diff) | |
download | brutalmaze-8166f2665aa46beb842202821fdc2cfff4a01954.tar.gz |
Retire pkg_resources 1.0.0
Diffstat (limited to 'brutalmaze/misc.py')
-rw-r--r-- | brutalmaze/misc.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/brutalmaze/misc.py b/brutalmaze/misc.py index db1be00..94537db 100644 --- a/brutalmaze/misc.py +++ b/brutalmaze/misc.py @@ -1,5 +1,5 @@ -# misc.py - module for miscellaneous functions -# Copyright (C) 2017-2020 Nguyễn Gia Phong +# Miscellaneous functions +# Copyright (C) 2017-2021 Nguyễn Gia Phong # # This file is part of Brutal Maze. # @@ -19,6 +19,7 @@ __doc__ = 'Brutal Maze module for miscellaneous functions' from datetime import datetime +from importlib.resources import path as resource from itertools import chain from math import cos, degrees, pi, sin from os import path @@ -86,14 +87,15 @@ def json_rec(directory): """Return path to JSON file to be created inside the given directory based on current time local to timezone in ISO 8601 format. """ - return path.join( - directory, '{}.json'.format(datetime.now().isoformat()[:19])) + return path.join(directory, + '{}.json'.format(datetime.now().isoformat()[:19])) def play(sound: str, x: float = MIDDLE, y: float = MIDDLE, gain: float = 1.0) -> Source: """Play a sound at the given position.""" - source = Buffer(sound).play() + with resource('brutalmaze.soundfx', sound) as file: + source = Buffer(str(file)).play() source.spatialize = True source.position = x, -y, 0 source.gain = gain |