view 2.00/files.py @ 18:a33653cdad57

Still $Rev$ substitution in 2.00
author Oleg Oshmyan <chortos@inbox.lv>
date Mon, 07 Jun 2010 23:42:16 +0000
parents f2279b7602d3
children ec6f1a132109
line wrap: on
line source

#!/usr/bin/python
# Copyright (c) 2010 Chortos-2 <chortos@inbox.lv>

import os
tasknames = (os.path.curdir,)

class Files(object):
	__slots__ = 'name', 'paths'
	stdpaths = '%/', '%/^:%/', '%/^:', 'tests/%/', 'tests/', '^:%/', '^:', ''
	
	def __init__(self, name, paths = stdpaths):
		self.name = name
		self.paths = paths
	
	def __iter__(self):
		for path in paths:
			p = getpath(path, self.name)
			if isfile(p):
				yield p

def isfile(path):
	return os.path.isfile(path)

def getpath(path, name):
	return path + name