示例#1
0
    def set_source(self, name, jobname=None):
        """
        Create a main dependency node from the given file name. If this name
        has an extension that is known of a preprocessor, this preprocessor is
        used, otherwise the name is that of a LaTeX source.
        """
        path = self.find_file(name, ".tex")
        if not path:
            msg.error(_("cannot find %s") % name)
            return 1

        base, ext = os.path.splitext(path)

        if ext in literate_preprocessors.keys():
            src = base + ".tex"
            self.src_node = literate_preprocessors[ext](self.depends, src,
                                                        path)
        else:
            src = path
            self.src_node = None

        from rubber.converters.latex import LaTeXDep
        self.main = LaTeXDep(self)
        if os.path.exists(src):
            if self.main.set_source(src, jobname):
                return 1
        self.final = self.main
        return 0
示例#2
0
    def prepare_source(self, filename):
        """
		Prepare the dependency node for the main LaTeX run.
		Returns the filename of the main LaTeX source file, which might
		change for various reasons (adding a .tex suffix; preprocessors;
		pipe dumping).
		When this is done, the file must exist on disk, otherwise this
		function must exit(1) or exit(2).
		"""
        path = rubber.util.find_resource(filename, suffix=".tex")

        if not path:
            msg.error(_("Main document not found: '%s'") % filename)
            rubber.util.abort_generic_error()

        base, ext = os.path.splitext(path)

        from rubber.converters.literate import literate_preprocessors as lpp
        if ext in lpp.keys():
            src = base + ".tex"
            # FIXME kill src_node
            src_node = lpp[ext](self.env.depends, src, path)
            if self.rubber_mode == "build":
                if not self.unsafe:
                    msg.error(
                        _("Running external commands requires --unsafe."))
                    rubber.util.abort_rubber_syntax_error()
                # Produce the source from its dependency rules, if needed.
                if src_node.make() == ERROR:
                    msg.error (_("Producing the main LaTeX file failed: '%s'") \
                     % src)
                    rubber.util.abort_generic_error()
        else:
            src = path

        from rubber.converters.latex import LaTeXDep
        self.env.final = self.env.main = LaTeXDep(self.env, src, self.jobname)

        return src
示例#3
0
	def set_source (self, name, jobname=None):
		"""
		Create a main dependency node from the given file name. If this name
		has an extension that is known of a preprocessor, this preprocessor is
		used, otherwise the name is that of a LaTeX source.
		"""
		src = None
		i = name.rfind(".")
		if i >= 0:
			ext = name[i+1:]
			if ext in ["w", "lhs"]:
				path = self.find_file(name)
				if not path:
					msg.error(_("cannot find %s") % name)
					return 1
				src = path[:-len(ext)] + "tex"
				if ext == "w":
					from rubber.converters.cweb import CWebDep
					self.src_node = CWebDep(self, src, path)
				elif ext == "lhs":
					from rubber.converters.lhs2TeX import LHSDep
					self.src_node = LHSDep(self, src, path)

		if src is None:
			path = self.find_file(name, ".tex")
			if not path:
				msg.error(_("cannot find %s") % name)
				return 1
			src = path
			self.src_node = None

		from rubber.converters.latex import LaTeXDep
		self.main = LaTeXDep(self)
		if os.path.exists(src):
			if self.main.set_source(src, jobname):
				return 1
		self.final = self.main
		return 0