How to use the sma.files.get_content_path function in sma

To help you get started, we’ve selected a few sma examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sdockray / sma / sma / sponge.py View on Github external
def content(url, force=False):
	if force or not os.path.exists(files.get_content_path(url)):
		try:
			response = requests.get(url, timeout=10)
			c = "this is an archive. [go to %s](%s)\n\n" % (url,url)
			c = "%s---\n\n" % c
			if response.ok:
				c = "%s### %s\n" % (c, Document(response.content).short_title())
				c = "%s%s" % (c, html2text.html2text(Document(response.content).summary()))
			else:
				c = "%sFor one reason or another, this document couldn't be archived." % c
			files.save_content(c, url)
		except:
			print "Failed to make markdown from: ", url