3 �^1 � @ sb d dl Z d dlZddlmZ ddlmZmZ ddlmZ ddl m Z mZmZ G dd� dee�Z dS ) � N� )�PolicyQuery)�CriteriaDescriptor�CriteriaSetDescriptor)� MatchObjClass)�DefaultRuletype�DefaultValue�DefaultRangeValuec sF e Zd ZdZeed�Zeed�Z ee d�Z� fdd�Zdd� Z � ZS )�DefaultQuerya# Query default_* statements. Parameter: policy The policy to query. Keyword Parameters/Class attributes: ruletype The rule type(s) to match. tclass The object class(es) to match. tclass_regex If true, use a regular expression for matching the rule's object class. default The default to base new contexts (e.g. "source" or "target") default_range The range to use on new context, default_range only ("low", "high", "low_high") )� enum_classc s$ t t| �j|f|� tjt�| _d S )N)�superr �__init__�loggingZ getLogger�__name__�log)�self�policy�kwargs)� __class__� �$/usr/lib64/python3.6/defaultquery.pyr 2 s zDefaultQuery.__init__c c s� | j jdj| �� | j jdj| �� | j| j � | j jdj| �� | j jdj| �� x|| jj� D ]n}| jrx|j| jkrxq`| j|�s�q`| j r�|j | j kr�q`| j r�y|j | j kr�w`W n tk r� w`Y nX |V q`W dS )z9Generator which yields all matching default_* statements.z,Generating default_* results from {0.policy}zRuletypes: {0.ruletype!r}zDefault: {0.default!r}zRange: {0.default_range!r}N)r �info�format�debugZ_match_object_class_debugr Zdefaults�ruletypeZ_match_object_class�default� default_range�AttributeError)r �dr r r �results6 s&