Ë
    ûûàgÚÇ  ã                   óþ  — d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
Z
d dlmZ d dlmZ d dlmZmZ d d	lmZ d d
lmZ d dlmZmZ d dlmZ d dlmZ d dlmZ d dlmZm Z  d dl!m"Z" d dl#m$Z$ d dl%m&Z' ddl(m)Z)m*Z* ddl+m,Z,m-Z- ddlm.Z. ddl/m0Z0m1Z1m2Z2 ddl3m4Z4m5Z5  ejl                  e7«      Z8e8js                   ejt                  «       «       d„ Z; G d„ d«      Z< G d„ de,¬«      Z= G d„ d e=e-¬«      Z>e>fd!„Z?y)"é    N)ÚOrderedDict)Údeepcopy)Úescape)Úwarn)Údiff_match_patch)Úsettings)ÚImproperlyConfiguredÚValidationError)Úno_style)Ú	Paginator)ÚconnectionsÚrouter)Úfields)Ú
ForeignKey)ÚQuerySet)ÚTransactionManagementErrorÚset_rollback)Ú	force_str)Ú	mark_safe)Úgettext_lazyé   )Ú
exceptionsÚwidgets)ÚDeclarativeMetaclassÚModelDeclarativeMetaclass)ÚField)ÚErrorÚResultÚ	RowResult)Úatomic_if_using_transactionÚget_related_modelc                 óJ   — t        | d«      xr t        | j                  d«      S )z@
    Determine if a model has natural foreign key functions
    Únatural_keyÚget_by_natural_key)ÚhasattrÚobjects©Úmodels    úU/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/import_export/resources.pyÚhas_natural_foreign_keyr*   "   s)   € ô �5˜-Ó(ò ¬WØ�‰Ð+ó.ð ó    c                   ó.   — e Zd Zd„ Zd„ Zd„ Zed„ «       Zy)ÚDiffc                 óV   — t         j                  ||«      | _        g | _        || _        y ©N)r-   Ú_read_field_valuesÚleftÚrightÚnew)ÚselfÚresourceÚinstancer3   s       r)   Ú__init__zDiff.__init__,   s$   € Ü×+Ñ+¨H°hÓ?ˆŒ	ØˆŒ
Øˆ�r+   c                 ó:   — t         j                  ||«      | _        y r/   )r-   r0   r2   )r4   r5   r6   s      r)   Úcompare_withzDiff.compare_with1   s   € Ü×,Ñ,¨X°xÓ@ˆ�
r+   c                 óX  — g }t        «       }t        | j                  | j                  «      D ]z  \  }}||k7  r| j                  rd}|j                  t        |«      t        |«      «      }|j                  |«       |j                  |«      }t        |«      }|j                  |«       Œ| |S )NÚ )r   Úzipr1   r2   r3   Ú	diff_mainr   Údiff_cleanupSemanticÚdiff_prettyHtmlr   Úappend)r4   ÚdataÚdmpÚv1Úv2ÚdiffÚhtmls          r)   Úas_htmlzDiff.as_html4   s•   € ØˆÜÓ ˆÜ˜$Ÿ)™) T§Z¡ZÓ0ò 	‰FˆB�Ø�RŠx˜DŸHšHØ�Ø—=‘=¤¨2£´	¸"³Ó>ˆDØ×$Ñ$ TÔ*Ø×&Ñ& tÓ,ˆDÜ˜T“?ˆDØ�K‰K˜Õð	ð ˆr+   c                 óf   — |j                  «       D �cg c]  }|j                  |«      ‘Œ c}S c c}w r/   )Úget_import_fieldsÚexport)Úclsr5   r6   Úfs       r)   r0   zDiff._read_field_valuesA   s(   € à,4×,FÑ,FÓ,HÖI q�—‘˜Õ"ÒIÐIùÒIs   “.N)Ú__name__Ú
__module__Ú__qualname__r7   r9   rG   Úclassmethodr0   © r+   r)   r-   r-   +   s(   „ òò
Aòð ñJó ñJr+   r-   c                   óÜ  — e Zd ZdZd„ Zed„ «       Zed„ «       Zed„ «       Zed„ «       Z	ed„ «       Z
d„ Zd	„ Zd
„ Zd„ Zd@d„Zd„ Zd„ Zd„ Zd„ Z	 dAd„Z	 dAd„Zd@d„Z	 dBd„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdCd„Zd„ Z d„ Z!d „ Z"d!„ Z#d"„ Z$d@d#„Z%d$„ Z&d%„ Z'd&„ Z(d'„ Z)d(„ Z*d@d)„Z+d*„ Z,dCd+„Z-d,„ Z.	 	 	 	 	 dDd-„Z/d.„ Z0d/„ Z1d0„ Z2d1„ Z3d2„ Z4d3„ Z5d4„ Z6d@d5„Z7d@d6„Z8d@d7„Z9d8„ Z:d9„ Z;d@d:„Z<d;„ Z=d<„ Z>d=„ Z?d>„ Z@d?„ ZAy)EÚResourcez‰
    Resource defines how objects are mapped to their import and export
    representations and handle importing and exporting data.
    c                 ób   — t        | j                  «      | _        g | _        g | _        g | _        y)z™
        kwargs:
           An optional dict of kwargs.
           Subclasses can use kwargs to pass dynamic values to enhance import / exports.
        N)r   r   Úcreate_instancesÚupdate_instancesÚdelete_instances©r4   Úkwargss     r)   r7   zResource.__init__L   s.   € ô ˜tŸ{™{Ó+ˆŒð !#ˆÔØ "ˆÔØ "ˆÕr+   c                 ó   — t         S )zJ
        Returns the class used to store the result of an import.
        )r   ©r4   s    r)   Úget_result_classzResource.get_result_class^   s	   € ô
 ˆr+   c                 ó   — t         S )zM
        Returns the class used to store the result of a row import.
        )r   r[   s    r)   Úget_row_result_classzResource.get_row_result_classe   s
   € ô
 Ðr+   c                 ó   — t         S )zT
        Returns the class used to store an error resulting from an import.
        )r   r[   s    r)   Úget_error_result_classzResource.get_error_result_classl   s	   € ô
 ˆr+   c                 ó   — t         S )zV
        Returns the class used to display the diff for an imported instance.
        )r-   r[   s    r)   Úget_diff_classzResource.get_diff_classs   s	   € ô
 ˆr+   c                 ó¬   — | j                   j                  €)t        j                  | j                   j                  «      S | j                   j                  S r/   )Ú_metaÚusing_dbr   Údb_for_writer(   r[   s    r)   Úget_db_connection_namezResource.get_db_connection_namez   s=   € à�:‰:×ÑÐ&Ü×&Ñ& t§z¡z×'7Ñ'7Ó8Ð8à—:‘:×&Ñ&Ð&r+   c                 ó|   — | j                   j                  €t        t        dd«      S | j                   j                  S )NÚIMPORT_EXPORT_USE_TRANSACTIONST)rd   Úuse_transactionsÚgetattrr   r[   s    r)   Úget_use_transactionszResource.get_use_transactions�   s2   € Ø�:‰:×&Ñ&Ð.Üœ8Ð%EÀtÓLÐLà—:‘:×.Ñ.Ð.r+   c                 ó|   — | j                   j                  €t        t        dd«      S | j                   j                  S )NÚIMPORT_EXPORT_CHUNK_SIZEéd   )rd   Ú
chunk_sizerk   r   r[   s    r)   Úget_chunk_sizezResource.get_chunk_size‡   s2   € Ø�:‰:× Ñ Ð(Üœ8Ð%?ÀÓEÐEà—:‘:×(Ñ(Ð(r+   c                 ól   — t        dt        d¬«       t        | j                  j	                  «       «      S )NzOThe 'get_fields()' method is deprecated and will be removed in a future releaseé   ©Ú
stacklevel)r   ÚDeprecationWarningÚlistr   ÚvaluesrX   s     r)   Ú
get_fieldszResource.get_fields�   s/   € Üð"äØõ		
ô �D—K‘K×&Ñ&Ó(Ó)Ð)r+   c                 ó�   — | j                   j                  «       D ]  \  }}||k(  sŒ|c S  t        d|› d| j                  › d�«      ‚)z;
        Returns the field name for a given field.
        zField z does not exists in z	 resource)r   ÚitemsÚAttributeErrorÚ	__class__)r4   ÚfieldÚ
