Files
old-saburly-wagtail-web/env/lib/python3.10/site-packages/modelcluster/__pycache__/utils.cpython-310.pyc

88 lines
6.1 KiB
Plaintext
Raw Normal View History

2024-08-27 20:33:44 +02:00
o
<00><><EFBFBD>f<EFBFBD><00>@s<>ddlZddlmZddlZddlmZddlmZmZm Z m
Z
m Z m Z ddl mZdZGdd<08>de<10>ZGd d
<EFBFBD>d
e<12>ZGd d <0C>d <0C>Zedd <0A>dd<0F><00>Zddd<12>Zdd<14>ZdS)<16>N)<01> lru_cache)<01>FieldDoesNotExist)<06> DateField<6C> DateTimeField<6C>ManyToManyField<6C> ManyToManyRel<65>Model<65> TimeField)<01>datetime_utils<6C>__c@<00> eZdZdS)<02>ManyToManyTraversalErrorN<72><03>__name__<5F>
__module__<EFBFBD> __qualname__<5F>rr<00>T/home/amir/Desktop/saburlyweb/env/lib/python3.10/site-packages/modelcluster/utils.pyr <00>r c@r )<02> NullRelationshipValueEncounteredNrrrrrrrrc@s:eZdZddgZdd<04>Zedefdd<07><04>Zedd <09><00>Zd
S) <0B>TraversedRelationship<69>
from_model<EFBFBD>fieldcCs||_||_dS<00>N)rr)<03>selfrrrrr<00>__init__s
zTraversedRelationship.__init__<5F>returncC<00>|jjSr)r<00>name<6D>rrrr<00>
field_name#<00>z TraversedRelationship.field_namecCrr)r<00> target_modelrrrr<00>to_model'r!zTraversedRelationship.to_modelN) rrr<00> __slots__r<00>property<74>strr r#rrrrrsr)<01>maxsizec Cs0|}g}d}|<01>t<01>D]<5D>}|durpt|ttf<02>r#tdj||||d<03><04><01>t|dd<01>r5|<03>t ||<04><02>|j
}n;t|t <0B>r?|t j vsSt|t<0E>rI|t jvsSt|t<10>r]|t jvr]t j|}|<06>}n4tdj|jjd|jt|<04>|d<07><03><01>z|j<14>|<05>}Wq ty<>|<05>d<08>r<>|j<14>|dd <09><00>j}<04>wt|<03>|_|S)
a<EFBFBD>
Returns a model field matching the supplied ``name``, which can include
double-underscores (`'__'`) to indicate relationship traversal - in which
case, the model field will be lookuped up from the related model.
Multiple traversals for the same field are supported, but at this
moment in time, only traversal of many-to-one and one-to-one relationships
is supported.
Details of any relationships traversed in order to reach the returned
field are made available as `field.traversals`. The value is a tuple of
``TraversedRelationship`` instances.
Raises ``FieldDoesNotExist`` if the name cannot be mapped to a model field.
Nz<4E>The lookup '{name}' from {model} cannot be replicated by modelcluster, because the '{field_name}' relationship from {subject_model} is a many-to-many, and traversal is only supported for one-to-one or many-to-one relationships.)r<00>modelr <00> subject_model<65> related_modelzVFailed attempting to traverse from {from_field} (a {from_field_type}) to '{to_field}'.<2E>.)<03>
from_field<EFBFBD>from_field_type<70>to_field<6C>_id<69><64><EFBFBD><EFBFBD><EFBFBD>)<1D>split<69> REL_DELIMETER<45>
isinstancerrr <00>format<61>getattr<74>appendrr*rr
<00>#DATETIMEFIELD_TRANSFORM_EXPRESSIONSr<00>DATEFIELD_TRANSFORM_EXPRESSIONSr <00>TIMEFIELD_TRANSFORM_EXPRESSIONS<4E>TRANSFORM_FIELD_TYPESr<00>_meta<74>labelr<00>type<70> get_field<6C>endswith<74> target_field<6C>tuple<6C>
traversals)r(rr)rBrr <00>transform_field_typerrr<00>get_model_field,s^<04><04> <02>
<02>
<02>

<04><04> 
<02>
rDFc Cs|}|}|<01>t<01>}t|dd<02>D]o\}} t|tj<04>r| tjvs4t|tj<07>r)| tjvs4t|tj <09>r=| tj
vr=t<05> || <09>}|}
qt || <09>rot || <09>}
t|
t<0E>rN|
}|
durl|t|<07>krl|r]dStdj|t|<00>|jj| d<05><04><01>|
}q|rtdStdj| t|<05>d<07><02><01>|r<>t |
d<08>r<>|
jS|
S) a<>
Attempts to extract a field value from ``obj`` matching the ``key`` - which,
can contain double-underscores (`'__'`) to indicate traversal of relationships
to related objects.
For keys that specify ``ForeignKey`` or ``OneToOneField`` field values, full
related objects are returned by default. If only the primary key values are
required ((.g. when ordering, or using ``values()`` or ``values_list()``)),
call the function with ``pk_only=True``.
By default, ``FieldDoesNotExist`` is raised if the key cannot be mapped to
a model field. Call the function with ``suppress_fielddoesnotexist=True``
to instead receive a ``None`` value when this occurs.
By default, ``NullRelationshipValueEncountered`` is raised if a ``None``
value is encountered while attempting to traverse relationships in order to
access further fields. Call the function with
``suppress_nullrelationshipvalueencountered`` to instead receive a ``None``
value when this occurs.
<20>)<01>startNzO'{key}' cannot be reached for {obj} because {model_class}.{field_name} is null.)<04>key<65>obj<62> model_classr z.'{name}' is not a valid field name for {model})rr(<00>pk)r1r2<00> enumerater3<00>datetimer
r7<00>dater8<00>timer9<00>derive_from_value<75>hasattrr5r<00>lenrr4<00>reprr;r<rr=rJ) rHrG<00>pk_only<6C>suppress_fielddoesnotexist<73>)suppress_nullrelationshipvalueencountered<65>source<63>
latest_obj<EFBFBD>segments<74>i<>segment<6E>valuerrr<00>extract_field_valuewsT

<02>

<02>

<02>
 


<04><04> <04><04>r\cs`t|<01>D])<29><00>dkrt<01>|<00>qd}<02>ddkr d}<02>dd<07><00><00>fdd <09>}|j||d
<EFBFBD>qdS) z<>
Sort a list of objects on the given fields. The field list works analogously to
queryset.order_by(*fields): each field is either a property of the object,
or is prefixed by '-' (e.g. '-name') to indicate reverse ordering.
<20>?Fr<00>-TrENcst|<00>dddd<02>}|du|fS)NT)rSrTrU)r\)<02>itemr[<00>rGrr<00>get_sort_value<75>s z&sort_by_fields.<locals>.get_sort_value)rG<00>reverse)<04>reversed<65>random<6F>shuffle<6C>sort)<04>items<6D>fieldsrbrarr`r<00>sort_by_fields<64>s 
   <04>ri)FFF)rL<00> functoolsrrd<00>django.core.exceptionsr<00>django.db.modelsrrrrrr <00> modelclusterr
r2<00>
ValueErrorr <00> ExceptionrrrDr\rirrrr<00><module>s    

J G