

def filingValidate(cntlr, options, filesource, entrypointFiles, sourceZipStream=None, responseZipStream=None, *args, **kwargs):
    modelManager = cntlr.modelManager
    if hasattr(modelManager, 'efmFiling'):
        efmFiling = modelManager.efmFiling
        reports = efmFiling.reports
        if any(((report.documentType and report.documentType.endswith(' SDR')) for report in reports)):
            _kSdrs = [r for r in reports if (r.documentType == 'K SDR')]
            if ((not _kSdrs) and (efmFiling.submissionType in ('SDR', 'SDR-A'))):
                efmFiling.error('EFM.6.03.08.sdrHasNoKreports', _('SDR filing has no K SDR reports'))
            elif (len(_kSdrs) > 1):
                efmFiling.error('EFM.6.03.08.sdrHasMultipleKreports', _('SDR filing has multiple K SDR reports for %(entities)s'), {
                    'entities': ', '.join((r.entityRegistrantName for r in _kSdrs)),
                }, (r.url for r in _kSdrs))
            _lSdrEntityReports = defaultdict(list)
            for r in reports:
                if (r.documentType == 'L SDR'):
                    _lSdrEntityReports[(r.entityCentralIndexKey if (r.entityCentralIndexKey != '0000000000') else r.entityRegistrantName)].append(r)
            for (lSdrEntity, lSdrEntityReports) in _lSdrEntityReports.items():
                if (len(lSdrEntityReports) > 1):
                    efmFiling.error('EFM.6.05.24.multipleLSdrReportsForEntity', _('Filing entity has multiple L SDR reports: %(entity)s'), {
                        'entity': lSdrEntity,
                    }, (r.url for r in lSdrEntityReports))
            for r in reports:
                hasSch = hasPre = hasCal = hasLbl = False
                for f in r.reportedFiles:
                    if f.endswith('.xsd'):
                        hasSch = True
                    elif f.endswith('_pre.xml'):
                        hasPre = True
                    elif f.endswith('_cal.xml'):
                        hasCal = True
                    elif f.endswith('_lab.xml'):
                        hasLbl = True
                missingFiles = ''
                if (not hasSch):
                    missingFiles += ', schema'
                if (not hasPre):
                    missingFiles += ', presentation linkbase'
                if (not hasLbl):
                    missingFiles += ', label linkbase'
                if missingFiles:
                    efmFiling.error('EFM.6.03.02.sdrMissingFiles', _('%(docType)s report missing files: %(missingFiles)s'), {
                        'docType': r.documentType,
                        'missingFiles': missingFiles[2:],
                    }, r.url)
                if (not r.hasUsGaapTaxonomy):
                    efmFiling.error('EFM.6.03.02.sdrMissingStandardSchema', _('%(documentType)s submission must use a US GAAP standard schema'), {
                        'documentType': r.documentType,
                    }, r.url)
                if (hasattr(r, 'exhibitType') and (r.exhibitType not in ('EX-99.K SDR', 'EX-99.L SDR', 'EX-99.K SDR.INS', 'EX-99.L SDR.INS'))):
                    efmFiling.error('EFM.6.03.02.sdrHasNonSdrExhibit', _('An SDR filling contains non-SDR exhibit type %(exhibitType)s document type %(documentType)s'), {
                        'documentType': r.documentType,
                        'exhibitType': r.exhibitType,
                    }, r.url)
        _exhibitTypeReports = defaultdict(list)
        for r in reports:
            if (hasattr(r, 'exhibitType') and r.exhibitType):
                _exhibitTypeReports[r.exhibitType.partition('.')[0]].append(r)
        if (len(_exhibitTypeReports) > 1):
            efmFiling.error('EFM.6.03.08', _('A filling contains multiple exhibit types %(exhibitTypes)s.'), {
                'exhibitTypes': ', '.join(_exhibitTypeReports.keys()),
            }, [r.url for r in reports])
        for (_exhibitType, _exhibitReports) in _exhibitTypeReports.items():
            if ((_exhibitType not in ('EX-99',)) and (len(_exhibitReports) > 1)):
                efmFiling.error('EFM.6.03.08.moreThanOneIns', _('A filing contains more than one instance for exhibit type %(exhibitType)s.'), {
                    'exhibitType': _exhibitType,
                }, [r.url for r in _exhibitReports])

dataset/ETHPy150Open Arelle/Arelle/arelle/plugin/validate/EFM/__init__.py filingValidate/original