Esempio n. 1
0
 def pdflatex(self, output, depends, binary="pdflatex", clean=True):
     "Convert latex to pdf using pdflatex"
     depends = u.str2list(depends)
     cmd = '{2} -jobname "{0}" "{1}"'.format(output, '" "'.join(depends), binary)
     if not self.quiet: print cmd
     os.system(cmd)
     if clean:
         os.system("rm -f "+" ".join(map(lambda x: self.replace_ext(output, x), [".aux", ".log", ".out"])))
Esempio n. 2
0
    def ttb(func, output, depends, *args, **kwargs):
        """func is a conversion function to run on the args and kwargs to produce the output.
    
        depends is a string or list of filespecs

        **kwargs are whatever the func calls for.

        output is a filespec.  We run u.time_to_build on the output
        and depends and if it comes back saying the output file is out
        of date, we rebuild it from the depends, args and kwargs by
        calling the func.

        """
        if u.time_to_build(u.str2list(depends), output):
            return func(output, depends, *args, **kwargs)
Esempio n. 3
0
def time_to_build(files, target):
    """files is a list of files.  It could also be a string with a
    filename if the list length is 1

    Return True if any of the files are newer than the target or if the
    target is missing.  Raise error if any of the files are missing.

    """

    files = u.str2list(files)

    # Make sure files exist
    for f in files:
        if not os.path.exists(f):
            raise OSError(2, "No such file or directory", f)

        # If the target doesn't exist, we should build it.
        if not os.path.exists(target):
            return True

        # If the newest doc isn't our target, we should rebuild
        return (reduce( (lambda o,n: o if os.stat(o)[8] > os.stat(n)[8] else n),
                        files + [target]) 
                != target)
Esempio n. 4
0
 def join(self, fname, files):
     files = u.str2list(files)
     cmd = 'gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="{0}" {1}'.format(fname, " ".join(files))
     if not self.quiet: print cmd
     os.system(cmd)