How to use the sma.config.DIR_BASE 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 / files.py View on Github external
def save_obj(obj, subdir, filename):
	if not os.path.exists(os.path.join(DIR_BASE, subdir)):
		os.makedirs(os.path.join(DIR_BASE, subdir))
	path = os.path.join(DIR_BASE, subdir, filename)
	with open(path, 'wb') as f:
		pickle.dump(obj, f, protocol=pickle.HIGHEST_PROTOCOL)
	print "Saved filename to",path
github sdockray / sma / sma / archiver.py View on Github external
def markdownify(self):
		# markdownify links in text
		def mdl(text):
			urls = utils.extract_urls(text)
			for u in urls:
				if u in self.links:
					text = text.replace(u, self.links[u].markdownify(summary=True))
			return text
		# make path for posts
		path = os.path.join(DIR_BASE, self.id, 'posts')
		if not os.path.exists(path):
			os.makedirs(path)
		# begin generating output
		output = "%s\n%s\n\n%s\n" % (self.name, "="*len(self.name), mdl(self.description))
		output = "%s\n\n" % output
		output = "%sReferences\n----------\n" % output
		# show all links
		c = Clusterer()
		clinks = c.cluster_links(self.links)
		for i in clinks:
			output = "%s### Group %s\n" % (output, i)
			for l in clinks[i]:
				output = "%s\n%s" % (output, l.markdownify(summary=True, prefer_snapshot=True))
		#for k in self.links:
		#	output = "%s\n%s" % (output, self.links[k].markdownify(summary=True, prefer_snapshot=True))
		output = "%s\n\n" % output
github sdockray / sma / sma / files.py View on Github external
def get_image_path(url):
	imgd = os.path.join(DIR_BASE, DIR_IMAGES)
	if not os.path.exists(imgd):
		os.makedirs(imgd)
	parsed = urlparse(url)
	filename, file_ext = os.path.splitext(os.path.basename(parsed.path))
	return os.path.join(imgd, "%s%s" %(hashlib.md5(url).hexdigest(), file_ext))