Exemplo n.º 1
0
def abspath(fname, check=True):
	"""Get the absolute path for fname relative to the base directory of the current context.
	   Also checks to make sure the file exists. """
	p = context().path(fname)
	if check and not os.path.exists(p):
		raise OSError("File not found: {0}".format(p))
	return p
Exemplo n.º 2
0
	def __init__(self, suggestedpath=None):
		"""Derived classes can suggest a path (relative to the current context base)
		that is to be used if not overridden by Add()"""

		# strip the basepath from absolute paths
		if suggestedpath:
			basepath = context().basepath
			if suggestedpath[0] == '/' and suggestedpath.startswith(basepath):
					suggestedpath = suggestedpath[len(basepath):].lstrip('/')

		self.path = suggestedpath