field_namerL   s       r)   Úget_field_namezResource.get_field_name–   sX   € ð "Ÿ[™[×.Ñ.Ó0ò 	"‰MˆJ˜Ø�E‹zØ!Ò!ð	"ô Ø�U�GÐ/°·±Ð/?¸yÐIó
ð 	
r+   Nc                 ó   — t        «       ‚)z|
        Initializes an object. Implemented in
        :meth:`import_export.resources.ModelResource.init_instance`.
        )ÚNotImplementedError©r4   Úrows     r)   Úinit_instancezResource.init_instance¡   s   € ô
 "Ó#Ð#r+   c                 ó°   — | j                  «       D �cg c]  }| j                  |   ‘Œ }}|D ]  }|j                  |vsŒ y |j                  |«      S c c}w )zI
        Calls the :doc:`InstanceLoader <api_instance_loaders>`.
        N)Úget_import_id_fieldsr   Úcolumn_nameÚget_instance)r4   Úinstance_loaderr„   rL   Úimport_id_fieldsr~   s         r)   r‰   zResource.get_instance¨   sd   € ð 59×4MÑ4MÓ4OÖP¨q˜DŸK™K¨›NÐPÐÐPØ%ò 	ˆEØ× Ñ ¨Ò+ñ ð	ð ×+Ñ+¨CÓ0Ð0ùò Qs   “Ac                 ó„   — | j                   j                  s| j                  ||«      }|r|dfS | j                  |«      dfS )zW
        Either fetches an already existing instance or initializes a new one.
        FT)rd   Úforce_init_instancer‰   r…   )r4   rŠ   r„   r6   s       r)   Úget_or_init_instancezResource.get_or_init_instanceµ   sF   € ð �z‰z×-Ò-Ø×(Ñ(¨¸#Ó>ˆHÙØ �Ð&Ø×!Ñ! #Ó&¨Ð,Ð,r+   c                 ó.   — | j                   j                  S )ú )rd   r‹   r[   s    r)   r‡   zResource.get_import_id_fields¿   s   € à�z‰z×*Ñ*Ð*r+   c                 ór   — | j                   D �cg c]  }|| j                  j                  vsŒ|‘Œ c}S c c}w )z¸
        Returns the fields to be included in calls to bulk_update().
        ``import_id_fields`` are removed because `id` fields cannot be supplied to
        bulk_update().
        )r   rd   r‹   )r4   rL   s     r)   Úget_bulk_update_fieldszResource.get_bulk_update_fieldsÃ   s-   € ð  Ÿ;™;ÖO�a¨!°4·:±:×3NÑ3NÒ*N’ÒOÐOùÒOs   �4­4c                 óz  — 	 t        | j                  «      dkD  r@|s|rn;| j                  j                  j                  j                  | j                  |¬«       | j                  j                  «        y# t        $ r}| j                  |||«       Y d}~Œ<d}~ww xY w# | j                  j                  «        w xY w)z=
        Creates objects by calling ``bulk_create``.
        r   ©Ú
batch_sizeN)	ÚlenrU   rd   r(   r&   Úbulk_createÚ	ExceptionÚhandle_import_errorÚclear©r4   Úusing_transactionsÚdry_runÚraise_errorsr•   ÚresultÚes          r)   r—   zResource.bulk_createË   s    € ð	*Ü�4×(Ñ(Ó)¨AÒ-Ù)©gØà—J‘J×$Ñ$×,Ñ,×8Ñ8Ø×-Ñ-¸*ð 9ô ð ×!Ñ!×'Ñ'Õ)øô ò 	>Ø×$Ñ$ V¨Q°×=Ñ=ûð	>ûð ×!Ñ!×'Ñ'Õ)ús*   ‚AA5 Á5	BÁ>BÂB ÂBÂB ÂB:c                 ó˜  — 	 t        | j                  «      dkD  rO|s|rnJ| j                  j                  j                  j                  | j                  | j                  «       |¬«       | j                  j                  «        y# t        $ r}| j                  |||«       Y d}~Œ<d}~ww xY w# | j                  j                  «        w xY w)z=
        Updates objects by calling ``bulk_update``.
        r   r”   N)
r–   rV   rd   r(   r&   Úbulk_updater’   r˜   r™   rš   r›   s          r)   r¢   zResource.bulk_updateÞ   s­   € ð	*Ü�4×(Ñ(Ó)¨AÒ-Ù)©gØà—J‘J×$Ñ$×,Ñ,×8Ñ8Ø×-Ñ-Ø×3Ñ3Ó5Ø#-ð 9ô ð ×!Ñ!×'Ñ'Õ)øô ò 	>Ø×$Ñ$ V¨Q°×=Ñ=ûð	>ûð ×!Ñ!×'Ñ'Õ)ús*   ‚A'B Â	B*ÂB%Â B- Â%B*Â*B- Â-C	c                 óÐ  — 	 t        | j                  «      dkD  rf|s|rna| j                  D �cg c]  }|j                  ‘Œ }}| j                  j                  j
                  j                  |¬«      j                  «        | j                  j                  «        yc c}w # t        $ r}| j                  |||«       Y d}~ŒAd}~ww xY w# | j                  j                  «        w xY w)zŽ
        Deletes objects by filtering on a list of instances to be deleted,
        then calling ``delete()`` on the entire queryset.
        r   )Úpk__inN)r–   rW   Úpkrd   r(   r&   ÚfilterÚdeleter˜   r™   rš   )r4   rœ   r�   rž   rŸ   ÚoÚ
delete_idsr    s           r)   Úbulk_deletezResource.bulk_deleteó   s½   € ð

	*Ü�4×(Ñ(Ó)¨AÒ-Ù)©gØà04×0EÑ0EÖ!F¨1 !§$£$Ð!F�JÐ!FØ—J‘J×$Ñ$×,Ñ,×3Ñ3¸:Ð3ÓF×MÑMÔOð ×!Ñ!×'Ñ'Õ)ùò "Gøäò 	>Ø×$Ñ$ V¨Q°×=Ñ=ûð	>ûð ×!Ñ!×'Ñ'Õ)ús;   ‚+B  ­BÁ A B  ÂB  Â 	CÂ)CÂ<C	 ÃCÃC	 Ã	C%c                 ó  — |€i }n|j                  «       }| j                  j                  r"	 |j                  |j	                  «       |¬«       |rt        |«      ‚y# t
        $ r}|j                  |«      }Y d}~Œ-d}~ww xY w)a  
        Takes any validation errors that were raised by
        :meth:`~import_export.resources.Resource.import_instance`, and combines them
        with validation errors raised by the instance's ``full_clean()``
        method. The combined errors are then re-raised as single, multi-field
        ValidationError.

        If the ``clean_model_instances`` option is False, the instances's
        ``full_clean()`` method is not called, and only the errors raised by
        ``import_instance()`` are re-raised.
        N)ÚexcludeÚvalidate_unique)Úcopyrd   Úclean_model_instancesÚ
