From de71c01cd5c6dca3b33201a9effafc6c422fa239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 20 Oct 2019 18:55:57 +0200 Subject: Add comment action --- documentation_en.md | 2 ++ documentation_fr.md | 2 ++ music_sampler/actions/__init__.py | 1 + music_sampler/actions/comment.py | 5 +++++ music_sampler/helpers.py | 2 +- music_sampler/mapping.py | 2 +- music_sampler/sysfont.py | 2 +- 7 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 music_sampler/actions/comment.py diff --git a/documentation_en.md b/documentation_en.md index ee95ad3..c616eda 100644 --- a/documentation_en.md +++ b/documentation_en.md @@ -348,6 +348,8 @@ Pauses "music1.mp3" for 10 seconds and reruns it afterward, seeking to 5 seconds later. #### List of all the actions: +- `comment`: does nothing, but shows a comment in the action windows + * `message: "some text"` the message to show - `play` : start a music. Music Sampler only runs a music once (if you want to have it playing several time concurrently, duplicate it or make symbolic link). Parameters: diff --git a/documentation_fr.md b/documentation_fr.md index 76a4b97..7434a5c 100644 --- a/documentation_fr.md +++ b/documentation_fr.md @@ -371,6 +371,8 @@ Met en pause la musique "music1.mp3" pour 10 secondes et la relance après, en avançant de 5 secondes dans la musique. #### Liste des actions possibles: +- `comment`: ne fait aucune action, mais affiche un message dans la zone des actions + * `message: "some text"` le message à afficher - `play` : joue une musique. music_sampler ne joue qu'une musique à la fois : si la musique demandée est déjà en train d'être jouée, elle n'est pas relancée ou jouée "par dessus". Paramètres : diff --git a/music_sampler/actions/__init__.py b/music_sampler/actions/__init__.py index e0671fe..2f4cc54 100644 --- a/music_sampler/actions/__init__.py +++ b/music_sampler/actions/__init__.py @@ -1,3 +1,4 @@ +from . import comment from . import interrupt_wait from . import load_music from . import pause diff --git a/music_sampler/actions/comment.py b/music_sampler/actions/comment.py new file mode 100644 index 0000000..c7baa82 --- /dev/null +++ b/music_sampler/actions/comment.py @@ -0,0 +1,5 @@ +def run(action, music=None, **kwargs): + pass + +def description(action, message, **kwargs): + return message diff --git a/music_sampler/helpers.py b/music_sampler/helpers.py index fbd338b..9eb1a95 100644 --- a/music_sampler/helpers.py +++ b/music_sampler/helpers.py @@ -232,7 +232,7 @@ def dump_config(): item, max_size, getattr(Config, item))) def build_config(args): - stream = open(Config.yml_file, "r") + stream = open(Config.yml_file, "r", encoding='utf8') try: config = yaml.safe_load(stream) except Exception as e: diff --git a/music_sampler/mapping.py b/music_sampler/mapping.py index 193f5e5..fc9768b 100644 --- a/music_sampler/mapping.py +++ b/music_sampler/mapping.py @@ -391,7 +391,7 @@ class Mapping(RelativeLayout): "a float, ignored".format(filename)) return music_property - stream = open(Config.yml_file, "r") + stream = open(Config.yml_file, "r", encoding='utf8') try: config = yaml.safe_load(stream) except Exception as e: diff --git a/music_sampler/sysfont.py b/music_sampler/sysfont.py index f47693e..7bb518e 100644 --- a/music_sampler/sysfont.py +++ b/music_sampler/sysfont.py @@ -115,7 +115,7 @@ def _cache_fonts_fontconfig(): # get the font name name = None - if len(values) > 3: + if len(values) > 4: fullnames, fullnamelangs = values[3:] langs = fullnamelangs.split(",") try: -- cgit v1.2.3