File: //opt/saltstack/salt/lib/python3.10/site-packages/jaraco/__pycache__/collections.cpython-310.pyc
o
�N�g�b � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlm Z d dl
ZG dd� dejj
�ZG dd� de�Zdd� ZG d d
� d
e�Zdd� Zed
fdd�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�Zdd� ZG dd� de�ZG dd� deejj
�ZG dd� de�ZG d d!� d!ejj
ejj�Z G d"d#� d#ee�Z!G d$d%� d%e�Z"G d&d'� d'ej#�Z$G d(d)� d)e�Z%G d*d+� d+e�Z&d,d-� Z'G d.d/� d/ej(�Z)G d0d1� d1�Z*G d2d3� d3e�Z+dS )4� N)�NonDataPropertyc @ s0 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
S )�
Projectiona@
Project a set of keys over a mapping
>>> sample = {'a': 1, 'b': 2, 'c': 3}
>>> prj = Projection(['a', 'c', 'd'], sample)
>>> prj == {'a': 1, 'c': 3}
True
Keys should only appear if they were specified and exist in the space.
>>> sorted(list(prj.keys()))
['a', 'c']
Attempting to access a key not in the projection
results in a KeyError.
>>> prj['b']
Traceback (most recent call last):
...
KeyError: 'b'
Use the projection to update another dict.
>>> target = {'a': 2, 'b': 2}
>>> target.update(prj)
>>> target == {'a': 1, 'b': 2, 'c': 3}
True
Also note that Projection keeps a reference to the original dict, so
if you modify the original dict, that could modify the Projection.
>>> del sample['a']
>>> dict(prj)
{'c': 3}
c C s t |�| _|| _d S �N)�tuple�_keys�_space)�self�keys�space� r �F/opt/saltstack/salt/lib/python3.10/site-packages/jaraco/collections.py�__init__2 �
zProjection.__init__c C � || j vr t|��| j| S r )r �KeyErrorr �r �keyr r r �__getitem__6 �
zProjection.__getitem__c C s t t| j��| j��S r )�iter�setr �intersectionr �r r r r �__iter__; � zProjection.__iter__c C s t tt| ���S r )�lenr r r r r r �__len__>