<commit_before># -*- coding: utf-8 -*-
##
##
## This file is part of CDS Indico.
## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.
##
## CDS 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 2 of the
## License, or (at your option) any later version.
##
## CDS 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 CDS Indico; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

import types

import MaKaC.conference as conference
import MaKaC.errors as errors
import MaKaC.domain as domain
import MaKaC.roomMapping as roomMapping
import MaKaC.webinterface.materialFactories as materialFactories
from MaKaC.i18n import _

class CategoryWebLocator:

    def __init__( self, params, mustExist=1 ):
        self._categList = []
        categIds = params.get("categId", [])
        if categIds == [] or params["categId"] == "":
            if mustExist:
                raise errors.MaKaCError( _("category ids not set"))
        if type(categIds) is types.StringType:
            categIds = [ categIds ]
        ch = conference.CategoryManager()
        for id in categIds:
            try:
                self._categList.append(ch.getById(id))
            except KeyError:
                continue


    def getObjectList( self ):
        return self._categList

    def getObject( self ):
        if len(self.getObjectList()) == 0:
            return None
        if len(self.getObjectList()) == 1:
            return self.getObjectList()[0]
        return self.getObjectList()


class DomainWebLocator:

    def __init__( self, params ):
        domId = params.get("domainId", "")
        if domId == "":
            raise errors.MaKaCError( _("domain id not set"))
        dh = domain.DomainHolder()
        self._dom = dh.getById( domId )

    def getObject( self ):
        return self._dom

class RoomMapperWebLocator:

    def __init__( self, params ):
        rmId = params.get("roomMapperId", "")
        if rmId == "":
            raise errors.MaKaCError( _("room mapper id not set"))
        rmh = roomMapping.RoomMapperHolder()
        self._rm = rmh.getById( rmId )

    def getObject( self ):
        return self._rm

class WebLocator:

    def __init__(self):
        self.__categId = None
        self.__confId = None
        self.__sessionId = None
        self.__contribId = None
        self.__subContribId = None
        self.__reviewId = None
        self.__materialId = None
        self.__resId = None
        self.__alarmId = None
        self.__trackId = None
        self.__abstractId = None
        self.__menuLinkId = None
        self.__contribTypeId = None
        self.__slotId = None
        self.__notifTplId = None
        self.__resvID = None
        self.__location = None
        self.__roomID = None
        self.__registrantId = None

    def setCategory( self, params, mustExist=1 ):
        if not ("categId" in params.keys()) or params["categId"].strip()=="":
            if mustExist:
                raise errors.MaKaCError( _("category id not set"))
        self.__categId = params["categId"]

    def setConference( self, params ):
        if not ("confId" in params.keys()) and "confid" in params.keys():
            params["confId"] = params["confid"]
        if not ("confId" in params.keys()) and "conference" in params.keys():
            params["confId"] = params["conference"]
        if not ("confId" in params.keys()) or \
           params["confId"] == None or \
               params["confId"].strip()=="":
            raise errors.MaKaCError( _("conference id not set"))
        self.__confId = params["confId"]

    def getConference( self ):
        return conference.ConferenceHolder().getById( self.__confId )

    def setNotificationTemplate( self, params, mustExist=1 ):
        self.setConference(params)
        if not ("notifTplId" in params.keys()) or params["notifTplId"].strip == "":
            if mustExist:
                raise errors.MaKaCError( _("notificationTemplate id not set"))
        else:
            self.__notifTplId = params["notifTplId"]

    def setMenuLink( self, params, mustExist=1 ):
        self.setConference(params)
        if not ("linkId" in params.keys()) or params["linkId"].strip=="":
            if mustExist:
                raise errors.MaKaCError( _("link id not set"))
        else:
            self.__menuLinkId = params["linkId"]<commit_msg>[FIX] Conference id multiple times<commit_after># -*- coding: utf-8 -*-
##
##
## This file is part of CDS Indico.
## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.
##
## CDS 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 2 of the
## License, or (at your option) any later version.
##
## CDS 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 CDS Indico; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

