示例#1
0
def position(where=None):
	if where is None:
		ancestors = list(fsitem.current().ancestors())
	else:
		ancestors = list(where.ancestors())
	c = courses()
	c_a = [item.path for item in c.ancestors()]
	l = [item for item in ancestors if item.path not in c_a and item.path != c.path]
	if len(l) > 0:
		p = l[-1]
		yr = int(p.basename())
		yr = year(yr)
	if len(l) > 1:
		p = l[-2]
		full_semester = p.basename()
		semester,space,ear = full_semester.partition(" ")
		sem = yr.semester(semester)
	if len(l) > 2:
		p = l[-3]
		course = sem.course(p.basename())
		return course
	if len(l) > 1:
		return sem
	if len(l) > 0:
		return yr
示例#2
0
def corresponding(where=None):
	if where is None:
		where = fsitem.current()
	p = position()
	d = p.data()
	s = where - p.code()
	return d[s]
示例#3
0
import sys
from fsitem import current, Folder, File

# consider moving to /Library/Python/2.7/site-packages

data_paths = []

for d in current().ancestors():
	for item in d.folders():
		b = item.basename()
		if b == "Data":
			data_paths.append(item.path)
		elif b == "Code":
			foundactools = 0
			for child in item.items():
				if isinstance(child,Folder):
					if child.basename() == "actools":
						foundactools = 1
						if child.path not in sys.path:
							sys.path.append(child.path)
						break
			if not foundactools:
				if item.path not in sys.path:
					sys.path.append(item.path)

if __name__ == "__main__":
	print "Code:"
	print sys.path
	print "Data:"
	print data_paths