Beispiel #1
0
    def dump(self, filepath):
        retVal = {}
        filename = os.path.join(filepath, self.title)
        filename += ".html"

        if os.path.isfile(filename):
            retVal = {"status": "True", "msg": "already downloaded"}
            return retVal
        contents = prepare_html(self.title, self.html)
        retVal = to_file(filename, "wb", contents)
        return retVal
Beispiel #2
0
    def _write_external_links(self, filepath):
        retVal = {}
        savedirs, name = os.path.split(filepath)
        filename = u"external-assets-links.txt"
        filename = os.path.join(savedirs, filename)
        file_data = []
        if os.path.isfile(filename):
            file_data = [
                i.strip().lower()
                for i in open(filename, encoding="utf-8", errors="ignore") if i
            ]

        content = u"\n{}\n{}\n".format(name, self.url)
        if name.lower() not in file_data:
            retVal = to_file(filename, "a", content)
        return retVal