Format: application/x-python-code
1 o
2
3 �h6v � @ sp d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m
4 Z
5 ddlmZm
6 Z
7 mZmZmZ ddlmZ dd lmZ dd
8 lmZmZ ddlmZmZmZmZmZ ddlmZmZ dd
9 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�
10 eQeQdx�dydz� d{dz� d|�d}eJieOePeXd~�deQid�eRid�e[id�eQid�dz� d�dz� d��d�eSieSeSd��eSeSd��e\ej^j_�e\ej^j`�e\ej^ja�e]d��d��Zbd�d�� ZcG d�d�� d�e�Zdd�d�� ZedS )�a�
11 Implementations of standard library functions, because it's not possible to
12 understand them with Jedi.
13
14 To add a new implementation, create a function and add it to the
15 ``_implemented`` dict at the bottom of this module.
16
17 Note that this module exists only to implement very specific functionality in
18 the standard library. The usual way to understand the standard library is the
19 compiled module that returns the types for C-builtins.
20 � N)� Parameter)�debug)�
21 safe_property)�get_str_or_none)�iterate_argument_clinic�
22 ParamIssue�repack_with_argument_clinic�AbstractArguments�TreeArgumentsWrapper)�analysis)�compiled)�AnonymousMethodExecutionContext�MethodExecutionContext)�ContextualizedNode� NO_VALUES�ValueSet�ValueWrapper�LazyValueWrapper)�
23 ClassValue�ModuleValue)�
24 ClassMixin)�
25 FunctionMixin)�iterable)�
26 LazyTreeValue�LazyKnownValue�LazyKnownValues)� ValueName�BaseTreeParamName)�AttributeOverwrite�publish_method�ParserTreeFilter�
27 DictFilter)�AbstractSignature�SignatureWrappera _property = property
28 _tuple = tuple
29 from operator import itemgetter as _itemgetter
30 from collections import OrderedDict
31
32 class {typename}(tuple):
33 __slots__ = ()
34
35 _fields = {field_names!r}
36
37 def __new__(_cls, {arg_list}):
38 'Create new instance of {typename}({arg_list})'
39 return _tuple.__new__(_cls, ({arg_list}))
40
41 @classmethod
42 def _make(cls, iterable, new=tuple.__new__, len=len):
43 'Make a new {typename} object from a sequence or iterable'
44 result = new(cls, iterable)
45 if len(result) != {num_fields:d}:
46 raise TypeError('Expected {num_fields:d} arguments, got %d' % len(result))
47 return result
48
49 def _replace(_self, **kwds):
50 'Return a new {typename} object replacing specified fields with new values'
51 result = _self._make(map(kwds.pop, {field_names!r}, _self))
52 if kwds:
53 raise ValueError('Got unexpected field names: %r' % list(kwds))
54 return result
55
56 def __repr__(self):
57 'Return a nicely formatted representation string'
58 return self.__class__.__name__ + '({repr_fmt})' % self
59
60 def _asdict(self):
61 'Return a new OrderedDict which maps field names to their values.'
62 return OrderedDict(zip(self._fields, self))
63
64 def __getnewargs__(self):
65 'Return self as a plain tuple. Used by copy and pickle.'
66 return tuple(self)
67
68 # These methods were added by Jedi.
69 # __new__ doesn't really work with Jedi. So adding this to nametuples seems
70 # like the easiest way.
71 def __init__(self, {arg_list}):
72 'A helper function for namedtuple.'
73 self.__iterable = ({arg_list})
74
75 def __iter__(self):
76 for i in self.__iterable:
77 yield i
78
79 def __getitem__(self, y):
80 return self.__iterable[y]
81
82 {field_defs}
83 zW {name} = _property(_itemgetter({index:d}), doc='Alias for field number {index:d}')
84 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
85 yV Y |� S w |�� |d�S )Nc s ��� d�S )N�� arguments� r'