+ # 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 as 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"):
+ lyxpreview_tools.debug = True
+ elif opt == "--dpi":
+ try:
+ dpi = int(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"):
+ 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]
+ dir, latex_file = os.path.split(input_path)
+
+ # Check for the input file
+ if not os.path.exists(input_path):
+ error('File "%s" not found.' % input_path)