From 1773163d37d82099d149b3087a81adee76aa3b18 Mon Sep 17 00:00:00 2001 From: Louis Date: Wed, 21 Oct 2015 19:10:07 +0200 Subject: [PATCH] Added a warning when files could not be found --- patacrep/songs/chordpro/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py index 4f33a084..39c8825c 100644 --- a/patacrep/songs/chordpro/__init__.py +++ b/patacrep/songs/chordpro/__init__.py @@ -2,6 +2,7 @@ from jinja2 import Environment, FileSystemLoader, contextfunction, ChoiceLoader import jinja2 +import logging import os from pkg_resources import resource_filename @@ -10,6 +11,8 @@ from patacrep.songs import Song from patacrep.songs.chordpro.syntax import parse_song from patacrep.templates import Renderer +LOGGER = logging.getLogger(__name__) + class ChordproSong(Song): """Chordpro song parser""" # pylint: disable=abstract-method @@ -76,6 +79,7 @@ class Chordpro2HtmlSong(ChordproSong): datadir, filename, extensions = self.search_datadir_file(filename, extensions, datadirs) return os.path.join(datadir, filename + extensions) except FileNotFoundError: + LOGGER.warning("Song '%s' (datadir '%s'): File '%s' not found.", self.subpath, self.datadir, filename) return None class Chordpro2LatexSong(ChordproSong): @@ -92,6 +96,7 @@ class Chordpro2LatexSong(ChordproSong): ) return filename except FileNotFoundError: + LOGGER.warning("Song '%s' (datadir '%s'): File '%s' not found.", self.subpath, self.datadir, filename) return None class Chordpro2ChordproSong(ChordproSong):