Example #1
0
def parse_directory (dir, depth):
	if depth == 0:
		return
	for entry in os.listdir(dir):
		type = ''
		fullpath = os.path.join (dir, entry)
		if os.path.isdir (fullpath):
			parse_directory (fullpath, depth-1)

		result = Directory.select (Directory.q.path == fullpath)
		if result.count() == 0:
			d = Directory(path=fullpath, date_added=datetime.datetime.now())
Example #2
0
def build_feed ():
	dirs = Directory.select (orderBy="-date_added")[0:10]
	items = []
	for dir in dirs:
		items.append(PyRSS2Gen.RSSItem(
				title = str(dir.path).split('/')[-1],
				link = 'http://whatever/',
				description = 'This file is now available: %s' % dir.path,
				pubDate = dir.date_added
		));
	rss = PyRSS2Gen.RSS2(
			title = 'My awesome dir feed',
			link = 'http://whatever/',
			description = 'Files available',
			lastBuildDate = datetime.datetime.now(),
			items = items,
	)
	print rss.to_xml()