<commit_before># This file is part of Indico.
# Copyright (C) 2002 - 2015 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/>.

from MaKaC.webinterface.pages.main import WPMainBase
import MaKaC.webinterface.wcomponents as wcomponents
from MaKaC.i18n import _
from pytz import timezone
from MaKaC.common import timezoneUtils

from indico.modules import ModuleHolder

class WPNews(WPMainBase):

    def _getBody(self, params):
        wc = WNews(tz = timezone(timezoneUtils.DisplayTZ(self._getAW()).getDisplayTZ()))
        return wc.getHTML()

    def getCSSFiles(self):
        return WPMainBase.getCSSFiles(self) + self._asset_env['news_sass'].urls()

    def _getTitle(self):
        return WPMainBase._getTitle(self) + " - " + _("News")


class WNews(wcomponents.WTemplated):

    def __init__(self, tz):
        wcomponents.WTemplated.__init__(self)
        self._tz = tz

    def getVars( self ):
        vars = wcomponents.WTemplated.getVars( self )

        newsModule = ModuleHolder().getById("news")
        vars["news"] = newsModule.getNewsItemsList()
        vars["tz"] = self._tz

        return vars<commit_msg>PEP8 and style fixes<commit_after># This file is part of Indico.
# Copyright (C) 2002 - 2015 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/>.

from pytz import timezone

from indico.modules import ModuleHolder
from indico.util.i18n import _

from MaKaC.common import timezoneUtils
from MaKaC.webinterface.pages.main import WPMainBase
from MaKaC.webinterface.wcomponents import WTemplated


class WPNews(WPMainBase):

    def _getBody(self, params):
        wc = WNews(tz=timezone(timezoneUtils.DisplayTZ(self._getAW()).getDisplayTZ()))
        return wc.getHTML()

    def getCSSFiles(self):
        return WPMainBase.getCSSFiles(self) + self._asset_env['news_sass'].urls()

    def _getTitle(self):
        return WPMainBase._getTitle(self) + " - " + _("News")


class WNews(WTemplated):

    def __init__(self, tz):
        WTemplated.__init__(self)
        self._tz = tz

    def getVars(self):
        vars = WTemplated.getVars(self)

        newsModule = ModuleHolder().getById("news")
        vars["news"] = newsModule.getNewsItemsList()
        vars["tz"] = self._tz

        return vars
{'fraction_non_alphanumeric': 0.08922363847045191, 'fraction_numerical': 0.006662804171494786, 'mean_word_length': 3.691576086956522, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7645547', 'n_tokens_mistral': 1050, 'n_tokens_neox': 998, 'n_words': 355}