Пример #1
0
    def createOutput(self, dest, text):  # TODO: move to helper.py?, use for other files too?
        mkdir(os.path.dirname(dest))

        try:
            outf = open(dest, "w")
            outf.write(text)
            outf.close()
        except IOError as e:  # TODO: check exceptions
            fail("Error creating " + dest + ": " + str(e))
Пример #2
0
    def copy(self, site, to=None):
        if not to:
            to = self._dest_dir

        out_file = os.path.join(to, self._src_path_rel)
        out_dir = os.path.dirname(out_file)
        mkdir(out_dir)

        site.delFromFileIndex(out_file)
        shutil.copyfile(
            os.path.join(self._src_path_root, self._src_path_rel),
            os.path.join(out_dir, os.path.basename(self._src_path_rel)),
        )