11
 (    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
 <head>
  <title>Index of /ALFA_DATA/alfasymlink/root/usr/lib64/python2.7/Demo/zlib</title>
 </head>
 <body>
<h1>Index of /ALFA_DATA/alfasymlink/root/usr/lib64/python2.7/Demo/zlib</h1>
  <table>
   <tr><th valign="top">&nbsp;</th><th><a href="?C=N;O=A">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr>
   <tr><th colspan="5"><hr></th></tr>
<tr><td valign="top">&nbsp;</td><td><a href="/ALFA_DATA/alfasymlink/root/usr/lib64/python2.7/Demo/">Parent Directory</a>       </td><td>&nbsp;</td><td align="right">  - </td><td>&nbsp;</td></tr>
<tr><td valign="top">&nbsp;</td><td><a href="zlibdemo.pyo">zlibdemo.pyo</a>           </td><td align="right">2023-11-14 19:44  </td><td align="right">1.2K</td><td>&nbsp;</td></tr>
<tr><td valign="top">&nbsp;</td><td><a href="zlibdemo.pyc">zlibdemo.pyc</a>           </td><td align="right">2023-11-14 19:44  </td><td align="right">1.2K</td><td>&nbsp;</td></tr>
<tr><td valign="top">&nbsp;</td><td><a href="zlibdemo.py">zlibdemo.py</a>            </td><td align="right">2023-11-14 19:43  </td><td align="right">1.4K</td><td>&nbsp;</td></tr>
<tr><td valign="top">&nbsp;</td><td><a href="minigzip.pyo">minigzip.pyo</a>           </td><td align="right">2023-11-14 19:44  </td><td align="right">3.6K</td><td>&nbsp;</td></tr>
<tr><td valign="top">&nbsp;</td><td><a href="minigzip.pyc">minigzip.pyc</a>           </td><td align="right">2023-11-14 19:44  </td><td align="right">3.6K</td><td>&nbsp;</td></tr>
<tr><td valign="top">&nbsp;</td><td><a href="minigzip.py">minigzip.py</a>            </td><td align="right">2023-11-14 19:43  </td><td align="right">4.2K</td><td>&nbsp;</td></tr>
   <tr><th colspan="5"><hr></th></tr>
</table>
</body></html>
  "   ˆl–äY>” T†» ÕÀ5q°)‹FÿÄƒyÆÜÂÁ !Ð    # Authors: Karl MacMillan <kmacmillan@mentalrootkit.com>
#
# Copyright (C) 2006 Red Hat
# see file 'COPYING' for use and warranty information
#
# This program 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; version 2 only
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#

"""
Classes and algorithms for matching requested access to access vectors.
"""

import itertools

from . import access
from . import objectmodel
from . import util


class Match(util.Comparison):
    def __init__(self, interface=None, dist=0):
        self.interface = interface
        self.dist = dist
        self.info_dir_change = False
        # when implementing __eq__ also __hash__ is needed on py2
        # if object is muttable __hash__ should be None
        self.__hash__ = None

    def _compare(self, other, method):
        try:
            a = (self.dist, self.info_dir_change)
            b = (other.dist, other.info_dir_change)
            return method(a, b)
        except (AttributeError, TypeError):
            # trying to compare to foreign type
            return NotImplemented

class MatchList:
    DEFAULT_THRESHOLD = 150
    def __init__(self):
        # Match objects that pass the threshold
        self.children = []
        # Match objects over the threshold
        self.bastards = []
        self.threshold = self.DEFAULT_THRESHOLD
        self.allow_info_dir_change = False
        self.av = None

    def best(self):
        if len(self.children):
            return self.children[0]
        if len(self.bastards):
            return self.bastards[0]
        return None

    def __len__(self):
        # Only return the length of the matches so
        # that this can be us