File: lbj2pdf

package info (click to toggle)
laborejo 0.8~ds0-2
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 13,260 kB
  • ctags: 2,211
  • sloc: python: 20,735; sh: 169; makefile: 5
file content (29 lines) | stat: -rwxr-xr-x 1,360 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
if __name__ == "__main__":
    import argparse, sys, os
    parser = argparse.ArgumentParser(description="Convert Laborejo Collections(.lbj) and Score (.lbjs) files to PDF through Lilypond.")
    parser.add_argument('infiles', help="One or more lbj or lbjs files to convert to PDF.", nargs="*")
    parser.add_argument("-o", "--out", help="Directory for PDF files. Default is the working directory", type=str)
    parser.add_argument("-p", "--parts", help="Export multiple files, splitted by a track property. Most likely 'exportExtractPart'. Other reasonable choices: 'group', 'uniqueContainerName' (by track), 'shortInstrumentName'", default=None, type=str)


    args = parser.parse_args()

    import laborejocore as api #This starts the backend and automatically creates a session. But not score/tracks.

    if args.out:
        outdir = os.path.join(os.path.abspath(args.out), "")
    else:
        outdir = os.path.join(os.path.abspath(os.curdir), "")

    if not os.path.isdir(outdir):
        os.makedirs(outdir)

    for filename in args.infiles:
        filename = os.path.abspath(filename)
        if filename.endswith("lbjs") or filename.endswith("lbj"):
            api.load(filename)
            api.exportPDF(os.path.join(outdir, os.path.basename(filename)), parts = args.parts)

    sys.exit()