Example #1
0
	def run (self):
		"""
		This method actually runs BibTeX with the appropriate environment
		variables set.
		"""
		msg.progress(_("running BibTeX on %s") % msg.simplify(self.base))
		doc = {}
		if len(self.bib_path) != 1:
			doc["BIBINPUTS"] = string.join(self.bib_path +
				[os.getenv("BIBINPUTS", "")], ":")
		if len(self.bst_path) != 1:
			doc["BSTINPUTS"] = string.join(self.bst_path +
				[os.getenv("BSTINPUTS", "")], ":")
		if self.crossrefs is None:
			cmd = ["bibtex"]
		else:
			cmd = ["bibtex", "-min-crossrefs=" + self.crossrefs]
		cmd.append(self.doc.env.file_name(self.base))
		msg.log(_("executing: %s") % " ".join(cmd), pkg="bibtex")
		process = Popen(cmd, stdout=PIPE, stderr=PIPE)
		process.communicate()
		if process.wait() != 0:
			msg.info(_("There were errors making the bibliography."))
			return False
		self.run_needed = 0
		self.doc.must_compile = 1
		return True
Example #2
0
    def run(self):
        """
		This method actually runs BibTeX with the appropriate environment
		variables set.
		"""
        msg.progress(_("running BibTeX on %s") % msg.simplify(self.base))
        doc = {}
        if len(self.bib_path) != 1:
            doc["BIBINPUTS"] = string.join(
                self.bib_path + [os.getenv("BIBINPUTS", "")], ":")
        if len(self.bst_path) != 1:
            doc["BSTINPUTS"] = string.join(
                self.bst_path + [os.getenv("BSTINPUTS", "")], ":")
        if self.crossrefs is None:
            cmd = ["bibtex"]
        else:
            cmd = ["bibtex", "-min-crossrefs=" + self.crossrefs]
        # BibTeX comes with a straightjacket in some TeX distros and can't write
        # to absolute paths.  strip the directory, and change into that dir.
        workdir = os.path.dirname(self.base)
        basename = os.path.basename(self.base)
        if self.doc.env.execute(['bibtex', basename], doc, pwd=workdir):
            msg.info(_("There were errors making the bibliography."))
            return False
        self.run_needed = 0
        self.doc.must_compile = 1
        return True
Example #3
0
	def run (self):
		msg.progress(_("compressing %s") % self.sources[0])
		out = BZ2File(self.products[0], 'w')
		file = open(self.sources[0])
		out.write(file.read())
		file.close()
		out.close()
		return True
Example #4
0
def run(doc, env, base):
	msg.progress(_("running slatex on %s") % doc.src_base)
	if env.execute(["slatex", "-n", base], {}):
		msg.error(_("Error executing slatex"))
		return 1
			
	doc.must_compile = 1
	return 0
Example #5
0
def run(doc, env, base):
    msg.progress(_("running slatex on %s") % doc.src_base)
    if env.execute(["slatex", "-n", base], {}):
        msg.error(_("Error executing slatex"))
        return 1

    doc.must_compile = 1
    return 0
Example #6
0
 def run(self):
     msg.progress(_("compressing %s") % self.sources[0])
     out = GzipFile(self.products[0], 'w')
     file = open(self.sources[0])
     out.write(file.read())
     file.close()
     out.close()
     return True
Example #7
0
 def run(self):
     msg.progress(_("running dvipdfm on %s") % self.source)
     cmd = ['dvipdfm']
     for opt in self.doc.vars['paper'].split():
         cmd.extend(['-p', opt])
     cmd.extend(self.options + ['-o', self.target, self.source])
     if self.env.execute(cmd, kpse=1):
         msg.error(_("dvipdfm failed on %s") % self.source)
         return False
     return True
Example #8
0
 def run (self):
     msg.progress (_ ("compressing %s into %s") % (self.source, self.target))
     try:
         with open (self.source, 'rb') as f_in:
             with self.constructor (self.target, 'wb') as f_out:
                 f_out.writelines (f_in)
     except:
         msg.error (_ ("compression failed"))
         return False
     return True