full_cleanÚkeysr
   Úupdate_error_dict)r4   r6   Úimport_validation_errorsr­   Úerrorsr    s         r)   Úvalidate_instancezResource.validate_instance  s…   € ð $Ð+Ø‰Fà-×2Ñ2Ó4ˆFØ�:‰:×+Ò+ð5Ø×#Ñ#Ø"ŸK™K›MØ$3ð $ô ñ Ü! &Ó)Ð)ð øô #ò 5Ø×,Ñ,¨VÓ4•ûð5ús   ­!A Á	B Á%A;Á;B c                 ó^  —  | j                   ||fi |¤Ž | j                  j                  r:|r| j                  j	                  |«       nQ| j
                  j	                  |«       n5| j                  |«      s| j                  |«      rn| j                  ||«        | j                  ||fi |¤Ž y)aã  
        Takes care of saving the object to the database.

        Objects can be created in bulk if ``use_bulk`` is enabled.

        :param instance: The instance of the object to be persisted.

        :param is_create: A boolean flag to indicate whether this is a new object
                          to be created, or an existing object to be updated.

        :param row: A dict representing the import row.

        :param \**kwargs:
            See :meth:`import_row
        N)
Úbefore_save_instancerd   Úuse_bulkrU   r@   rV   Ú_is_using_transactionsÚ_is_dry_runÚdo_instance_saveÚafter_save_instance)r4   r6   Ú	is_creater„   rY   s        r)   Úsave_instancezResource.save_instance"  s˜   € ð  	"ˆ×!Ñ! (¨CÑ:°6Ò:Ø�:‰:×ÒÙØ×%Ñ%×,Ñ,¨XÕ6à×%Ñ%×,Ñ,¨XÕ6à×.Ñ.¨vÔ6¸4×;KÑ;KÈFÔ;Sàà×%Ñ% h°	Ô:Ø ˆ× Ñ  ¨3Ñ9°&Ó9r+   c                 ó$   — |j                  «        y)aœ  
        A method specifically to provide a single overridable hook for the instance
        save operation.
        For example, this can be overridden to implement update_or_create().

        :param instance: The model instance to be saved.
        :param is_create: A boolean flag to indicate whether this is a new object
                          to be created, or an existing object to be updated.
        N)Úsave)r4   r6   r½   s      r)   r»   zResource.do_instance_save@  s   € ð 	�‰�r+   c                  ó   — y©a  
        Override to add additional logic. Does nothing by default.

        :param instance: A new or existing model instance.

        :param row: A ``dict`` containing key / value data for the row to be imported.

        :param \**kwargs:
            See :meth:`import_row`
        NrQ   ©r4   r6   r„   rY   s       r)   r·   zResource.before_save_instanceL  ó   € ð 	r+   c                  ó   — yrÂ   rQ   rÃ   s       r)   r¼   zResource.after_save_instanceY  rÄ   r+   c                 ó  —  | j                   ||fi |¤Ž | j                  j                  r| j                  j	                  |«       n3| j                  |«      s| j                  |«      rn|j                  «         | j                  ||fi |¤Ž y)as  
        Calls :meth:`instance.delete` as long as ``dry_run`` is not set.
        If ``use_bulk`` then instances are appended to a list for bulk import.

        :param instance: A new or existing model instance.

        :param row: A ``dict`` containing key / value data for the row to be imported.

        :param \**kwargs:
            See :meth:`import_row`
        N)	Úbefore_delete_instancerd   r¸   rW   r@   r¹   rº   r§   Úafter_delete_instancerÃ   s       r)   Údelete_instancezResource.delete_instancef  s{   € ð 	$ˆ×#Ñ# H¨cÑ<°VÒ<Ø�:‰:×ÒØ×!Ñ!×(Ñ(¨Õ2à×.Ñ.¨vÔ6¸4×;KÑ;KÈFÔ;Sàà—‘Ô!Ø"ˆ×"Ñ" 8¨SÑ;°FÓ;r+   c                  ó   — yrÂ   rQ   rÃ   s       r)   rÇ   zResource.before_delete_instance}  rÄ   r+   c                  ó   — yrÂ   rQ   rÃ   s       r)   rÈ   zResource.after_delete_instanceŠ  rÄ   r+   c                 óä   — |j                   st        j                  d|› d�«       y|j                  |vr't        j                  d|› d|j                  › d�«       y |j                  |||fi |¤Ž y)a»  
        Handles persistence of the field data.

        :param field: A :class:`import_export.fields.Field` instance.

        :param instance: A new or existing model instance.

        :param row: A ``dict`` containing key / value data for the row to be imported.

        :param is_m2m: A boolean value indicating whether or not this is a
          many-to-many field.

        :param \**kwargs:
            See :meth:`import_row`
        zskipping field 'z"' - field attribute is not definedNz' - column name 'z' is not present in row)Ú	attributeÚloggerÚdebugrˆ   rÀ   )r4   r~   r6   r„   Úis_m2mrY   s         r)   Úimport_fieldzResource.import_field—  s|   € ð  �ŠÜ�L‰LÐ+¨E¨7Ð2TÐUÔVØØ×Ñ CÑ'Ü�L‰LØ" 5 'ð *"Ø"'×"3Ñ"3Ð!4Ð4KðMôð Øˆ�
‰
�8˜S &Ñ3¨FÓ3r+   c                 ó  — g }| j                  «       D ]o  }|| j                  v r|j                  | j                  |   «       Œ0| j                  j                  «       D ]#  }|j                  |k(  sŒ|j                  |«       Œ% Œq |S r/   )Úget_import_orderr   r@   rx   rˆ   )r4   Úimport_fieldsr   r~   s       r)   rI   zResource.get_import_fields²  sŠ   € ØˆØ×/Ñ/Ó1ò 		ˆJØ˜TŸ[™[Ñ(Ø×$Ñ$ T§[¡[°Ñ%<Ô=Øð Ÿ™×+Ñ+Ó-ò �Ø×$Ñ$¨
Ó2Ø!×(Ñ(¨Ô/Øñð		ð Ðr+   c                 ó~   — t        dt        d¬«       |du r|j                  d|i«        | j                  ||fi |¤Ž y )NzªThe 'import_obj' method is deprecated and will be replaced with 'import_instance(self, instance, row, **kwargs)' in a future release.  Refer to Release Notes for details.rs   rt   Tr�   )r   rv   ÚupdateÚimport_instance)r4   ÚobjrA   r�   rY   s        r)   Ú
import_objzResource.import_objÀ  sI   € ÜðHô Øõ	
ð �d‰?Ø�M‰M˜9 gÐ.Ô/Øˆ×Ñ˜S $Ñ1¨&Ó1r+   c                 ó4  — i }| j                  «       D ]=  }t        |j                  t        j                  «      rŒ(	  | j
                  |||fi |¤Ž Œ? |rt        |«      ‚y# t        $ r-}t        t        |«      d¬«      ||j                  <   Y d}~Œd}~ww xY w)a  
        Traverses every field in this Resource and calls
        :meth:`~import_export.resources.Resource.import_field`. If
        ``import_field()`` results in a ``ValueError`` being raised for
        one of more fields, those errors are captured and reraised as a single,
        multi-field ValidationError.

        :param instance: A new or existing model instance.

        :param row: A ``dict`` containing key / value data for the row to be imported.

        :param \**kwargs:
            See :meth:`import_row`
        Úinvalid)ÚcodeN)
rI   Ú
isinstanceÚwidgetr   ÚManyToManyWidgetrÑ   Ú
ValueErrorr
   r   rÍ   )r4   r6   r„   rY   r´   r~   r    s          r)   r×   zResource.import_instanceÌ  s›   € ð ˆØ×+Ñ+Ó-ò 	XˆEÜ˜%Ÿ,™,¬×(@Ñ(@ÔAØðXØ!�×!Ñ! %¨°3ÑA¸&ÓAð		Xñ Ü! &Ó)Ð)ð øô ò XÜ*9¼)ÀA»,ÈYÔ*W��u—‘Ö'ûðXús   ¼A!Á!	BÁ*#BÂBc                 ó  — | j                  |«      }| j                  |«      }|s|s| j                  j                  ry| j	                  «       D ];  }t        |j                  t        j                  «      sŒ(| j                  |||d«       Œ= y)af  
        Saves m2m fields.

        Model instance need to have a primary key value before
        a many-to-many relationship can be used.

        :param instance: A new or existing model instance.

        :param row: A ``dict`` containing key / value data for the row to be imported.

        :param \**kwargs:
            See :meth:`import_row`
        TN)
r¹   rº   rd   r¸   rI   rÝ   rÞ   r   rß   rÑ   )r4   r6   r„   rY   rœ   r�   r~   s          r)   Úsave_m2mzResource.save_m2mæ  s~   € ð "×8Ñ8¸Ó@ÐØ×"Ñ" 6Ó*ˆÙ"¡w°4·:±:×3FÒ3Fð à×/Ñ/Ó1ò >�Ü! %§,¡,´×0HÑ0HÔIØØ×!Ñ! %¨°3¸Õ=ñ>r+   c                  ó   — y)aG  
        Returns ``True`` if ``row`` importing should delete instance.

        Default implementation returns ``False``.
        Override this method to handle deletion.

        :param row: A ``dict`` containing key / value data for the row to be imported.

        :param instance: A new or existing model instance.
        FrQ   )r4   r„   r6   s      r)   Ú
for_deletezResource.for_delete  s   € ð r+   c                 óz  — | j                   j                  r| j                   j                  s|ry| j                  «       D ]ù  }t	        |j
                  t        j                  «      r®|j                  |j                  «       vrŒDt        |j                  |«      «      }|j                  €g n't        |j                  |«      j                  «       «      }t        |«      t        |«      k7  r yt!        d„ |D «       «      t!        d„ |D «       «      k7  sŒÓ y|j                  |«      |j                  |«      k7  sŒù y y)aí  
        Returns ``True`` if ``row`` importing should be skipped.

        Default implementation returns ``False`` unless skip_unchanged == True
        and skip_diff == False.

        If skip_diff is True, then no comparisons can be made because ``original``
        will be None.

        When left unspecified, skip_diff and skip_unchanged both default to ``False``,
        and rows are never skipped.

        By default, rows are not skipped if validation errors have been detected
        during import.  You can change this behavior and choose to ignore validation
        errors by overriding this method.

        Override this method to handle skipping rows meeting certain
        conditions.

        Use ``super`` if you want to preserve default handling while overriding
        ::

            class YourResource(ModelResource):
                def skip_row(self, instance, original,
                             row, import_validation_errors=None):
                    # Add code here
                    return super().skip_row(instance, original, row,
                                            import_validation_errors=import_validation_errors)

        :param instance: A new or updated model instance.

        :param original: The original persisted model instance.

        :param row: A ``dict`` containing key / value data for the row to be imported.

        :param import_validation_errors: A ``dict`` containing key / value data for any
          identified validation errors.
        Fc              3   ó4   K  — | ]  }|j                   –— Œ y ­wr/   ©r¥   ©Ú.0Úvs     r)   ú	<genexpr>z$Resource.skip_row.<locals>.<genexpr>K  s   è ø€ Ò8 1˜!Ÿ$�$Ñ8ùó   ‚c              3   ó4   K  — | ]  }|j                   –— Œ y ­wr/   rç   rè   s     r)   rë   z$Resource.skip_row.<locals>.<genexpr>K  s   è ø€ ò CØ�A—D•DñCùrì   T)rd   Úskip_unchangedÚ	skip_diffrI   rÝ   rÞ   r   rß   rˆ   r±   rw   Úcleanr¥   Ú	get_valueÚallr–   Úsorted)r4   r6   Úoriginalr„   r³   r~   Úinstance_valuesÚoriginal_valuess           r)   Úskip_rowzResource.skip_row  s  € ðP —
‘
×)Ò)Ø�z‰z×#Ò#Ù'àØ×+Ñ+Ó-ò 	!ˆEô ˜%Ÿ,™,¬×(@Ñ(@ÔAà×$Ñ$¨C¯H©H«JÑ6Øô #' u§{¡{°3Ó'7Ó"8�à"Ÿ+™+Ð-‘B´4¸¿¹ÈÓ8Q×8UÑ8UÓ8WÓ3Xð  ô �Ó'¬3¨Ó+?Ò?Ù äÑ8¨Ô8Ó8¼Fñ CØ"1ôCó =ó ñ !à—?‘? 8Ó,°·±ÀÓ0IÓIÙ ð-	!ð. r+   c                 ón   — | j                  «       D �cg c]  }t        |j                  «      ‘Œ c}S c c}w )z.
        Diff representation headers.
        )rI   r   rˆ   )r4   r~   s     r)   Úget_diff_headerszResource.get_diff_headersT  s,   € ð ;?×:PÑ:PÓ:RÖS°”	˜%×+Ñ+Õ,ÒSÐSùÒSs   “2c                  ó   — y)z¹
        Override to add additional logic. Does nothing by default.

        :param dataset: A ``tablib.Dataset``.

        :param \**kwargs:
            See :meth:`import_row`
        NrQ   )r4   ÚdatasetrY   s      r)   Úbefore_importzResource.before_importZ  ó   € ð 	r+   c                  ó   — y)a6  
        Override to add additional logic. Does nothing by default.

        :param dataset: A ``tablib.Dataset``.

        :param result: A :class:`import_export.results.Result` implementation
          containing a summary of the import.

        :param \**kwargs:
            See :meth:`import_row`
        NrQ   )r4   rû   rŸ   rY   s       r)   Úafter_importzResource.after_importe  ó   € ð 	r+   c                  ó   — y)zâ
        Override to add additional logic. Does nothing by default.

        :param row: A ``dict`` containing key / value data for the row to be imported.

        :param \**kwargs:
            See :meth:`import_row`
        NrQ   )r4   r„   rY   s      r)   Úbefore_import_rowzResource.before_import_rows  rý   r+   c                  ó   — y)aY  
        Override to add additional logic. Does nothing by default.

        :param row: A ``dict`` containing key / value data for the row to be imported.

        :param row_result: A ``RowResult`` instance.
          References the persisted ``instance`` as an attribute.

        :param \**kwargs:
            See :meth:`import_row`
        NrQ   )r4   r„   Ú
row_resultrY   s       r)   Úafter_import_rowzResource.after_import_row~  r   r+   c                 ó|   — t        dt        d¬«       |�|j                  d|i«        | j                  ||d fi |¤Ž y )Nz¾The 'after_import_instance' method is deprecated and will be replaced with 'after_init_instance(self, instance, new, row, **kwargs)' in a future release.  Refer to Release Notes for details.rs   rt   Ú
row_number)r   rv   rÖ   Úafter_init_instance)r4   r6   r3   r  rY   s        r)   Úafter_import_instancezResource.after_import_instanceŒ  sJ   € ÜðHô Øõ	
ð Ð!Ø�M‰M˜<¨Ð4Ô5Ø ˆ× Ñ  ¨3°Ñ?¸Ó?r+   c                  ó   — y)ar  
        Override to add additional logic. Does nothing by default.

        :param instance: A new or existing model instance.

        :param new: a boolean flag indicating whether instance is new or existing.

        :param row: A ``dict`` containing key / value data for the row to be imported.

        :param \**kwargs:
            See :meth:`import_row`
        NrQ   )r4   r6   r3   r„   rY   s        r)   r  zResource.after_init_instance˜  s   € ð 	r+   c                 ó®   — t         j                  ||¬«       |r%|j                   | j                  «       |«      «       |rt	        j
                  |«      ‚y )N©Úexc_info)rÎ   rÏ   Úappend_base_errorr`   r   ÚImportError)r4   rŸ   Úerrorrž   s       r)   r™   zResource.handle_import_error§  sM   € Ü�‰�U UˆÔ+ÙØ×$Ñ$Ð%B T×%@Ñ%@Ó%BÀ5Ó%IÔJÙÜ×(Ñ(¨Ó/Ð/ð r+   c           	      ó^  — | j                   j                  }| j                   j                  s!|j                  dd«      | j                   _         | j	                  «       «       }| j                   j
                  r||_        d}	  | j                  |fi |¤Ž | j                  ||«      \  }} | j                  |||fi |¤Ž |rt        j                  |_        nt        j                  |_        |s#t        |«      } | j                  «       | ||«      }	| j!                  ||«      r£|r,t        j"                  |_        |�sP	j%                  | d«       �n<t        j&                  |_        |j)                  |«       | j                   j                  rt        |«      |_         | j,                  ||fi |¤Ž |sÚ	j%                  | d«       nÇi }
	  | j.                  ||fi |¤Ž | j5                  ||||
