stdlib.pyc
1 o 2 )��c�u � @ sl d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m 3 Z 4 ddlmZm Z mZmZmZ ddlmZ dd lmZ dd 5 lmZmZ ddlmZmZmZmZmZ ddlmZmZ dd l m!Z! ddl"m#Z# ddlm$Z$ ddl%m&Z&m'Z'm(Z( ddl)m*Z*m+Z+ ddl,m-Z-m.Z.m/Z/m0Z0 ddl1m2Z2m3Z3 dZ4dZ5dd� Z6dd� Z7 d�dd�Z8e8ddd�d d!� �Z9e8d�d"d#� �Z:e8d$�d�d%d&��Z;e8d'�d(d)� �Z<G d*d+� d+e�Z=e8d,dd-�d.d/� �Z>G d0d1� d1e-�Z?e8d2ddd3�d4d5� �Z@e8d6ddd7�d8d9� �ZAG d:d;� d;e�ZBe8d2�d<d=� �ZCG d>d?� d?e�ZDG d@dA� dAe�ZEG dBdC� dCe�ZFe8d2ddd3�dDdE� �ZGG dFdG� dGe-e�ZHe8dHddI�dJdK� �ZIdLdM� ZJG dNdO� dOe�ZKG dPdQ� dQeK�ZLG dRdS� dSe3�ZMG dTdU� dUe�ZNdVdW� ZOdXdY� ZPe8dZ�d[d\� �ZQe8d]�d^d_� �ZRd`da� ZSG dbdc� dcee!�ZTG ddde� dee2�ZUG dfdg� dge+�ZVG dhdi� die�ZWe8dH�djdk� �ZXG dldm� dme�ZYG dndo� doee#�ZZe8dpddd3�dqdr� �Z[dsdt� Z\e8dpddI�dudv� �Z]e;e<e>e@eAe9e:eCeGeIdw� 6 eQeQdx�dydz� d{dz� d|�d}eJieOePeXd~�deQid�eRid�e[id�eQid�dz� d�dz� d��d�eSid�eSid�eSie\ej^j_�e\ej^j`�e\ej^ja�e]d��d��Zbd�d�� ZcG d�d�� d�e�Zdd�d�� ZedS )�a� 7 Implementations of standard library functions, because it's not possible to 8 understand them with Jedi. 9 10 To add a new implementation, create a function and add it to the 11 ``_implemented`` dict at the bottom of this module. 12 13 Note that this module exists only to implement very specific functionality in 14 the standard library. The usual way to understand the standard library is the 15 compiled module that returns the types for C-builtins. 16 � N)� Parameter)�debug)� safe_property)�get_str_or_none)�iterate_argument_clinic� 17 ParamIssue�repack_with_argument_clinic�AbstractArguments�TreeArgumentsWrapper)�analysis)�compiled)�AnonymousMethodExecutionContext�MethodExecutionContext)�ContextualizedNode� NO_VALUES�ValueSet�ValueWrapper�LazyValueWrapper)� 18 ClassValue�ModuleValue)� 19 ClassMixin)� FunctionMixin)�iterable)� LazyTreeValue�LazyKnownValue�LazyKnownValues)� ValueName�BaseTreeParamName)�AttributeOverwrite�publish_method�ParserTreeFilter� 20 DictFilter)�AbstractSignature�SignatureWrappera _property = property 21 _tuple = tuple 22 from operator import itemgetter as _itemgetter 23 from collections import OrderedDict 24 25 class {typename}(tuple): 26 __slots__ = () 27 28 _fields = {field_names!r} 29 30 def __new__(_cls, {arg_list}): 31 'Create new instance of {typename}({arg_list})' 32 return _tuple.__new__(_cls, ({arg_list})) 33 34 @classmethod 35 def _make(cls, iterable, new=tuple.__new__, len=len): 36 'Make a new {typename} object from a sequence or iterable' 37 result = new(cls, iterable) 38 if len(result) != {num_fields:d}: 39 raise TypeError('Expected {num_fields:d} arguments, got %d' % len(result)) 40 return result 41 42 def _replace(_self, **kwds): 43 'Return a new {typename} object replacing specified fields with new values' 44 result = _self._make(map(kwds.pop, {field_names!r}, _self)) 45 if kwds: 46 raise ValueError('Got unexpected field names: %r' % list(kwds)) 47 return result 48 49 def __repr__(self): 50 'Return a nicely formatted representation string' 51 return self.__class__.__name__ + '({repr_fmt})' % self 52 53 def _asdict(self): 54 'Return a new OrderedDict which maps field names to their values.' 55 return OrderedDict(zip(self._fields, self)) 56 57 def __getnewargs__(self): 58 'Return self as a plain tuple. Used by copy and pickle.' 59 return tuple(self) 60 61 # These methods were added by Jedi. 62 # __new__ doesn't really work with Jedi. So adding this to nametuples seems 63 # like the easiest way. 64 def __init__(self, {arg_list}): 65 'A helper function for namedtuple.' 66 self.__iterable = ({arg_list}) 67 68 def __iter__(self): 69 for i in self.__iterable: 70 yield i 71 72 def __getitem__(self, y): 73 return self.__iterable[y] 74 75 {field_defs} 76 zW {name} = _property(_itemgetter({index:d}), doc='Alias for field number {index:d}') 77 c � � fdd�}|S )Nc s� � ��fdd�}z�j j}W n ty Y |� S w �j}|d ur(|�� r(d}n|d ur5|�� r5|�� }n|� S ��� s@��� rC|� S zt | | }W n t 78 yV Y |� S w |�� |d�S )Nc s ��� d�S )N�� arguments� r'