Example #9
0
 def run(self):
     msg.progress(_("compressing %s into %s") % (self.source, self.target))
     try:
         with open(self.source, 'rb') as f_in:
             with self.constructor(self.target, 'wb') as f_out:
                 f_out.writelines(f_in)
     except:
         msg.error(_("compression failed"))
         return False
     return True
Example #10
0
 def run(self):
     msg.progress(_("running dvipdfm on %s") % self.source)
     cmd = ["dvipdfm"]
     for opt in self.doc.vars["paper"].split():
         cmd.extend(["-p", opt])
     cmd.extend(self.options + ["-o", self.target, self.source])
     if self.env.execute(cmd, kpse=1):
         msg.error(_("dvipdfm failed on %s") % self.source)
         return False
     return True
Example #11
0
    def post_compile(self):
        """
		Run makeindex if needed, with appropriate options and environment.
		"""
        if not os.path.exists(self.source):
            msg.log(_("strange, there is no %s") % self.source, pkg="index")
            return True
        if not self.run_needed():
            return True

        msg.progress(_("processing index %s") % msg.simplify(self.source))

        if self.tool == "makeindex":
            cmd = ["makeindex", "-q", "-o", self.target] + self.opts
            cmd.extend(["-t", self.transcript])
            if self.style:
                cmd.extend(["-s", self.style])
            cmd.append(self.source)
            path_var = "INDEXSTYLE"

        elif self.tool == "xindy":
            cmd = ["texindy", "--quiet"]
            for opt in self.opts:
                if opt == "-g":
                    if self.lang != "":
                        msg.warn(_("'language' overrides 'order german'"),
                                 pkg="index")
                    else:
                        self.lang = "german-din"
                elif opt == "-l":
                    self.modules.append("letter-ordering")
                    msg.warn(_(
                        "use 'module letter-ordering' instead of 'order letter'"
                    ),
                             pkg="index")
                else:
                    msg.error("unknown option to xindy: %s" % opt, pkg="index")
            for mod in self.modules:
                cmd.extend(["--module", mod])
            if self.lang:
                cmd.extend(["--language", self.lang])
            cmd.append(self.source)
            path_var = "XINDY_SEARCHPATH"

        if self.path != []:
            env = {path_var: ':'.join(self.path + [os.getenv(path_var, '')])}
        else:
            env = {}
        if self.doc.env.execute(cmd, env):
            msg.error(_("could not make index %s") % self.target)
            return False

        self.doc.must_compile = 1
        return True
Example #12
0
	def post_compile (self):
		"""
		Run makeindex if needed, with appropriate options and environment.
		"""
		if not os.path.exists(self.source):
			msg.log(_("strange, there is no %s") % self.source, pkg="index")
			return True
		if not self.run_needed():
			return True

		msg.progress(_("processing index %s") % msg.simplify(self.source))

		if self.tool == "makeindex":
			cmd = ["makeindex", "-q", "-o", self.target] + self.opts
			cmd.extend(["-t", self.transcript])
			if self.style:
				cmd.extend(["-s", self.style])
			cmd.append(self.source)
			path_var = "INDEXSTYLE"

		elif self.tool == "xindy":
			cmd = ["texindy", "--quiet"]
			for opt in self.opts:
				if opt == "-g":
					if self.lang != "":
						msg.warn(_("'language' overrides 'order german'"),
							pkg="index")
					else:
						self.lang = "german-din"
				elif opt == "-l":
					self.modules.append("letter-ordering")
					msg.warn(_("use 'module letter-ordering' instead of 'order letter'"),
						pkg="index")
				else:
					msg.error("unknown option to xindy: %s" % opt, pkg="index")
			for mod in self.modules:
				cmd.extend(["--module", mod])
			if self.lang:
				cmd.extend(["--language", self.lang])
			cmd.append(self.source)
			path_var = "XINDY_SEARCHPATH"

		if self.path != []:
			env = { path_var: ':'.join(self.path + [os.getenv(path_var, '')]) }
		else:
			env = {}
		if self.doc.env.execute(cmd, env):
			msg.error(_("could not make index %s") % self.target)
			return False

		self.doc.must_compile = 1
		return True