«      rt        j"                  |_        n;| j7                  ||
«        | j8                  |||fi |¤Ž  | j:                  ||fi |¤Ž |j)                  |«       | j                   j                  r||_        |s	j%                  | |«       |s||_        |s+| j                   j>                  s	jA                  «       |_!         | jD                  ||fi |¤Ž |S # t0        $ r}|j3                  |
«      }
Y d}~�Œd}~ww xY w# t0        $ r'}t        jF                  |_        ||_$        Y d}~|S d}~wtJ        $ r|}t        jL                  |_        tO        |tP        «      stR        jU                  |d¬«       |jV                  jY                   | j[                  «       |||d   ¬«      «       Y d}~|S d}~ww xY w)aZ  
        Imports data from ``tablib.Dataset``. Refer to :doc:`import_workflow`
        for a more complete description of the whole import process.

        :param row: A ``dict`` of the 'row' to import.
          A row is a dict of data fields so can be a csv line, a JSON object,
          a YAML object etc.

        :param instance_loader: The instance loader to be used to load the model
          instance associated with the row (if there is one).

        :param \**kwargs:
            See below.

        :Keyword Arguments:
            * dry_run (``boolean``) --
              A True value means that no data should be persisted.
            * use_transactions (``boolean``) --
              A True value means that transactions will be rolled back.
            * row_number  (``int``) --
              The index of the row being imported.
        Úretain_instance_in_row_resultFNTr  r  )r„   Únumber).rd   rï   Ústore_instanceÚgetr^   Ústore_row_valuesÚ
