<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 MaKaC.webinterface.urlHandlers as urlHandlers
from MaKaC.common import xmlGen
from MaKaC.common.Configuration import Config
from MaKaC.common import indexes
from MaKaC.conference import ConferenceHolder
import sets
from pytz import timezone
from MaKaC.common.timezoneUtils import nowutc
import MaKaC.common.info as info
import struct, socket


# TOREMOVE
def ACLfiltered(iter, requestIP, aw=None):

    def _inIPList(iplist, ip):

        for rule in iplist:
            if '/' in rule:
                # it's a netmask (CIDR), check if ip belongs to it
                # ipv4-specific, non-endian-safe check!
                ipaddr = struct.unpack('L', socket.inet_aton(ip))[0]
                netaddr, bits = rule.split('/')
                netmask = struct.unpack('L', socket.inet_aton(netaddr))[0] & ((2L << int(bits) - 1) - 1)
                if ipaddr & netmask == netmask:
                    return True
            else:
                if ip in iplist:
                    return True
        return False

    acl = Config.getInstance().getExportACL().iteritems()
    blIds = list(categ for (categ, iplist) in acl if (not _inIPList(iplist, requestIP)))

    for conf in iter:
        owners = list(categ.getId() for categ in conf.getOwnerPath()) + ['0']
        for blId in blIds:
            if blId in owners:
                if aw and aw.getUser() and conf.canAccess(aw):
                    yield conf
                else:
                    break
        else:
            yield conf


class CategoryToRSS:

    def __init__(self, categ, req, date=None, tz=None):<commit_msg>[IMP] Standard size/alignment for struct<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 MaKaC.webinterface.urlHandlers as urlHandlers
from MaKaC.common import xmlGen
from MaKaC.common.Configuration import Config
from MaKaC.common import indexes
from MaKaC.conference import ConferenceHolder
import sets
from pytz import timezone
from MaKaC.common.timezoneUtils import nowutc
import MaKaC.common.info as info
import struct, socket


# TOREMOVE
def ACLfiltered(iter, requestIP, aw=None):

    def _inIPList(iplist, ip):

        for rule in iplist:
            if '/' in rule:
                # it's a netmask (CIDR), check if ip belongs to it
                # ipv4-specific, non-endian-safe check!
                ipaddr = struct.unpack('=L', socket.inet_aton(ip))[0]
                netaddr, bits = rule.split('/')
                netmask = struct.unpack('=L', socket.inet_aton(netaddr))[0] & ((2L << int(bits) - 1) - 1)
                if ipaddr & netmask == netmask:
                    return True
            else:
                if ip in iplist:
                    return True
        return False

    acl = Config.getInstance().getExportACL().iteritems()
    blIds = list(categ for (categ, iplist) in acl if (not _inIPList(iplist, requestIP)))

    for conf in iter:
        owners = list(categ.getId() for categ in conf.getOwnerPath()) + ['0']
        for blId in blIds:
            if blId in owners:
                if aw and aw.getUser() and conf.canAccess(aw):
                    yield conf
                else:
                    break
        else:
            yield conf


class CategoryToRSS:

    def __init__(self, categ, req, date=None, tz=None):
{'fraction_non_alphanumeric': 0.09190505173463177, 'fraction_numerical': 0.01907080543720836, 'mean_word_length': 2.5014204545454546, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5817189', 'n_tokens_mistral': 1530, 'n_tokens_neox': 1379, 'n_words': 559}