def validate_within_subproject(self, subdir, fname):
    norm = os.path.normpath(os.path.join(subdir, fname))
    if os.path.isabs(norm):
        if (not norm.startswith(self.environment.source_dir)):
            return
        norm = os.path.relpath(norm, self.environment.source_dir)
        assert (not os.path.isabs(norm))
    (num_sps, sproj_name) = self.evaluate_subproject_info(norm, self.subproject_dir)
    plain_filename = os.path.basename(norm)
    if (num_sps == 0):
        if (not self.is_subproject()):
            return
        raise InterpreterException(('Sandbox violation: Tried to grab file %s from a different subproject.' % plain_filename))
    if (num_sps > 1):
        raise InterpreterException(('Sandbox violation: Tried to grab file %s from a nested subproject.' % plain_filename))
    if (sproj_name != self.subproject_directory_name):
        raise InterpreterException(('Sandbox violation: Tried to grab file %s from a different subproject.' % plain_filename))
def validate_within_subproject(self, subdir, fname):
    norm = os.path.normpath(os.path.join(subdir, fname))
    if os.path.isabs(norm):
        if (not norm.startswith(self.environment.source_dir)):
            return
        norm = os.path.relpath(norm, self.environment.source_dir)
        assert (not os.path.isabs(norm))
    (num_sps, sproj_name) = self.evaluate_subproject_info(norm, self.subproject_dir)
    plain_filename = os.path.basename(norm)
    if (num_sps == 0):
        if (not self.is_subproject()):
            return
        raise InterpreterException(('Sandbox violation: Tried to grab file %s from a different subproject.' % plain_filename))
    if (num_sps > 1):
        raise InterpreterException(('Sandbox violation: Tried to grab file %s from a nested subproject.' % plain_filename))
    if (sproj_name != self.subproject_directory_name):
        raise InterpreterException(('Sandbox violation: Tried to grab file %s from a different subproject.' % plain_filename))