row_valuesr  rŽ   r  r   ÚIMPORT_TYPE_NEWÚimport_typeÚIMPORT_TYPE_UPDATEr   rb   rä   ÚIMPORT_TYPE_SKIPr9   ÚIMPORT_TYPE_DELETEÚadd_instance_infor6   rÉ   r×   r
   r²   r÷   rµ   r¾   râ   rô   Úskip_html_diffrG   rE   r  ÚIMPORT_TYPE_INVALIDÚvalidation_errorr˜   ÚIMPORT_TYPE_ERRORrÝ   r   rÎ   rÏ   r´   r@   r`   )r4   r„   rŠ   rY   rï   r  rô   r6   r3   rE   r³   r    s               r)   Ú
import_rowzResource.import_row®  sX  € ð. —J‘J×(Ñ(ˆ	à�z‰z×(Ò(Ø(.¯
©
Ø/°ó)ˆD�J‰JÔ%ð 1�T×.Ñ.Ó0Ó2ˆ
Ø�:‰:×&Ò&Ø$'ˆJÔ!ØˆðB	Ø"ˆD×"Ñ" 3Ñ1¨&Ò1Ø ×5Ñ5°oÀsÓK‰MˆH�cØ$ˆD×$Ñ$ X¨s°CÑB¸6ÒBÙÜ)2×)BÑ)B�
Õ&ä)2×)EÑ)E�
Ô&ÙÜ# HÓ-�Ø,�t×*Ñ*Ó,¨T°8¸SÓA�Ø�‰˜s HÔ-ÙÜ-6×-GÑ-G�JÔ*Ú$Ø×)Ñ)¨$°Ö5ä-6×-IÑ-I�JÔ*Ø×0Ñ0°Ô:Ø—z‘z×0Ò0ä.6°xÓ.@˜
Ô+Ø(�D×(Ñ(¨°3ÑA¸&ÒAÙ$Ø×)Ñ)¨$°Õ5à+-Ð(ðØ(�D×(Ñ(¨°3ÑA¸&ÒAð —=‘= ¨8°SÐ:RÔSÜ-6×-GÑ-G�JÕ*à×*Ñ*¨8Ð5MÔNØ&�D×&Ñ& x°°cÑD¸VÒDØ!�D—M‘M (¨CÑ:°6Ò:Ø×,Ñ,¨XÔ6Ø—:‘:×,Ò,Ø*2�JÔ'Ù Ø×%Ñ% d¨HÔ5ÙØ.6˜
Ô+á T§Z¡Z×%>Ò%>Ø"&§,¡,£.�
”Ø!ˆD×!Ñ! # zÑ<°VÒ<ð ÐøôO 'ò ð 01×/BÑ/BØ0ó0Ö,ûð	ûô4 ò 	,Ü%.×%BÑ%BˆJÔ"Ø*+ˆJ×'Ð'ð Ðûô ò 	Ü%.×%@Ñ%@ˆJÔ"ô ˜aÔ!;Ô<Ü—‘˜Q¨�Ô.Ø×Ñ×$Ñ$Ø-�×+Ñ+Ó-¨a°SÀÈÑAUÔV÷ð ð Ðûð	úsQ   ÂEK9 Ç
K ÇC1K9 Ë	K6ËK1Ë+K9 Ë1K6Ë6K9 Ë9	N,ÌL$Ì$N,Ì0A1N'Î'N,c                 óH  — |€| j                  «       }| j                  «       }t        |   }	t        |	j                  dd«      }
|r|
st
        ‚|xs |xr |
}| j                  j                  �Ht        | j                  j                  t        «      r| j                  j                  dk  rt        d«      ‚t        ||¬«      5   | j                  |||||fi |¤Ž}|r1|s"|j                  «       s|r|j                  «       rt        d|¬«       |cddd«       S # 1 sw Y   yxY w)aë  
        Imports data from ``tablib.Dataset``. Refer to :doc:`import_workflow`
        for a more complete description of the whole import process.

        :param dataset: A ``tablib.Dataset``.

        :param raise_errors: Whether errors should be printed to the end user
                             or raised regularly.

        :param use_transactions: If ``True`` the import process will be processed
                                 inside a transaction.

        :param collect_failed_rows:
          If ``True`` the import process will create a new dataset object comprising
          failed rows and errors.
          This can be useful for debugging purposes but will cause higher memory usage
          for larger datasets.
          See :attr:`~import_export.results.Result.failed_dataset`.

        :param rollback_on_validation_errors: If both ``use_transactions`` and
          ``rollback_on_validation_errors`` are set to ``True``, the import process will
          be rolled back in case of ValidationError.

        :param dry_run: If ``dry_run`` is set, or an error occurs, if a transaction
            is being used, it will be rolled back.

        :param \**kwargs:
            Metadata which may be associated with the import.
        NÚsupports_transactionsFr   z%Batch size must be a positive integer©ÚusingT)rl   rg   r   rk   Úfeaturesr	   rd   r•   rÝ   Úintrà   r    Úimport_data_innerÚ
has_errorsÚhas_validation_errorsr   )r4   rû   r�   rž   rj   Úcollect_failed_rowsÚrollback_on_validation_errorsrY   Údb_connectionÚ
connectionr$  rœ   rŸ   s                r)   Úimport_datazResource.import_data  s&  € ðP Ð#Ø#×8Ñ8Ó:Ðà×3Ñ3Ó5ˆÜ  Ñ/ˆ
Ü 'Ø×ÑÐ!8¸%ó!
Ðñ Ñ$9Ü&Ð&à.Ò9°'ÒTÐ?TÐà�:‰:× Ñ Ð,Ü˜4Ÿ:™:×0Ñ0´#Ô6¸$¿*¹*×:OÑ:OÐRSÒ:SäÐDÓEÐEä(Ð);À=ÔQñ 	Ø+�T×+Ñ+ØØØØ"Ø#ñð ñˆFñ "ÙØ×$Ñ$Ô&Ù1°f×6RÑ6RÔ6Tä˜T¨Õ7Ø÷	÷ 	ò 	ús   ÃADÄD!c           	      ó^
  —  | j                  «       «       }| j                  «       |_        t        |«      |_        | j                  «       }	 t        ||¬«      5   | j                  |fi |¤Ž d d d «       | j                  |j                  «       | j                  j                  | |«      }
t        |«      |_        |r|j                  |j                  «       t        |d«      D �]   \  }}t!        t#        |j                  |«      «      }t        |xr | j                  j$                   |¬«      5  |j'                  |||dœ«        | j(                  ||
fi |¤Ž}d d d «       | j                  j$                  �r/t        | j*                  «      | j                  j,                  k(  r@t        ||¬«      5  | j/                  |||| j                  j,                  |¬«       d d d «       t        | j0                  «      | j                  j,                  k(  r@t        ||¬«      5  | j3                  |||| j                  j,                  |¬«       d d d «       t        | j4                  «      | j                  j,                  k(  r+t        ||¬«      5  | j7                  ||||¬«       d d d «       |j9                  «       |j:                  ro|j=                  |||j:                  «       |r|j?                  ||j:                  d   «       |rštA        jB                  |j:                  d   jD                  ||¬«      ‚|jF                  r_|jI                  |||jF                  «       |r|j?                  ||jF                  «       |r"tA        jB                  |jF                  ||¬«      ‚|jJ                  tL        jN                  k7  s| j                  jP                  s�Œð|jS                  |«       �Œ | j                  j$                  rUt        ||¬«      5  | j/                  ||||¬«       | j3                  ||||¬«       | j7                  ||||¬«       d d d «       	 t        ||¬«      5   | jT                  ||fi |¤Ž d d d «       |S # 1 sw Y   �ŒxY w# t        $ r}	| j                  ||	|«       Y d }	~	�Œ d }	~	ww xY w# 1 sw Y   �Œ_xY w# 1 sw Y   �ŒéxY w# 1 sw Y   �ŒŠxY w# 1 sw Y   �Œ@xY w# 1 sw Y   Œ¡xY w# 1 sw Y   |S xY w# t        $ r}	| j                  ||	|«       Y d }	~	|S d }	~	ww xY w)	Nr%  r   )r�   rœ   r  )r•   rŸ   )rŸ   r   éÿÿÿÿ)r  r„   )+r\   rù   Údiff_headersr–   Ú
total_rowsrg   r    rü   Ú_check_import_id_fieldsÚheadersr˜   r™   rd   Úinstance_loader_classÚadd_dataset_headersÚ	enumerater   r<   r¸   rÖ   r"  rU   r•   r—   rV   r¢   rW   rª   Úincrement_row_result_totalr´   Úappend_error_rowÚappend_failed_rowr   r  r  r   Úappend_invalid_rowr  r   r  Úreport_skippedÚappend_row_resultrÿ   )r4   rû   r�   rž   rœ   r,  rY   rŸ   r.  r    rŠ   ÚiÚdata_rowr„   r  s                  r)   r)  zResource.import_data_innerb  sæ  € ð )�×&Ñ&Ó(Ó*ˆØ"×3Ñ3Ó5ˆÔÜ ›LˆÔØ×3Ñ3Ó5ˆð	>Ü,Ð-?À}ÔUñ 6Ø"�×"Ñ" 7Ñ5¨fÒ5÷6à×(Ñ(¨¯©Ô9ð Ÿ*™*×:Ñ:¸4ÀÓIˆô   ›LˆÔáØ×&Ñ& w§¡Ô7ä$ W¨aÓ0ó I	5‰KˆAˆxÜœc '§/¡/°8Ó<Ó=ˆCÜ,Ø"Ò>¨4¯:©:×+>Ñ+>Ð'>Àmôñ ð —‘à#*Ø.@Ø&'ñôð -˜TŸ_™_ØØ#ñð ñ�
÷ð �z‰z×"Ó"ô �t×,Ñ,Ó-°·±×1FÑ1FÒFÜ4Ø*°-ôñ 	ð ×(Ñ(Ø.Ø#Ø(Ø'+§z¡z×'<Ñ'<Ø#)ð )ô ÷	ô �t×,Ñ,Ó-°·±×1FÑ1FÒFÜ4Ø*°-ôñ 	ð ×(Ñ(Ø.Ø#Ø(Ø'+§z¡z×'<Ñ'<Ø#)ð )ô ÷	ô �t×,Ñ,Ó-°·±×1FÑ1FÒFÜ4Ø*°-ôñ ð ×(Ñ(Ø.°¸Èfð )ô ÷ð ×-Ñ-¨jÔ9à× Ò Ø×'Ñ'¨¨3°
×0AÑ0AÔBÙ&Ø×,Ñ,¨S°*×2CÑ2CÀAÑ2FÔGÙÜ$×0Ñ0Ø"×)Ñ)¨"Ñ-×3Ñ3¸AÀ3ôð ð ×,Ò,Ø×)Ñ)¨!¨S°*×2MÑ2MÔNÙ&Ø×,Ñ,¨S°*×2MÑ2MÔNÙÜ$×0Ñ0Ø"×3Ñ3¸AÀ3ôð ð ×&Ñ&¬)×*DÑ*DÒDØ—:‘:×,Ô,à×(Ñ(¨Ö4ðSI	5ðV �:‰:×Òä,Ð-?À}ÔUñ 	Ø× Ñ Ø&¨°Àfð !ô ð × Ñ Ø&¨°Àfð !ô ð × Ñ Ø&¨°Àfð !ô ÷	ð	>Ü,Ð-?À}ÔUñ =Ø!�×!Ñ! '¨6Ñ<°VÒ<÷=ð
 ˆ÷Y6ñ 6ûô ò 	>Ø×$Ñ$ V¨Q°×=Ò=ûð	>ú÷ñ ú÷(	ñ 	ú÷	ñ 	ú÷ñ ú÷B	ð 	ú÷=ð
 ˆûô ò 	>Ø×$Ñ$ V¨Q°×=Ð=àˆûð	>ús£   ÁR ÁRÁ-#R Ä1*R8Æ3+SÈ+SÊSÐA S,ÑT Ñ"S8Ñ7T ÒRÒR Ò	R5ÒR0Ò0R5Ò8S	ÓS	ÓS	ÓS)	Ó,S5Ó8TÓ=T ÔT Ô	T,ÔT'Ô'T,c                 ó$   — | j                  d«      S )NÚimport_order©Ú_get_ordered_field_namesr[   s    r)   rÓ   zResource.get_import_orderß  ó   € Ø×,Ñ,¨^Ó<Ð<r+   c                 ó$   — | j                  d«      S )NÚexport_orderrD  r[   s    r)   Úget_export_orderzResource.get_export_orderâ  rF  r+   c                  ó   — y)zØ
        Override to add additional logic. Does nothing by default.

        :param queryset: The queryset for export.

        :param \**kwargs:
            Metadata which may be associated with the export.
        NrQ   ©r4   ÚquerysetrY   s      r)   Úbefore_exportzResource.before_exportå  rý   r+   c                  ó   — y)a  
        Override to add additional logic. Does nothing by default.

        :param queryset: The queryset for export.

        :param dataset: A ``tablib.Dataset``.

        :param \**kwargs:
            Metadata which may be associated with the export.
        NrQ   )r4   rL  rû   rY   s       r)   Úafter_exportzResource.after_exportð  rÄ   r+   c                 ó   — |S )zî
        Override to filter an export queryset.

        :param queryset: The queryset for export.

        :param \**kwargs:
            Metadata which may be associated with the export.

        :returns: The filtered queryset.
        rQ   rK  s      r)   Úfilter_exportzResource.filter_exportý  s	   € ð ˆr+   c                 ó¶   — | j                  |«      }|j                  |«      }t        |«      r|}nt        | |d «      }|� ||«      S  |j                  |fi |¤ŽS r/   )r€   Úget_dehydrate_methodÚcallablerk   rJ   )r4   r~   r6   rY   r   Údehydrate_methodÚmethods          r)   Úexport_fieldzResource.export_field
  sg   € Ø×(Ñ(¨Ó/ˆ
Ø ×5Ñ5°jÓAÐäÐ$Ô%Ø%‰Fä˜TÐ#3°TÓ:ˆFàÐÙ˜(Ó#Ð#Øˆu�|‰|˜HÑ/¨Ñ/Ð/r+   c                 ó¬   — |r|n| j                   }g }| j                  «       }|D ],  }||v sŒ| j                  |«      }|€Œ|j                  |«       Œ. |S r/   )r   rI  Ú_select_fieldr@   )r4   Úselected_fieldsÚfields_Úexport_fieldsrH  r   r~   s          r)   Úget_export_fieldszResource.get_export_fields  se   € Ù%4‘/¸$¿+¹+ˆØˆØ×,Ñ,Ó.ˆØ&ò 	0ˆJØ˜WÒ$Ø×*Ñ*¨:Ó6�ØÑ$Ø!×(Ñ(¨Õ/ð		0ð
 Ðr+   c                 ór   — | j                  |«      }|D �cg c]  } | j                  ||fi |¤Ž‘Œ c}S c c}w r/   )r]  rW  )r4   r6   rZ  rY   r\  r~   s         r)   Úexport_resourcezResource.export_resource"  s;   € Ø×.Ñ.¨Ó?ˆØJWÖXÀÐ!�×!Ñ! %¨Ñ<°VÓ<ÒXÐXùÒXs   –4c                 óz   — | j                  |«      }|D �cg c]  }|sŒt        |j                  «      ‘Œ c}S c c}w r/   )r]  r   rˆ   )r4   rZ  r\  r~   s       r)   Úget_export_headerszResource.get_export_headers&  s3   € Ø×.Ñ.¨Ó?ˆØ:GÖQ°Ê5”	˜%×+Ñ+Õ,ÒQÐQùÒQs   –8ž8c                 ó"   — | j                  «       S r/   )rI   r[   s    r)   Úget_user_visible_fieldsz Resource.get_user_visible_fields*  s   € Ø×%Ñ%Ó'Ð'r+   c              #   ó¦  K  — t        |t        «      s|E d {  –—†  y |j                  rx|j                  j                  s|j	                  d«      }t        || j                  «       «      }t        |j                  «      D ]  }|j                  |dz   «      E d {  –—†  Œ  y |j                  | j                  «       ¬«      E d {  –—†  y 7 Œ²7 Œ27 Œ	­w)Nr¥   r   )rp   )rÝ   r   Ú_prefetch_related_lookupsÚqueryÚorder_byr   rq   ÚrangeÚ	num_pagesÚget_pageÚiterator)r4   rL  Ú	paginatorÚindexs       r)   Úiter_querysetzResource.iter_queryset-  s»   è ø€ Ü˜(¤HÔ-Ø×ÑØ×/Ò/ð —>‘>×*Ò*ð $×,Ñ,¨TÓ2�Ü! (¨D×,?Ñ,?Ó,AÓBˆIÜ˜y×2Ñ2Ó3ò 9�Ø$×-Ñ-¨e°a©iÓ8×8Ñ8ñ9ð  ×(Ñ(°D×4GÑ4GÓ4IÐ(ÓJ×JÑJð  øð 9øàJús4   ‚C˜C™BCÂCÂ*CÃCÃCÃCÃCc                 óŠ  —  | j                   |fi |¤Ž |€| j                  «       } | j                  |fi |¤Ž}|j                  dd«      }| j	                  |¬«      }t        j                  |¬«      }| j                  |«      D ](  } | j                  |fd|i|¤Ž}|j                  |«       Œ*  | j                  ||fi |¤Ž |S )zŒ
        Exports a resource.

        :param queryset: The queryset for export (optional).

        :returns: A ``tablib.Dataset``.
        Nr\  )rZ  )r6  rZ  )rM  Úget_querysetrQ  r  ra  ÚtablibÚDatasetrn  r_  r@   rO  )r4   rL  rY   r\  r6  rû   rØ   Úrs           r)   rJ   zResource.export>  sÕ   € ð 	ˆ×Ñ˜8Ñ. vÒ.àÐØ×(Ñ(Ó*ˆHØ%�4×%Ñ% hÑ9°&Ñ9ˆØŸ
™
 ?°DÓ9ˆØ×)Ñ)¸-Ð)ÓHˆÜ—.‘.¨Ô1ˆà×%Ñ% hÓ/ò 	ˆCØ$�×$Ñ$ SÑR¸-ÐRÈ6ÑRˆAØ�N‰N˜1Õð	ð 	ˆ×Ñ˜( GÑ6¨vÒ6àˆr+   c                 óÆ   — || j                   v r| j                   |   S | j                   j                  «       D ]  \  }}||j                  k(  sŒ|c S  t        d|› d�«       y )Nz,cannot identify field for export with name 'ú')r   r{   rˆ   r   )r4   Útarget_field_namer   r~   s       r)   rY  zResource._select_fieldW  sh   € à §¡Ñ+Ø—;‘;Ð0Ñ1Ð1à!%§¡×!2Ñ!2Ó!4ò 	ÑˆJ˜Ø  E×$5Ñ$5Ó5Ø’ð	ô
 	Ð;Ð<MÐ;NÈaÐPÕQr+   c                 óª  — t        t        | j                  |«      xs d«      }|t        t        | j                  d«      xs d«      z   }g }|D �cg c]  }||vsŒ|j                  |«      ‘Œ c} g }| j                  j                  «       D ]*  \  }}||vsŒ|j                  |vsŒ|j                  |«       Œ, t        |«      t        |«      z   S c c}w )zP
        Return a list of field names, respecting any defined ordering.
        rQ   r   )Útuplerk   rd   r@   r   r{   rˆ   )	r4   Úorder_fieldÚorder_fieldsÚdefined_fieldsÚorderrL   Údeclared_fieldsr   r~   s	            r)   rE  z!Resource._get_ordered_field_namesc  sÃ   € ô
 œW T§Z¡Z°Ó=ÒCÀÓDˆà%¬¬g°d·j±jÀ(Ó.KÒ.QÈrÓ(RÑRˆàˆØ"0ÖC˜Q°A¸U²Nˆ�‰�a�ÓCØˆØ!%§¡×!2Ñ!2Ó!4ò 	3ÑˆJ˜Ø Ò&¨5×+<Ñ+<ÀEÒ+IØ×&Ñ& zÕ2ð	3ô �U‹|œe OÓ4Ñ4Ð4ùò 	Ds   Á	CÁCc                 ó&   — |j                  dd«      S )Nrœ   F©r  rX   s     r)   r¹   zResource._is_using_transactionst  s   € Ø�z‰zÐ.°Ó6Ð6r+   c                 ó&   — |j                  dd«      S )Nr�   Fr  rX   s     r)   rº   zResource._is_dry_runw  s   € Ø�z‰z˜) UÓ+Ð+r+   c                 ó$  — g }g }g }| j                  «       dgk(  ry| j                  «       D ]@  }|| j                  vr|j                  |«       Œ#|j                  | j                  |   «       ŒB |r0t        j                  t        ddj                  |«      z  «      «      ‚|D ]9  }|r|j                  |vsŒt        |j                  «      }|j                  |«       Œ; |r0t        j                  t        ddj                  |«      z  «      «      ‚y)ay  
        Provides a safety check with a meaningful error message for cases where
        the ``import_id_fields`` declaration contains a field which is not in the
        dataset.  For most use-cases this is an error, so we detect and raise.
        There are conditions, such as 'dynamic fields' where this does not apply.
        See issue 1834 for more information.
        ÚidNzfThe following fields are declared in 'import_id_fields' but are not present in the resource fields: %sz, zcThe following fields are declared in 'import_id_fields' but are not present in the file headers: %s)	r‡   r   r@   r   Ú
FieldErrorÚ_Újoinrˆ   r   )r4   r6  r‹   Úmissing_fieldsÚmissing_headersr   r~   Úcols           r)   r5  z Resource._check_import_id_fieldsz  s&  € ð ÐØˆØˆà×$Ñ$Ó&¨4¨&Ò0àà×3Ñ3Ó5ò 	AˆJØ §¡Ñ,Ø×%Ñ% jÕ1à ×'Ñ'¨¯©°JÑ(?Õ@ð		Añ Ü×'Ñ'ÜðAà—i‘i Ó/ñ0óóð ð &ò 	,ˆEÙ˜e×/Ñ/°wÒ>ä˜U×.Ñ.Ó/�Ø×&Ñ& sÕ+ð		,ñ Ü×'Ñ'Üð>à—i‘i Ó0ñ1óóð ð r+   r/   )NN)NT)F)FFNFF)BrM   rN   rO   Ú__doc__r7   rP   r\   r^   r`   rb   rg   rl   rq   ry   r€   r…   r‰   rŽ   r‡   r’   r—   r¢   rª   rµ   r¾   r»   r·   r¼   rÉ   rÇ   rÈ   rÑ   rI   rÙ   r×   râ   rä   r÷   rù   rü   rÿ   r  r  r	  r  r™   r"  r0  r)  rÓ   rI  rM  rO  rQ  rW  r]  r_  ra  rc  rn  rJ   rY  rE  r¹   rº   r5  rQ   r+   r)   rS   rS   F   s¸  „ ñò
#ð$ ñó ðð ñó ðð ñó ðð ñó ðð ñ'ó ð'ò/ò)ò*ò	
ó$ò1ò-ò+òPð RVó*ð( RVó*ó**ð$ HLó*ò<:ò<
òòò<ò.òó4ò6ò
2ò*ò4>ò6óDòLTò	òò	òó
@òó0òfðV ØØØ!Ø&+óJòX{òz=ò=ò	òòò0ó	óYóRò(òKó"ò2
Rò5ò"7ò,ó,r+   rS   )Ú	metaclassc                   ó–  — e Zd ZdZeZi dd“dd“dd“dej                  “dej                  “d	ej                  “d
ej                  “dej                  “dej                  “dej                  “dej                  “dej                  “dej                  “dej                  “dej                  “dej                  “dej                  “ej                  ej                  ej                  ej                  ej                   dœ¥Zed„ «       Zed„ «       Zeej*                  fd„«       Zed„ «       Zed„ «       Zd„ Zd d„Zd„ Zed„ «       Zy)!ÚModelResourcezH
    ModelResource is Resource subclass for handling Django models.
    ÚManyToManyFieldÚget_m2m_widgetÚOneToOneFieldÚget_fk_widgetr   Ú	CharFieldÚDecimalFieldÚDateTimeFieldÚ	DateFieldÚ	TimeFieldÚDurationFieldÚ
FloatFieldÚIntegerFieldÚPositiveIntegerFieldÚBigIntegerFieldÚPositiveBigIntegerFieldÚPositiveSmallIntegerFieldÚSmallIntegerFieldÚSmallAutoField)Ú	AutoFieldÚBigAutoFieldÚNullBooleanFieldÚBooleanFieldÚ	JSONFieldc                 ó^   — t        j                  t        j                  t	        |«      ¬«      S )z.
        Prepare widget for m2m field
        r'   )Ú	functoolsÚpartialr   rß   r!   )rK   r~   s     r)   rŽ  zModelResource.get_m2m_widgetÉ  s(   € ô
 × Ñ Ü×$Ñ$Ô,=¸eÓ,Dô
