From 24dcb1871e04ad408ab4b15fa8abd06fc5b81c3d Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 17 Feb 2014 14:06:23 +0100 Subject: [PATCH] =?UTF-8?q?Changement=20de=20l'ordre=20de=20priorit=C3=A9?= =?UTF-8?q?=20de=20datadir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1) Ligne de commande 2) Sinon, défini dans le fichier .sb 3) Sinon, répertoire du fichier .sb --- songbook.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/songbook.py b/songbook.py index 5997b2e0..ed9c5b54 100755 --- a/songbook.py +++ b/songbook.py @@ -22,7 +22,7 @@ def argument_parser(args): Book to compile. """)) - parser.add_argument('--datadir', '-d', nargs=1, type=str, action='store', default=".", + parser.add_argument('--datadir', '-d', nargs=1, type=str, action='store', help=textwrap.dedent("""\ Data location. Expected (not necessarily required) subdirectories are 'songs', 'img', 'latex', 'templates'. """)) @@ -44,11 +44,13 @@ def main(): sb = json.load(f) f.close() - if 'datadir' in sb.keys(): + if options.datadir is not None: + sb['datadir'] = options.datadir + elif 'datadir' in sb.keys(): if not os.path.isabs(sb['datadir']): sb['datadir'] = os.path.join(os.path.dirname(sbFile), sb['datadir']) else: - sb['datadir'] = options.datadir + sb['datadir'] = os.path.dirname(sbFile) buildsongbook(sb, basename) if __name__ == '__main__':