Example #13
0
	def run (self):
		if self.doc.vars['engine'] == 'Omega':
			cmd = ['odvips']
		else:
			cmd = ['dvips']
		msg.progress(_("running %s on %s") % (cmd[0], self.source))
		for opt in self.doc.vars['paper'].split():
			cmd.extend(['-t', opt])
		cmd.extend(self.options + ['-o', self.target, self.source])
		if self.env.execute(cmd, kpse=1):
			msg.error(_("%s failed on %s") % (cmd[0], self.source))
			return False
		return True
Example #14
0
    def run(self):
        """
		This method reads the source file (which is supposed to be a
		gzip-compressed PostScript file) until it finds a line that contains a
		bounding box indication. Then it creates the target file with this
		single line.
		"""
        msg.progress(_("extracting bounding box from %s") % self.source)
        with GzipFile(self.source) as source:
            for line in source:
                if re_bbox.match(line):
                    with open(self.target, "w") as target:
                        target.write(line)
                    return True
        msg.error(_("no bounding box was found in %s!") % self.source)
        return False
Example #15
0
	def run (self):
		"""
		This method reads the source file (which is supposed to be a
		gzip-compressed PostScript file) until it finds a line that contains a
		bounding box indication. Then it creates the target file with this
		single line.
		"""
		msg.progress(_("extracting bounding box from %s") % self.source)
		with GzipFile(self.source) as source:
			for line in source:
				if re_bbox.match(line):
					with open(self.target, "w") as target:
						target.write(line)
					return True
		msg.error(_("no bounding box was found in %s!") % self.source)
		return False
Example #16
0
	def run (self):
		"""
		This method actually runs BibTeX with the appropriate environment
		variables set.
		"""
		msg.progress(_("running BibTeX on %s") % msg.simplify(self.base))
		doc = {}
		if len(self.bib_path) != 1:
			doc["BIBINPUTS"] = string.join(self.bib_path +
				[os.getenv("BIBINPUTS", "")], os.pathsep)
		if len(self.bst_path) != 1:
			doc["BSTINPUTS"] = string.join(self.bst_path +
				[os.getenv("BSTINPUTS", "")], os.pathsep)
		if self.crossrefs is None:
			cmd = ["bibtex"]
		else:
			cmd = ["bibtex", "-min-crossrefs=" + self.crossrefs]
		if self.doc.env.execute(['bibtex', self.base], doc):
			msg.info(_("There were errors making the bibliography."))
			return False
		self.run_needed = 0
		self.doc.must_compile = 1
		return True
Example #17
0
    def run(self):
        """
		This method actually runs BibTeX with the appropriate environment
		variables set.
		"""
        msg.progress(_("running BibTeX on %s") % msg.simplify(self.base))
        doc = {}
        if len(self.bib_path) != 1:
            doc["BIBINPUTS"] = string.join(
                self.bib_path + [os.getenv("BIBINPUTS", "")], os.pathsep)
        if len(self.bst_path) != 1:
            doc["BSTINPUTS"] = string.join(
                self.bst_path + [os.getenv("BSTINPUTS", "")], os.pathsep)
        if self.crossrefs is None:
            cmd = ["bibtex"]
        else:
            cmd = ["bibtex", "-min-crossrefs=" + self.crossrefs]
        if self.doc.env.execute(['bibtex', self.base], doc):
            msg.info(_("There were errors making the bibliography."))
            return False
        self.run_needed = 0
        self.doc.must_compile = 1
        return True