ð 	
r+   c                 óª   — t        |«      }t        |«      xr | j                  j                  }t	        j
                  t        j                  ||¬«      S )z6
        Prepare widget for fk and o2o fields
        )r(   Úuse_natural_foreign_keys)r!   r*   rd   r¨  r¥  r¦  r   ÚForeignKeyWidget)rK   r~   r(   r¨  s       r)   r�  zModelResource.get_fk_widgetÒ  sP   € ô " %Ó(ˆô $ EÓ*ÒQ¨s¯y©y×/QÑ/Qð 	!ô × Ñ Ü×$Ñ$ØØ%=ô
ð 	
r+   c                 ó4  — |}d}t        t        |dd«      «      r|j                  «       }|| j                  v r3| j                  |   }t	        |t
        «      r t        | |«      |«      }|S |j                  j                  D ]W  }|j                  | j                  v sŒ| j                  |j                     }t	        |t
        «      r t        | |«      |«      } n 	 ddl	m
} t	        ||«      rt        j                  S |S # t        $ r  G d„ d«      }Y Œ3w xY w)a	  
        Returns the widget that would likely be associated with each
        Django type.

        Includes mapping of Postgres Array field. In the case that
        psycopg2 is not installed, we consume the error and process the field
        regardless.
        r;   Úget_internal_typeNr   )Ú
