+ {% for line in verse.lines %}
+ {{ line }}
+ {% endfor %}
+
+ {% endfor %}
+
+
+ {% endfor %}
+
+{% include "footer.html" %}
+
+
\ No newline at end of file
diff --git a/src/create_songbook.py b/src/create_songbook.py
new file mode 100644
index 0000000..5a2cc26
--- /dev/null
+++ b/src/create_songbook.py
@@ -0,0 +1,40 @@
+import latex_scanner
+from os.path import join
+from django.template import Engine, Context
+from django.conf import settings
+
+
+def generate_songbook(song_loader, song_numbers, out_file, dj_engine):
+ # Build the list of songs
+ song_list = []
+ for n in song_numbers:
+ found = None
+ for song in song_loader.songs:
+ if song.number == n:
+ found = song
+ break
+ if not found:
+ raise Exception("Could not find song with number " + str(n))
+ song_list.append(found)
+ # Export to html
+ context = Context({'songs': song_list})
+ with open(out_file, 'w') as f:
+ f.write(dj_engine.get_template("songbook.html").render(context))
+
+
+def create_argparser():
+ parser = latex_scanner.create_argparser()
+ parser.add_argument("--songs", required=True, nargs='+', type=int, help="A list of song numbers to include.")
+ parser.add_argument("--output-file", required=False, nargs=1, default=["misa.html"],
+ help="The file where the result should be placed, relative to --output-dir.")
+ return parser
+
+
+if __name__ == '__main__':
+ args = create_argparser().parse_args()
+ loader = latex_scanner.SongLoader(args.latex[0], args.audios[0])
+ if args.other_latex:
+ loader.scan_others(args.other_latex[0], args.other_index[0])
+ settings.configure(USE_TZ=False, USE_I18N=False)
+ e = Engine(dirs=["res/templates/"])
+ generate_songbook(loader, args.songs, join(args.output_dir[0], args.output_file[0]), e)
\ No newline at end of file
diff --git a/src/latex_scanner.py b/src/latex_scanner.py
index 4e427d1..b6bbe95 100644
--- a/src/latex_scanner.py
+++ b/src/latex_scanner.py
@@ -278,21 +278,21 @@ class SongLoader:
self.print_index(join(output_dir, "index.html"), dj_engine)
-def parse_args():
+def create_argparser():
parser = argparse.ArgumentParser()
parser.add_argument("--latex", required=True, nargs=1, help="The main LaTeX file. It may include other documents")
parser.add_argument("--other-latex", required=False, nargs=1, default=[None],
help="A folder with songs, those not referenced in the main file will be included at the end.")
- parser.add_argument("--other-index", required=False, nargs=1, default=["400"],
+ parser.add_argument("--other-index", required=False, nargs=1, type=int, default=[400],
help="The first song number for songs outside the main songbook.")
parser.add_argument("--audios", required=False, nargs=1, default=[None],
help="The folder containing the audio files.")
parser.add_argument("--output-dir", required=False, nargs=1, default=["public"])
- return parser.parse_args()
+ return parser
if __name__ == '__main__':
- args = parse_args()
+ args = create_argparser().parse_args()
loader = SongLoader(args.latex[0], args.audios[0])
if args.other_latex:
loader.scan_others(args.other_latex[0], int(args.other_index[0]))