def _clean_x_file_factory(name):
    def clean_x_file(self):
        logger.debug("Checking file lengths")
        if self.cleaned_data["%s_file" % name].size > \
        settings.GCF_MAX_UPLOADED_PEM_FILE_SIZE:
            raise forms.ValidationError(
                "File exceeds maximum file size of %s bytes."
                % settings.GCF_MAX_UPLOADED_PEM_FILE_SIZE)
        return self.cleaned_data["%s_file" % name]
    return clean_x_file
Factory to create functions that check file size
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/expedient_geni/forms.py/_clean_x_file_factory