ArrayFieldc                   ó   — e Zd Zy)ú:ModelResource.widget_from_django_field.<locals>.ArrayFieldN)rM   rN   rO   rQ   r+   r)   r¬  r®    s   „ Ør+   r¬  )rT  rk   r«  ÚWIDGETS_MAPrÝ   Ústrr}   Ú__mro__rM   Údjango.contrib.postgres.fieldsr¬  r  r   ÚSimpleArrayWidget)rK   rL   ÚdefaultrŸ   Úinternal_typeÚ
base_classr¬  s          r)   Úwidget_from_django_fieldz&ModelResource.widget_from_django_fieldä  s  € ð ˆØˆÜ”G˜AÐ2°DÓ9Ô:Ø×/Ñ/Ó1ˆMà˜CŸO™OÑ+Ø—_‘_ ]Ñ3ˆFÜ˜&¤#Ô&Ø-œ  fÓ-¨aÓ0�ð. ˆð#  Ÿk™k×1Ñ1ò �
Ø×&Ñ&¨#¯/©/Ò9Ø Ÿ_™_¨Z×-@Ñ-@ÑA�FÜ! &¬#Ô.Ø!5¤¨¨fÓ!5°aÓ!8˜ÙððÝEô ˜!˜ZÔ(Ü×0Ñ0Ð0àˆøô ò ÷ó ðús   ÃD ÄDÄDc                 ó0  — i }| j                   j                  r7| j                   j                  j                  |i «      }|j                  |«       t	        |j
                  t        j                  «      r"|j                  du r|j                  dddœ«       |S )z=
        Returns widget kwargs for given field_name.
        T)Úcoerce_to_stringÚallow_blank)	rd   r   r  rÖ   Ú
