Anyway, no need to go to these lengths now (there are shorter but less readable tricks involving lambdas as well :), it's looking good, so let's get it landed and email Fathi/Alex when it's up on the server.
PS. You don't have to check for os.path.islink() anymore: the normalization/realpath code resolves all the links.
Thanks, tests look much neater now. Thanks for the code changes as well, r=me.
As for your comment about getcwd stuff, there was a simple way around it:
class LinaroIncludeRe placer( object) :
base_path = None
def read_file_ with_include_ data(self, matchobj):
# Assume self.base_path is the allowed path, instead of getcwd().
...
def _process_ include_ tags(contents, base_path): placer( ) base_path = base_path
replacer = LinaroIncludeRe
replacer.
contents = LINARO_ INCLUDE_ FILE_RE. sub(replacer. read_file_ with_include_ data, contents)
...
Anyway, no need to go to these lengths now (there are shorter but less readable tricks involving lambdas as well :), it's looking good, so let's get it landed and email Fathi/Alex when it's up on the server.
PS. You don't have to check for os.path.islink() anymore: the normalization/ realpath code resolves all the links.