@stream_session
def get_did_from_pfns(pfns, rse_id=None, vo='def', session=None):
    "\n    Get the DIDs associated to a PFN on one given RSE\n\n    :param pfns: The list of PFNs.\n    :param rse_id: The RSE id.\n    :param vo: The VO to get DIDs from.\n    :param session: The database session in use.\n    :returns: A dictionary {pfn: {'scope': scope, 'name': name}}\n    "
    dict_rse = {}
    if (not rse_id):
        (scheme, dict_rse, unknown_replicas) = get_pfn_to_rse(pfns, vo=vo, session=session)
        if unknown_replicas:
            raise Exception
    else:
        scheme = 'srm'
        dict_rse[rse_id] = pfns
    for rse_id in dict_rse:
        pfns = dict_rse[rse_id]
        rse_info = rsemgr.get_rse_info(rse_id=rse_id, session=session)
        pfndict = {}
        proto = rsemgr.create_protocol(rse_info, 'read', scheme=scheme)
        if rse_info['deterministic']:
            parsed_pfn = proto.parse_pfns(pfns=pfns)
            for pfn in parsed_pfn:
                path = parsed_pfn[pfn]['path']
                if (path.startswith('/user') or path.startswith('/group')):
                    scope = ('%s.%s' % (path.split('/')[1], path.split('/')[2]))
                    name = parsed_pfn[pfn]['name']
                elif path.startswith('/'):
                    scope = path.split('/')[1]
                    name = parsed_pfn[pfn]['name']
                else:
                    scope = path.split('/')[0]
                    name = parsed_pfn[pfn]['name']
                scope = InternalScope(scope, vo)
                (yield {pfn: {'scope': scope, 'name': name}})
        else:
            condition = []
            parsed_pfn = proto.parse_pfns(pfns=pfns)
            for pfn in parsed_pfn:
                path = ('%s%s' % (parsed_pfn[pfn]['path'], parsed_pfn[pfn]['name']))
                pfndict[path] = pfn
                condition.append(and_((models.RSEFileAssociation.path == path), (models.RSEFileAssociation.rse_id == rse_id)))
            for (scope, name, pfn) in session.query(models.RSEFileAssociation.scope, models.RSEFileAssociation.name, models.RSEFileAssociation.path).filter(or_(*condition)):
                (yield {pfndict[pfn]: {'scope': scope, 'name': name}})
Get the DIDs associated to a PFN on one given RSE

:param pfns: The list of PFNs.
:param rse_id: The RSE id.
:param vo: The VO to get DIDs from.
:param session: The database session in use.
:returns: A dictionary {pfn: {'scope': scope, 'name': name}}
@stream_session
def get_did_from_pfns(pfns, rse_id=None, vo='def', session=None):
    "\n    Get the DIDs associated to a PFN on one given RSE\n\n    :param pfns: The list of PFNs.\n    :param rse_id: The RSE id.\n    :param vo: The VO to get DIDs from.\n    :param session: The database session in use.\n    :returns: A dictionary {pfn: {'scope': scope, 'name': name}}\n    "
    dict_rse = {}
    if (not rse_id):
        (scheme, dict_rse, unknown_replicas) = get_pfn_to_rse(pfns, vo=vo, session=session)
        if unknown_replicas:
            raise Exception
    else:
        scheme = 'srm'
        dict_rse[rse_id] = pfns
    for rse_id in dict_rse:
        pfns = dict_rse[rse_id]
        rse_info = rsemgr.get_rse_info(rse_id=rse_id, session=session)
        pfndict = {}
        proto = rsemgr.create_protocol(rse_info, 'read', scheme=scheme)
        if rse_info['deterministic']:
            parsed_pfn = proto.parse_pfns(pfns=pfns)
            for pfn in parsed_pfn:
                path = parsed_pfn[pfn]['path']
                if (path.startswith('/user') or path.startswith('/group')):
                    scope = ('%s.%s' % (path.split('/')[1], path.split('/')[2]))
                    name = parsed_pfn[pfn]['name']
                elif path.startswith('/'):
                    scope = path.split('/')[1]
                    name = parsed_pfn[pfn]['name']
                else:
                    scope = path.split('/')[0]
                    name = parsed_pfn[pfn]['name']
                scope = InternalScope(scope, vo)
                (yield {pfn: {'scope': scope, 'name': name}})
        else:
            condition = []
            parsed_pfn = proto.parse_pfns(pfns=pfns)
            for pfn in parsed_pfn:
                path = ('%s%s' % (parsed_pfn[pfn]['path'], parsed_pfn[pfn]['name']))
                pfndict[path] = pfn
                condition.append(and_((models.RSEFileAssociation.path == path), (models.RSEFileAssociation.rse_id == rse_id)))
            for (scope, name, pfn) in session.query(models.RSEFileAssociation.scope, models.RSEFileAssociation.name, models.RSEFileAssociation.path).filter(or_(*condition)):
                (yield {pfndict[pfn]: {'scope': scope, 'name': name}})