issubclassr}   r   r‘  Úblank)rK   r   Údjango_fieldÚwidget_kwargsÚ
cls_kwargss        r)   Úwidget_kwargs_for_fieldz%ModelResource.widget_kwargs_for_field  s}   € ð
 ˆØ�9‰9×ÒØŸ™×*Ñ*×.Ñ.¨z¸2Ó>ˆJØ× Ñ  Ô,ä�|×-Ñ-¬v×/?Ñ/?Ô@Ø×"Ñ" dÑ*à× Ñ °dÈ4Ñ!PÔQØÐr+   c           	      ó  — | j                  |«      }| j                  ||«      }|}|}t        |t        «      r$d|vr | j                  j
                  s
|dz  }d|d<   | j                  || |di |¤Ž||j                  ¬«      }|S )zU
        Returns a Resource Field instance for the given Django model field.
        Ú__Ú_idTÚ	key_is_id)rÍ   rˆ   rÞ   Úreadonlyr´  rQ   )r·  rÀ  rÝ   r   rd   r¨  ÚDEFAULT_RESOURCE_FIELDr´  )	rK   r   r½  rÅ  ÚFieldWidgetr¾  rÍ   rˆ   r~   s	            r)   Úfield_from_django_fieldz%ModelResource.field_from_django_field  sž   € ð ×2Ñ2°<Ó@ˆØ×3Ñ3°JÀÓMˆàˆ	Ø ˆô �|¤ZÔ0Ø˜KÑ'Ø—I‘I×6Ò6à˜ÑˆIØ)-ˆM˜+Ñ&à×*Ñ*ØØ#ÙÑ/ Ñ/ØØ ×(Ñ(ð +ó 
ˆð ˆr+   c                 ó^   — | j                   j                  j                  j                  «       S )z…
        Returns a queryset of all objects for this model. Override this if you
        want to limit the returned queryset.
        )rd   r(   r&   rò   r[   s    r)   rp  zModelResource.get_queryset<  s#   € ð
 �z‰z×Ñ×'Ñ'×+Ñ+Ó-Ð-r+   Nc                 ó6   — | j                   j                  «       S )z1
        Initializes a new Django model.
        )rd   r(   rƒ   s     r)   r…   zModelResource.init_instanceC  s   € ð �z‰z×ÑÓ!Ð!r+   c                 ó®  — | j                  |«      }|s­t        d„ |j                  D «       «      r�| j                  «       }t        |   }|j
                  j                  t        «       | j                  j                  g«      }|r;|j                  «       }	 |D ]  }	|j                  |	«       Œ 	 |j                  «        yyyy# |j                  «        w xY w)zH
        Reset the SQL sequences after new objects are imported
        c              3   óV   K  — | ]!  }|j                   t        j                  k(  –— Œ# y ­wr/   )r  r   r  )ré   rs  s     r)   rë   z-ModelResource.after_import.<locals>.<genexpr>O  s$   è ø€ ò 
Ø;<ˆA�M‰MœY×6Ñ6Õ6ñ
ùs   ‚')N)rº   ÚanyÚrowsrg   r   ÚopsÚsequence_reset_sqlr   rd   r(   ÚcursorÚexecuteÚclose)
r4   rû   rŸ   rY   r�   r.  r/  Úsequence_sqlrÑ  Úlines
             r)   rÿ   zModelResource.after_importI  sÈ   € ð
 ×"Ñ" 6Ó*ˆÙœ3ñ 
Ø@FÇÁô
ô 
ð !×7Ñ7Ó9ˆMÜ$ ]Ñ3ˆJØ%Ÿ>™>×<Ñ<Ü“
˜TŸZ™Z×-Ñ-Ð.óˆLñ Ø#×*Ñ*Ó,�ð#Ø ,ò -˜ØŸ™ tÕ,ñ-ð —L‘L•Nð ð
ˆwøð —L‘L•Nús   ÂC ÃCc                 ór   — t        | j                  d«      r| j                  j                  S | j                  S )NÚname)r%   rd   r×  rM   )rK   s    r)   Úget_display_namezModelResource.get_display_name_  s(   € ä�3—9‘9˜fÔ%Ø—9‘9—>‘>Ð!Ø�|‰|Ðr+   r/   )rM   rN   rO   r‰  r   rÆ  r   Ú
CharWidgetÚDecimalWidgetÚDateTimeWidgetÚ
DateWidgetÚ
TimeWidgetÚDurationWidgetÚFloatWidgetÚIntegerWidgetÚBooleanWidgetÚ
JSONWidgetr¯  rP   rŽ  r�  ÚWidgetr·  rÀ  rÈ  rp  r…   rÿ   rØ  rQ   r+   r)   rŒ  rŒ  ©  sö  „ ñð #ÐðØÐ+ðà˜ðð 	�oðð 	�W×'Ñ'ð	ð
 	˜×-Ñ-ðð 	˜×/Ñ/ðð 	�W×'Ñ'ðð 	�W×'Ñ'ðð 	˜×/Ñ/ðð 	�g×)Ñ)ðð 	˜×-Ñ-ðð 	 × 5Ñ 5ðð 	˜7×0Ñ0ðð 	" 7×#8Ñ#8ðð 	$ W×%:Ñ%:ðð  	˜W×2Ñ2ð!ð" 	˜'×/Ñ/ð#ð$ ×*Ñ*Ø×-Ñ-Ø#×1Ñ1Ø×-Ñ-Ø×'Ñ'ò-€Kð2 ñ
ó ð
ð ñ
ó ð
ð" Ø18·±ò (ó ð(ðT ñó ðð ñó ðò8.ó"ò#ð, ñó ñr+   rŒ  c                 óv   — d| i}t        dt        f|«      }| j                  dz   }d|i}t        } |||f|«      S )zN
    Factory for creating ``ModelResource`` class for given Django model.
    r(   ÚMetarS   )ÚtypeÚobjectrM   r   )r(   Úresource_classÚattrsrå  Ú
class_nameÚclass_attrsrŠ  s          r)   Úmodelresource_factoryrì  f  sS   € ð �eÐ€EÜ�œ˜	 5Ó)€Dà—‘ *Ñ,€Jð 	�ð€Kô *€IÙ�Z .Ð!2°KÓ@Ð@r+   )@r¥  ÚloggingÚcollectionsr   r®   r   rF   r   Úwarningsr   rq  r   Údjango.confr   Údjango.core.exceptionsr	   r
   Údjango.core.management.colorr   Údjango.core.paginatorr   Ú	django.dbr   r   Údjango.db.modelsr   Údjango.db.models.fields.relatedr   Údjango.db.models.queryr   Údjango.db.transactionr   r   Údjango.utils.encodingr   Údjango.utils.safestringr   Údjango.utils.translationr   r„  r;   r   r   Údeclarativer   r   r   Úresultsr   r   r   Úutilsr    r!   Ú	getLoggerrM   rÎ   Ú
addHandlerÚNullHandlerr*   r-   rS   rŒ  rì  rQ   r+   r)   ú<module>r     s½   ðÛ Û Ý #Ý Ý Ý ã Ý -Ý  ß HÝ 1Ý +ß )Ý #Ý 6Ý +ß JÝ +Ý -Ý 6ç !ß HÝ ß -Ñ -ß Aà	ˆ×	Ñ	˜8Ó	$€à × Ñ Ð%�'×%Ñ%Ó'Ô (ò÷Jñ Jô6`Ð-õ `ôF#z�HÐ(Aõ zðz 1>ô Ar+   