<commit_before># This file is part of Indico.
# Copyright (C) 2002 - 2016 European Organization for Nuclear Research (CERN).
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Indico is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Indico; if not, see <http://www.gnu.org/licenses/>.

"""This file contain several classes which contain the logic needed to allow
    generating HTML links for some pieces of information about the conferences.
"""
#import MaKaC.conference as conference
from MaKaC.roomMapping import RoomMapperHolder


class RoomLinker:
    """This class is a "facade" for all the room linking system. It constains
        the necessary logic to know which linker object he must appply in order
        to obtain the correct linking for the requests
    """

    def getHTMLLink( self, room, location=None ):
        if room == None:
            return ""
        roomLink = room.getName()
        url = self.getURL( room, location )
        if url != "":
            roomLink = """<a href="%s">%s</a>"""%(url, roomLink)
        return roomLink

    def getURL( self, room, location=None ):
        if location is not None and room is not None:
            res = RoomMapperHolder().match({"name":location.getName()},exact=True)
            if res != []:
                return res[0].getMapURL(room.getName())
        return ""

    def getURLByName( self, room, location=None ):
        if location is not None and room is not None:
            res = RoomMapperHolder().match({"name":location},exact=True)
            if res != []:
                return res[0].getMapURL(room)
        return ""<commit_msg>Change room linking code, pass names as parameters<commit_after># This file is part of Indico.
# Copyright (C) 2002 - 2016 European Organization for Nuclear Research (CERN).
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Indico is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Indico; if not, see <http://www.gnu.org/licenses/>.

"""This file contain several classes which contain the logic needed to allow
    generating HTML links for some pieces of information about the conferences.
"""
#import MaKaC.conference as conference
from MaKaC.roomMapping import RoomMapperHolder


class RoomLinker:
    """This class is a "facade" for all the room linking system. It constains
        the necessary logic to know which linker object he must appply in order
        to obtain the correct linking for the requests
    """

    def getHTMLLink(self, room, location=None):
        if room is None:
            return ""
        url = self.getURL(room, location)
        if url != "":
            roomLink = '<a href="{}">{}</a>'.format(url, room)
        return roomLink

    def getURL(self, room, location=None):
        if location is not None and room is not None:
            res = RoomMapperHolder().match({"name": location}, exact=True)
            if res:
                return res[0].getMapURL(room)
        return ""

    def getURLByName(self, room, location=None):
        if location is not None and room is not None:
            res = RoomMapperHolder().match({"name": location}, exact=True)
            if res != []:
                return res[0].getMapURL(room)
        return ""
{'fraction_non_alphanumeric': 0.08492620372610694, 'fraction_numerical': 0.005323009920154851, 'mean_word_length': 2.925925925925926, 'pattern_counts': {'":': 6, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7041601', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1051, 'n_words': 500}