import types

import MaKaC.conference as conference
import MaKaC.errors as errors
import MaKaC.domain as domain
import MaKaC.roomMapping as roomMapping
import MaKaC.webinterface.materialFactories as materialFactories
from MaKaC.i18n import _

class CategoryWebLocator:

    def __init__( self, params, mustExist=1 ):
        self._categList = []
        categIds = params.get("categId", [])
        if categIds == [] or params["categId"] == "":
            if mustExist:
                raise errors.MaKaCError( _("category ids not set"))
        if type(categIds) is types.StringType:
            categIds = [ categIds ]
        ch = conference.CategoryManager()
        for id in categIds:
            try:
                self._categList.append(ch.getById(id))
            except KeyError:
                continue


    def getObjectList( self ):
        return self._categList

    def getObject( self ):
        if len(self.getObjectList()) == 0:
            return None
        if len(self.getObjectList()) == 1:
            return self.getObjectList()[0]
        return self.getObjectList()


class DomainWebLocator:

    def __init__( self, params ):
        domId = params.get("domainId", "")
        if domId == "":
            raise errors.MaKaCError( _("domain id not set"))
        dh = domain.DomainHolder()
        self._dom = dh.getById( domId )

    def getObject( self ):
        return self._dom

class RoomMapperWebLocator:

    def __init__( self, params ):
        rmId = params.get("roomMapperId", "")
        if rmId == "":
            raise errors.MaKaCError( _("room mapper id not set"))
        rmh = roomMapping.RoomMapperHolder()
        self._rm = rmh.getById( rmId )

    def getObject( self ):
        return self._rm

class WebLocator:

    def __init__(self):
        self.__categId = None
        self.__confId = None
        self.__sessionId = None
        self.__contribId = None
        self.__subContribId = None
        self.__reviewId = None
        self.__materialId = None
        self.__resId = None
        self.__alarmId = None
        self.__trackId = None
        self.__abstractId = None
        self.__menuLinkId = None
        self.__contribTypeId = None
        self.__slotId = None
        self.__notifTplId = None
        self.__resvID = None
        self.__location = None
        self.__roomID = None
        self.__registrantId = None

    def setCategory( self, params, mustExist=1 ):
        if not ("categId" in params.keys()) or params["categId"].strip()=="":
            if mustExist:
                raise errors.MaKaCError( _("category id not set"))
        self.__categId = params["categId"]

    def setConference( self, params ):
        if not ("confId" in params.keys()) and "confid" in params.keys():
            params["confId"] = params["confid"]
        if not ("confId" in params.keys()) and "conference" in params.keys():
            params["confId"] = params["conference"]
        if isinstance(params.get("confId", ""), list):
            params["confId"] = params["confId"][0]
        if not ("confId" in params.keys()) or \
           params["confId"] == None or \
               params["confId"].strip()=="":
            raise errors.MaKaCError( _("conference id not set"))
        self.__confId = params["confId"]

    def getConference( self ):
        return conference.ConferenceHolder().getById( self.__confId )

    def setNotificationTemplate( self, params, mustExist=1 ):
        self.setConference(params)
        if not ("notifTplId" in params.keys()) or params["notifTplId"].strip == "":
            if mustExist:
                raise errors.MaKaCError( _("notificationTemplate id not set"))
        else:
            self.__notifTplId = params["notifTplId"]

    def setMenuLink( self, params, mustExist=1 ):
        self.setConference(params)
        if not ("linkId" in params.keys()) or params["linkId"].strip=="":
            if mustExist:
                raise errors.MaKaCError( _("link id not set"))
        else:
            self.__menuLinkId = params["linkId"]
{'fraction_non_alphanumeric': 0.10865335381464414, 'fraction_numerical': 0.010138248847926268, 'mean_word_length': 2.403973509933775, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6799219', 'n_tokens_mistral': 2903, 'n_tokens_neox': 2753, 'n_words': 870}