+ # Parse and manipulate the command line arguments.
+ try:
+ (opts, args) = getopt.gnu_getopt(argv[1:], "dhv", ["bibtex=", "bg=",
+ "debug", "dpi=", "fg=", "help", "latex=", "lilypond",
+ "lilypond-book=", "png", "ppm", "verbose"])
+ except getopt.GetoptError, err:
+ error("%s\n%s" % (err, usage(script_name)))
+
+ opts.reverse()
+ for opt, val in opts:
+ if opt in ("-h", "--help"):
+ print usage(script_name)
+ sys.exit(0)
+ elif opt == "--bibtex":
+ bibtex = [val]
+ elif opt == "--bg":
+ bg_color = val
+ elif opt in ("-d", "--debug"):
+ import lyxpreview_tools
+ lyxpreview_tools.debug = True
+ elif opt == "--dpi":
+ try:
+ dpi = string.atoi(val)
+ except:
+ error("Cannot convert %s to an integer value" % val)
+ elif opt == "--fg":
+ fg_color = val
+ elif opt == "--latex":
+ latex = [val]
+ elif opt == "--lilypond":
+ lilypond = True
+ elif opt == "--lilypond-book":
+ lilypond_book = [val]
+ elif opt in ("--png", "--ppm"):
+ output_format = opt[2:]
+ elif opt in ("-v", "--verbose"):
+ import lyxpreview_tools
+ lyxpreview_tools.verbose = True
+
+ # Determine input file
+ if len(args) != 1:
+ err = "A single input file is required, %s given" % (len(args) or "none")
+ error("%s\n%s" % (err, usage(script_name)))
+
+ input_path = args[0]