Example #18
0
    def main(self, cmdline):
        """
		Run Rubber as a pipe for the specified command line. This dumps the
		standard input into a temporary file, compiles it, dumps the result on
		standard output, and then removes the files if requested. If an error
		happens while building the document, the process stops. The method
		returns the program's exit code.
		"""
        self.prologue = []
        self.epilogue = []
        self.clean = 1
        self.place = "."
        self.path = []
        self.parse_opts(cmdline)
        msg.log(_("This is Rubber version %s.") % version)

        # Put the standard input in a file

        initial_dir = os.getcwd()

        if self.place is not None and self.place != ".":
            self.path.insert(0, initial_dir)
            os.chdir(self.place)

        src = make_name() + ".tex"
        try:
            srcfile = open(src, "w")
        except IOError:
            msg.error(_("cannot create temporary files"))
            return 1

        msg.progress(_("saving the input in %s") % src)
        dump_file(sys.stdin, srcfile)
        srcfile.close()

        # Make the document

        env = Environment()
        env.vars["cwd"] = initial_dir

        if env.set_source(src):
            msg.error(_("cannot open the temporary %s") % src)
            return 1

        if self.include_only is not None:
            env.main.includeonly(self.include_only)

        env.make_source()

        for dir in self.path:
            env.main.do_path(dir)
        for cmd in self.prologue:
            cmd = parse_line(cmd, {})
            env.main.command(cmd[0], cmd[1:], {"file": "command line"})

        env.main.parse()

        for cmd in self.epilogue:
            cmd = parse_line(cmd, {})
            env.main.command(cmd[0], cmd[1:], {"file": "command line"})

        ret = env.final.make()

        if ret == ERROR:
            msg.info(_("There were errors."))
            number = self.max_errors
            for err in env.final.failed().get_errors():
                if number == 0:
                    msg.info(_("More errors."))
                    break
                msg.display(**err)
                number -= 1
            return 1

            # Dump the results on standard output

        output = open(env.final.products[0])
        dump_file(output, sys.stdout)

        # Clean the intermediate files

        if self.clean:
            env.final.clean()
            os.unlink(src)
        return 0
Example #19
0
    def main(self, cmdline):
        """
		Run Rubber as a pipe for the specified command line. This dumps the
		standard input into a temporary file, compiles it, dumps the result on
		standard output, and then removes the files if requested. If an error
		happens while building the document, the process stops. The method
		returns the program's exit code.
		"""
        self.prologue = []
        self.epilogue = []
        self.clean = 1
        self.place = "."
        self.path = []
        self.parse_opts(cmdline)
        msg.log(_("This is Rubber version %s.") % version)

        # Put the standard input in a file

        initial_dir = os.getcwd()

        if self.place is not None and self.place != ".":
            self.path.insert(0, initial_dir)
            os.chdir(self.place)

        src = make_name() + ".tex"
        try:
            srcfile = open(src, 'w')
        except IOError:
            msg.error(_("cannot create temporary files"))
            return 1

        msg.progress(_("saving the input in %s") % src)
        dump_file(sys.stdin, srcfile)
        srcfile.close()

        # Make the document

        env = Environment()
        env.vars["cwd"] = initial_dir

        if env.set_source(src):
            msg.error(_("cannot open the temporary %s") % src)
            return 1

        if self.include_only is not None:
            env.main.includeonly(self.include_only)

        env.make_source()

        for dir in self.path:
            env.main.do_path(dir)
        for cmd in self.prologue:
            cmd = parse_line(cmd, {})
            env.main.command(cmd[0], cmd[1:], {'file': 'command line'})

        env.main.parse()

        for cmd in self.epilogue:
            cmd = parse_line(cmd, {})
            env.main.command(cmd[0], cmd[1:], {'file': 'command line'})

        ret = env.final.make()

        if ret == ERROR:
            msg.info(_("There were errors."))
            number = self.max_errors
            for err in env.final.failed().get_errors():
                if number == 0:
                    msg.info(_("More errors."))
                    break
                msg.display(**err)
                number -= 1
            return 1

        # Dump the results on standard output

        output = open(env.final.products[0])
        dump_file(output, sys.stdout)

        # Clean the intermediate files

        if self.clean:
            env.final.clean()
            os.unlink(src)
        return 0