+
    &j.                     :   ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RI
HtHt ^ RIt^ RIHt  ^ RIt^ RIHt ^ RIHt ^ RIHtHtHt ^ R	IHt ^ R
IHtHtH t  ]PB                  ! R4      t" ! R R]#4      t$R t%R t&R t' ! R R]PP                  PR                  4      t* ! R R]PP                  PV                  4      t,R t- ! R R]PP                  P\                  4      t/ ! R R]4      t0 ! R R]4      t1R#   ] d    ]'       g   ^ RIt Li ; i)    N)	lru_cache)chain)TYPE_CHECKINGLiteral)AbstractBufferedFile)AsyncFileSystem)DEFAULT_CALLBACK)
filesystemopensplit_protocol)AsyncFileSystemWrapper)
isfilelikemerge_offset_rangesother_pathszfsspec.referencec                   8   a a ] tR t^"t oV 3R ltR tRtVtV ;t# )ReferenceNotReachablec                <   < \         SV `  ! V!   Wn        W n        R # N)super__init__	referencetarget)selfr   r   args	__class__s   &&&*x/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/fsspec/implementations/reference.pyr   ReferenceNotReachable.__init__#   s    $"    c                :    R V P                    RV P                   2# )zReference "z" failed to fetch target r   r   r   s   &r   __str__ReferenceNotReachable.__str__(   s    T^^,,Edkk]SSr   r    )	__name__
__module____qualname____firstlineno__r   r"   __static_attributes____classdictcell____classcell__r   __classdict__s   @@r   r   r   "   s     
T Tr   r   c                 F    \        \        V P                  4       4      4      # r   )nextitervalues)ds   &r   _firstr2   ,   s    QXXZ !!r   c                     VP                  V 4      p\        V\        \        34      '       dQ   \        V^ ,          \        4      '       d2   V^ ,          '       d   \        V^ ,          4      ^ ,          # V^ ,          # R# R# r   N)get
isinstancelisttuplestrr   )path
referencesrefs   && r   _prot_in_referencesr=   0   s_    
..
C#e}%%*SVS*A*A,/FF~c!f%a(>A> +B%r   c                     \        V \        4      '       d   \        W4      V ./# / pV  F/  p\        W14      pVP                  V. 4      P	                  V4       K1  	  V# r   )r6   r9   r=   
setdefaultappend)pathsr;   outr:   protocols   &&   r   _protocol_groupsrD   6   sZ    %#E6@@
C&t8x$++D1  Jr   c                   &   a  ] tR t^@t o R tRtV tR# )RefsValuesViewc              #  *  "   V P                   P                  P                  4        F)  p\        P                  ! V4      P                  4       x  K+  	  V P                   P                  P                  4        R j  xL
  V P                   P                  4        Fo  pV P                   P                  V4      p\        V4      ^ 8X  d   V P                   VR,           ,          x  KL  V P                   P                  V4       R j  xL
  Kq  	  R #  L L5i)N/0)_mapping	zmetadatar0   jsondumpsencode_itemslistdir_get_chunk_sizeslen_generate_all_records)r   valfieldchunk_sizess   &   r   __iter__RefsValuesView.__iter__A   s     ==**113C**S/((** 4==''..000]]**,E--88?K;1$mmEDL11}}::5AAA - 	1 Bs%   A9D;D<BDDDD Nr$   r%   r&   r'   rV   r(   r)   r,   s   @r   rF   rF   @   s     	B 	Br   rF   c                   &   a  ] tR t^Mt o R tRtV tR# )RefsItemsViewc                z    \        V P                  P                  4       V P                  P                  4       4      # r   )ziprI   keysr0   r!   s   &r   rV   RefsItemsView.__iter__N   s)    4==%%')=)=)?@@r   rX   NrY   rZ   s   @r   r\   r\   M   s     A Ar   r\   c                     ^ p^p\        V RRR1,          VRRR1,          4       F  w  rEW$V,          ,          pW5,          pK  	  V# )r   N)r^   )idxsizesrS   multiss   &&    r   ravel_multi_indexrh   R   sH    
CDC"IuTrT{+4x	 , Jr   c                     a  ] tR t^[t o Rt]R 4       t]R 4       tRV 3R lR lltR t	R t
]R R	 l4       tR
 tR!R ltR tR tR tR tR tR tR tR tR tR t]R 4       tR tR"R ltR"R ltR tR tR tR t Rt!V t"R# )#LazyReferenceMappera[  This interface can be used to read/write references from Parquet stores.
It is not intended for other types of references.
It can be used with Kerchunk's MultiZarrToZarr method to combine
references into a parquet store.
Examples of this use-case can be found here:
https://fsspec.github.io/kerchunk/advanced.html?highlight=parquet#parquet-storagec                    ^ RI pV# r4   )numpy)r   nps   & r   rm   LazyReferenceMapper.npd   s
    	r   c                    ^ RI pV# r4   )pandas)r   pds   & r   rq   LazyReferenceMapper.pdj   s
    	r   Nc                .   < V ^8  d   QhRS[ R,          /# )   engine)fastparquetpyarrow)r   )formatr,   s   "r   __annotate__ LazyReferenceMapper.__annotate__p   s      5K 5K 015Kr   c                   Wn         / V n        WPn        W`n        W@n        V P                   R,           V n        Vf   \        P                  ! R4      MTV n        V P                  P                  T;'       g    V P                   4      V n
        ^ RIHp V P                  R8X  d   V! R4      f   \        R4      h\        4       ! V P                  4      V n        \        RR7      ! V P                   4      V n        R# )	aH  

This instance will be writable, storing changes in memory until full partitions
are accumulated or .flush() is called.

To create an empty lazy store, use .create()

Parameters
----------
root : str
    Root of parquet store
fs : fsspec.AbstractFileSystem
    fsspec filesystem object, default is local filesystem.
cache_size : int, default=128
    Maximum size of LRU cache, where cache_size*record_size denotes
    the total number of references that can be loaded in memory at once.
categorical_threshold : int
    Encode urls as pandas.Categorical to reduce memory footprint if the ratio
    of the number of unique urls to total number of refs for each variable
    is greater than or equal to this number. (default 10)
engine: Literal["fastparquet","pyarrow"]
    Engine choice for reading parquet files. (default is "fastparquet")
z/{field}/refs.{record}.parqNfile)	find_specrw   z)engine choice `pyarrow` is not installed.i   maxsize)rootrU   
cat_threshru   
cache_sizeurlfsspecr
   fsunstrip_protocolout_rootimportlib.utilr}   ImportErrorr   rO   _key_to_record)r   r   r   r   r   categorical_thresholdru   r}   s   &&&&&&& r   r   LazyReferenceMapper.__init__p   s    B 	/$99<</1z&##F+r001F1FTYYG,;;)#	)(<(DIJJ !{4<<0'5d6I6IJr   c                l    VR9   d$   V P                  4        V P                  V,          # \        V4      h)rN   )rN   record_sizerJ   )setup__dict__AttributeErrorr   items   &&r   __getattr__LazyReferenceMapper.__getattr__   s.    99JJL==&&T""r   c                n  a  / S n         S P                  P                  R P                  S P                  R.4      4      S P                   R&   \
        P                  ! S P                   R,          4      pVR,          S n        VR,          S n        \        S P                  R7      V 3R l4       pVS n        R# )/
.zmetadatar   metadatar~   c                ~  < SP                   P                  WR7      p\        P                  ! SP                  P                  V4      4      p SP                  P                  VSP                  R7      pVP                   Uu/ uF  qUWE,          P                  4       bK  	  ppV# u upi   \         d    Rp T# i ; i)zcached parquet file loader)rT   record)ru   N)r   rx   ioBytesIOr   cat_filerq   read_parquetru   columnsto_numpyOSError)rT   r   r:   datadfcrefsr   s   &&     r   	open_refs,LazyReferenceMapper.setup.<locals>.open_refs   s     88???>D::dgg..t45DWW))$t{{)C57ZZ@Z25>>++Z@ K A Ks$   5B+ B&"B+ &B+ +B<;B<N)rN   r   r   joinr   rK   loadsr   rJ   r   r   r   )r   metr   s   f  r   r   LazyReferenceMapper.setup   s    $(GG$4$4HHdii./%
L! jj\23}-Z 
4??	+		 
,		 #r   c                   R/ RV/pVf.   \         P                  P                  ! V 3/ T;'       g    / B w  r VP                  V 4      '       d   VP	                  V RR7       VP                  V RR7       VP                  RP                  V R.4      \        P                  ! V4      P                  4       4       \        W3/ VB # )a  Make empty parquet reference set

First deletes the contents of the given directory, if it exists.

Parameters
----------
root: str
    Directory to contain the output; will be created
storage_options: dict | None
    For making the filesystem to use for writing is fs is None
fs: FileSystem | None
    Filesystem for writing
record_size: int
    Number of references per parquet file
kwargs: passed to __init__

Returns
-------
LazyReferenceMapper instance
r   r   T	recursiveexist_okr   r   )r   core	url_to_fsexistsrmmakedirspiper   rK   rL   rM   rj   )r   storage_optionsr   r   kwargsr   s   &&&&, r   createLazyReferenceMapper.create   s    , 2}k::{{,,TMo6K6KMHB99T??EE$$E'
D4(
$-.

30F0F0HI"46v66r   c                >    R V P                    4       p\        V4      # )zList top-level directoriesc              3      "   T F6  qP                  R 4      '       d   K  VP                  R^4      ^ ,          x  K8  	  R# 5i).zr   N)
startswithrsplit.0ps   & r   	<genexpr>.LazyReferenceMapper.listdir.<locals>.<genexpr>   s0     V^<<PTCU#a ##^s
   A !A )rJ   set)r   dirss   & r   rO   LazyReferenceMapper.listdir   s    VT^^V4yr   c                x   VP                  R4      pV'       d
   VR,           MRpV P                  4       pV Uu. uF6  pVP                  V4      '       g   K  RVP                  V4      9  g   K4  VNK8  	  ppV'       Ed&   \	        R.R V P
                   4       R V P                   4       4       Uu0 uF6  pVP                  V4      '       g   K  RVP                  V4      9  g   K4  VkK8  	  ppVRJ d   VP                  V4       \        V4      # V U	u. uF  p	RV	RR	R
^ /NK  	  p
p	V U	u. uF\  p	RT	RRR
\        WP
                  9   d(   \        P                  ! V P
                  V	,          4      MV P                  V	,          4      /NK^  	  pp	\        W,           R R7      # Tp\        V P
                   U	u. uF   qP                  V R24      '       g   K  V	NK"  	  up	V P                   U	u. uF   qP                  V R24      '       g   K  V	NK"  	  up	,           4      pV U	u. uF\  p	RT	RRR
\        WP
                  9   d(   \        P                  ! V P
                  V	,          4      MV P                  V	,          4      /NK^  	  pp	V P                  V4      pVRJ d   \        V4      \        V4      ,           # V P                  V4      p\!        W4       U	Uu. uF%  w  rV^ ,          '       g   K  RV	RRR
VR,          /NK'  	  pp	pVV,           # u upi u upi u up	i u up	i u up	i u up	i u up	i u upp	i )zShortcut file listingsr    r   c              3   $   "   T F  qx  K  	  R # 5ir   rX   r   names   & r   r   )LazyReferenceMapper.ls.<locals>.<genexpr>   s     5ndTn   c              3   $   "   T F  qx  K  	  R # 5ir   rX   r   s   & r   r   r      s     2kdTkr   Fr   type	directorysizer|   c                     V R ,          # )r   rX   )rg   s   &r   <lambda>(LazyReferenceMapper.ls.<locals>.<lambda>  s    AfIr   keyrb   )rstriprO   r   lstripr   rJ   rN   updatesortedrQ   rK   rL   r   _keys_in_fieldr7   rR   r^   )r   r:   detailpathdashdirnamesr1   r   fothersr   dirinfofileinforT   r_   recsrecrecinfos   &&&              r   lsLazyReferenceMapper.ls   s%   {{3!%4#:2<<> 
||H% *-QXXh5G*G A 	 

 4 !N5dnn52dkk2A
 <<)  /2(9K.K    d#f~%RVWRV$fk61ERVGW # #D DFC>>1 

4>>$#78![[. #   ',2EFF"nnLnd4&
0KTTnL $K$qz/JttKL
 
  ~~- JJt~~d34T*  	 
 ""5)U?<$t*,,))%0 !_
,	1vv <VT6663r7;, 	 

 '!!w
 X MK
"
s[   LL/L2LL(LL-A"L":L'L'0L,
L,
'A"L1L64L6c                l   WP                   9   d   V P                   V,          # WP                  9   d6   \        P                  ! V P                  V,          4      P	                  4       # RV9  g   V P                  V4      '       d   \        V4      hVP                  R^4      w  r#V P                  V4      w  rEpV P                   P                  W$3/ 4      P                  VR4      pVf   \        hV'       d   V# V^ 8X  d   R#  V P                  W$4      p. R	Op
T
 Uu. uF  qT9   d   Y,          T,          MRNK  	  ppTR
,          pTe   T# T^ ,          f   \        R4      hTR,          ^ ^ .8X  d
   TR,          # TR,          #   \        \        \        3 d   p	\        T4      T	hRp	?	ii ; iu upi )zVGet the reference for one key

Returns bytes, one-element list or three-element list.
r   FNr   z1This reference does not exist or has been deleted:      N:Nr   NNr   N)r:   offsetr   rawrb   )rN   rJ   rK   rL   rM   _is_metaKeyErrorr   r   r5   r   
ValueError	TypeErrorFileNotFoundError)r   r   rT   _r   ri
chunk_sizemayber   excr   r   	selectionr   s   &&            r   _load_one_key!LazyReferenceMapper._load_one_key,  s   
 ++;;s##NN"::dnnS1299;;^t}}S113-::c1%!%!4!4S!9J488UC=NL1_	)>>%0D 4AHIAITWR[47	Im?JQ<NOOS>aV#R= } I'89 	)3-S(	) Js   F  F1F.F))F.c                D   VP                  R^4      w  r#V P                  V4      p\        V4      ^ 8X  d   R# VP                  R4       Uu. uF  p\	        V4      NK  	  pp\        Wd4      pWpP                  ,          pWpP                  ,          p	W\        V4      3# u upi )z3Details needed to construct a reference for one keyr   .)r   r   r   )r   rP   rQ   splitintrh   r   )
r   r   rT   chunkrU   r   	chunk_idxchunk_numberr   r   s
   &&        r   r   "LazyReferenceMapper._key_to_recordT  s    zz#q)++E2{q N%*[[%56%5SV%5	6(@!1!11,,,3{+++	 7s   Bc                B   WP                   9  dx   V P                  V R2,          p\        VR,          VR,          4       UUu. uF!  w  r4\        P                  ! W4,          4      NK#  	  pppT;'       g    ^.V P                   V&   V P                   V,          # u uppi )z6The number of chunks along each axis for a given fieldz/.zarrayshapechunks)rU   rJ   r^   mathceil)r   rT   zarrayrg   r   
size_ratios   &&    r   rP   $LazyReferenceMapper._get_chunk_sizes`  s    (((^^ugX$67F-0&BR-S-STQ		!% -S   '1&7&7QCDU#&&	s   'Bc                    V P                  W4      p\        \        VP                  4       !  4      p\	        V4      ^8X  d
   R V 4       # \	        V4      ^8X  d
   VR,          # R V 4       # )z8The references for a given parquet file of a given fieldc              3   8   "   T F  p\        V4      x  K  	  R # 5ir   r7   r   ts   & r   r   7LazyReferenceMapper._generate_record.<locals>.<genexpr>p  s     (RDGGR   r   c              3   t   "   T F.  q^,          '       g   \        VR,          4      MV^,          x  K0  	  R# 5i)r   r   Nr  r  s   & r   r   r  v  s'     Br!ttD2K15rs   68)r   r/   r^   r0   rQ   )r   rT   r   r   its   &&&  r   _generate_record$LazyReferenceMapper._generate_recordj  s^    ~~e,#t{{}%&t9>(R((Y!^; CrBBr   c              #     "   ^pV P                  V4       F  pW#,          pK  	  \        P                  ! W P                  ,          4      p\	        V4       F  pV P                  W4       Rj  xL
  K  	  R#  L
5i)zJLoad all the references within a field by iterating over the parquet filesN)rP   r  r	  r   ranger  )r   rT   nrecchr   s   &&   r   rR   )LazyReferenceMapper._generate_all_recordsx  sb     ''.BJD /yy 0 001DkF,,U;;; ";s   A+A:-A8.A:c                    \        V 4      # r   )rF   r!   s   &r   r0   LazyReferenceMapper.values  s    d##r   c                    \        V 4      # r   )r\   r!   s   &r   itemsLazyReferenceMapper.items  s    T""r   c                    \        V 4      # r   )idr!   s   &r   __hash__LazyReferenceMapper.__hash__  s    $xr   c                $    V P                  V4      # r   )r   )r   r   s   &&r   __getitem__LazyReferenceMapper.__getitem__  s    !!#&&r   c                   R V9   d   V P                  V4      '       gy   VP                  R ^4      w  r4V P                  V4      w  rVpV P                  P	                  W53/ 4      pW(V&   \        V4      V P                  8X  d   V P                  W54       R# R# \        VR4      '       d    VP                  4       P                  4       p	M)\        V\        4      '       d   VP                  4       p	MTp	WP                  V&   \        P                  ! V	4      p
/ V P                  P!                  V/ 4      CV
CV P                  V&   R# )r   to_bytesN)r   r   r   rN   r?   rQ   r   writehasattrr*  decoder6   bytesrK   r   rJ   r5   )r   r   valuerT   r  r   rf   r   subdictrS   	new_values   &&&        r   __setitem__LazyReferenceMapper.__setitem__  s   #:dmmC00::c1-LE..s3LFqkk,,e_bAGAJ7|t///

5) 0 uj))nn&--/E5))lln"KK

3I"NT^^%7%7R%@"NI"NDNN3r   c                >    V P                  R 4      ;'       g    RV 9   # )r   z/.zr   r   s   &r   r   LazyReferenceMapper._is_meta  s    ~~d#33u|3r   c                   WP                   9   d   V P                   V R# WP                  9   d   V P                  V R# R V9   d   V P                  V4      '       gy   VP                  R ^4      w  r#V P	                  V4      w  rEpV P                   P                  W$3/ 4      pRWe&   \        V4      V P                  8X  d   V P                  W$4       R# R# RV P                   V&   R# r   N)	rN   rJ   r   r   r   r?   rQ   r   r+  )r   r   rT   r   r   rf   r0  s   &&     r   __delitem__LazyReferenceMapper.__delitem__  s    ++C NN"s#cz$--"4"4::c1-#22371++00%"E!
w<4#3#33JJu- 4 $(C r   c                H   ^ RI p^ RIp^ RIpV P                  W3,          pRp	\	        V4      V P
                  8  d    V P                  W4      p	V	'       d&   V	R,          p
V	R,          pV	R,          pV	R,          pMVP                  V P
                  VP                  RR7      p
VP                  V P
                  R	R7      pVP                  V P
                  R	R7      pVP                  V P
                  VP                  RR7      pVP                  4        F  w  r\        V\        4      '       d   \        V
P                  4      R
8X  d;   V^ ,          V
P                  P                   9  d   V
P#                  V^ ,          4      p
V^ ,          W&   \	        V4      ^8  d   V^,          W&   V^,          W&   K  K  Vf   RW&   ^ W&   ^ W&   RW&   K  VP$                  P'                  V4      W&   K  	  VP)                  RV
RVRVRV/RR7      pVP*                  P-                  4       VP*                  P/                  4       ;'       g    ^,          V P0                  8  d   VR,          P3                  R
4      VR&   RRRR/pRR.pT;'       g    V P4                   RV RV R2pV P6                  P9                  T;'       g    V P4                   RV 2RR7       V P:                  R8X  d   RR/pM2V P:                  R8X  d
   RRRVRV/pM\=        V P:                   R24      hVP>                  ! V3RV P:                  RT;'       g    \A        V P6                  RR4      RRRR/VB  VPC                  4        V P                  PE                  W34       R#   \         d     ELQi ; i)r   NFr:   r   r   r   O)dtypeint64category)copyr.  utf8r   z/refs.z.parqTr   rw   write_statisticsrv   statsobject_encoding	has_nullsz not supportedru   r   compressionzstdindex)#kerchunk.dfrl   rp   rN   rQ   r   r   r   fullnanzerosr   r6   r7   r9   r=  
categoriesadd_categoriesr   	_proc_raw	DataFramer:   countnuniquer   astyper   r   mkdirsru   NotImplementedError
to_parquetgetattrclearpop)r   rT   r   base_urlr   kerchunkrm   rq   	partitionoriginalrA   offsetsrd   rawsjr   r   rD  rE  fndf_backend_kwargss   &&&&&                r   r+  LazyReferenceMapper.write  sj   KK0	y>D,,,>>%8 V$Ex(GV$EE?DGGD,,bffCG@Ehht//wh?GHHT--WH=E774++RVV37?D (GA$%%$
2Qu{{'='==!00a9E7t9q=!%aGJ#AwEH ! 
 #++//5' )* \\'t	   
 77==?bggoo/4415GF**:6BvJ '66:UO	))DMM*!E7&F(33dmm4AeW=M;;)#!3U ;[[M)!?Y! &^&DEE
	
;;	
 , 9 9tww 148		

 	
 	
  	
 	(Q  s   N N! N!c                   \        V P                  4       F4  p\        V\        4      '       g   K  Vw  rEV P	                  VVVVR7       K6  	  \        V P                  4       FQ  pVR8w  g   K  RV9   g   K  \
        P                  ! V P                  P                  V4      4      V P                  V&   KS  	  RV P                  RV P                  /pV P                  P                  4        \
        P                  ! V4      P                  4       V P                  R&   V P                  P                  RP                  T;'       g    V P                   R.4      V P                  R,          4       V P"                  P%                  4        R# )zdOutput any modified or deleted keys

Parameters
----------
base_url: str
    Location of the output
)rZ  r   r   r   r   r   r   N)r7   rN   r6   r8   r+  rK   r   rY  rJ   r   rX  rL   rM   r   r   r   r   r   cache_clear)r   rZ  r   thingrT   r   kr   s   &&&     r   flushLazyReferenceMapper.flush  s#    $++&E%'' %

%$3	   ' dkk"AL TQY$(JJt{{q/A$Bq! # 4>>=$:J:JK$(JJsO$:$:$<L!HHh//$-->?KK%	
 	""$r   c                R   ^ pV P                  4        FQ  pVP                  R4      '       d   V^,          pK%  V\        P                  ! V P	                  V4      4      ,          pKS  	  V\        V P                  4      ,          pV\        R V P                   4       4      ,          pV# )r   r   c              3   V   "   T F  p\        V\        4      '       d   K  ^x  K!  	  R# 5i)r   N)r6   r8   )r   r   s   & r   r   .LazyReferenceMapper.__len__.<locals>.<genexpr>8  s     H1:a3GQQs   )
))	rO   r   r  prodrP   rQ   rJ   sumrN   )r   rQ  rT   s   &  r   __len__LazyReferenceMapper.__len__.  s    \\^E$$
4#8#8#?@@	 $
 	T^^$$HHHHr   c              #  .  "   \        V P                  4      pVP                  V P                  4       V F  p\	        V\
        4      '       g   K  Vx  K!  	  V P                  4        F'  pV P                  V4       F  pW@9   g   K  Vx  K  	  K)  	  R # 5ir   )r   rJ   r   rN   r6   r9   rO   r   )r   metasbitrT   rg  s   &    r   rV   LazyReferenceMapper.__iter__;  sr      DNN#T[[!C#s##	  \\^E((/9G 0 $s   A	B2BBc                N     V P                  V4       R #   \         d     R# i ; i)TF)r   r   r   s   &&r   __contains__ LazyReferenceMapper.__contains__H  s*    	t$ 		s    $$c           
   #  0  "   V P                  V4      p\        V4      ^ 8X  d   VR,           x  R# \        P                  ! R V 4       !  pV F=  pVR,           RP	                  V Uu. uF  p\        V4      NK  	  up4      ,           x  K?  	  R# u upi 5i)zlList key names in given field

Produces strings like "field/x.y" appropriate from the chunking of the array
rH   Nc              3   8   "   T F  p\        V4      x  K  	  R # 5ir   )r  )r   rf   s   & r   r   5LazyReferenceMapper._keys_in_field.<locals>.<genexpr>X  s     "A[588[r  r   r   )rP   rQ   	itertoolsproductr   r9   )r   rT   rU   indsindr   s   &&    r   r   "LazyReferenceMapper._keys_in_fieldO  s     
 ++E2{q $,  "A["ABC#+#)>#Q#a&#)> ??? )>s   A&B(B<B)rN   r   r   r   rU   ru   r   rO   r   r   r   r   r   rJ   )NN   
   rv   )NNi'  )r   TNN)#r$   r%   r&   r'   __doc__propertyrm   rq   r   r   r   staticmethodr   rO   r   r   r   rP   r  rR   r0   r   r$  r'  r2  r   r9  r+  rh  ro  rV   rv  r   r(   r)   rZ   s   @r   rj   rj   [   s     Y  
  
5K 5Kn##0 7 7<
@"D&P
,'C<$#'O( 4 4("S)j!%F@ @r   rj   c                   $  a a ] tR tRt oRtRtRtR"V 3R lltR#R ltR#R lt	R#R lt
R	 tR
 t]3R ltR$R ltR%R ltR&R ltR tR&R ltR tR tR tR'R ltR(R ltR tR tR tR(R ltR)V 3R lltR tR tR t R*R lt!R*R lt"R  t#R!t$Vt%V ;t&# )+ReferenceFileSystemi]  a  View byte ranges of some other file as a file system
Initial version: single file system target, which must support
async, and must allow start and end args in _cat_file. Later versions
may allow multiple arbitrary URLs for the targets.
This FileSystem is read-only. It is designed to be used with async
targets (for now). We do not get original file details from the target FS.
Configuration is by passing a dict of references at init, or a URL to
a JSON file containing the same; this dict
can also contain concrete data for some set of paths.
Reference dict format:
{path0: bytes_data, path1: (target_url, offset, size)}
https://github.com/fsspec/kerchunk/blob/main/README.md
r   Fc                	  < \         SV `  ! R/ VB  W n        Wn        Wn        / V n        / V n        / V n        Wn        Wn	        \        V\        4      '       Ed   \        R/ T;'       g    T;'       g    / BRV/B p\        P                  P                  ! V3/ VB w  ppRV9  dY   VP!                  R4      '       g   VP#                  V4      '       d+   \$        P'                  RV4       \)        VVVR7      V n        My\        P,                  ! VR3/ VB ;_uu_ 4       p\$        P'                  RV4       \.        P0                  ! V4      pRRR4       V P3                  XV	4       MV P3                  W4       \        V\        4      '       d   VP5                  4        UUu/ uFM  w  ppT\        V\        4      '       d/   \        P6                  ! VP9                  R^4      ^ ,          3/ VB MTbKO  	  uppV n        RV P                  9  d   \7        R	4      V P                  R&   R# VeN   \        VP:                  \<        4      '       d   VP:                  ^ ,          MVP:                  pWP                  V&   Vf   V P
                  P?                  4        F~  p\A        V4      '       d   V! 4       p\        P                  PC                  V4      w  ppV'       g   KG  VV P                  9  g   KZ  \7        V3/ T;'       g    / B pWP                  V&   K  	  Vf   V P*                  P?                  4        F  p\A        V4      '       d   V! 4       p\        V\D        4      '       g   K3  V^ ,          '       g   KD  \        P                  PC                  V^ ,          4      w  ppVV P                  9  g   K  \7        V3/ T;'       g    / B pWP                  V&    M	  V'       d5   W`P                  9  d%   \7        V3/ T;'       g    / B pWP                  V&   T;'       g    \7        R	4      V P                  R&   V P                  P5                  4        Fl  w  ppVPF                  '       g'   \I        VV PJ                  R
7      V P                  V&   K>  V PJ                  VPJ                  ,          '       g   Kc  \M        R4      h	  R#   + '       g   i     EL; iu uppi )a`
  
Parameters
----------
fo : dict or str
    The set of references to use for this instance, with a structure as above.
    If str referencing a JSON file, will use fsspec.open, in conjunction
    with target_options and target_protocol to open and parse JSON at this
    location. If a directory, then assume references are a set of parquet
    files to be loaded lazily.
target : str
    For any references having target_url as None, this is the default file
    target to use
ref_storage_args : dict
    If references is a str, use these kwargs for loading the JSON file.
    Deprecated: use target_options instead.
target_protocol : str
    Used for loading the reference file, if it is a path. If None, protocol
    will be derived from the given path
target_options : dict
    Extra FS options for loading the reference file ``fo``, if given as a path
remote_protocol : str
    The protocol of the filesystem on which the references will be evaluated
    (unless fs is provided). If not given, will be derived from the first
    URL that has a protocol in the templates or in the references, in that
    order.
remote_options : dict
    kwargs to go with remote_protocol
fs : AbstractFileSystem | dict(str, (AbstractFileSystem | dict))
    Directly provide a file system(s):
        - a single filesystem instance
        - a dict of protocol:filesystem, where each value is either a filesystem
          instance, or a dict of kwargs that can be used to create in
          instance for the given protocol

    If this is given, remote_options and remote_protocol are ignored.
template_overrides : dict
    Swap out any templates in the references file with these - useful for
    testing.
simple_templates: bool
    Whether templates can be processed with simple replace (True) or if
    jinja  is needed (False, much slower). All reference sets produced by
    ``kerchunk`` are simple in this sense, but the spec allows for complex.
max_gap, max_block: int
    For merging multiple concurrent requests to the same remote file.
    Neighboring byte ranges will only be merged when their
    inter-range gap is <= ``max_gap``. Default is 64KB. Set to 0
    to only merge when it requires no extra bytes. Pass a negative
    number to disable merging, appropriate for local target files.
    Neighboring byte ranges will only be merged when the size of
    the aggregated range is <= ``max_block``. Default is 256MB.
cache_size : int
    Maximum size of LRU cache, where cache_size*record_size denotes
    the total number of references that can be loaded in memory at once.
    Only used for lazily loaded references.
kwargs : passed to parent class
rC   z.jsonz$Open lazy reference dict from URL %s)r   r   rbzRead reference from URL %sN:r|   )asynchronouszEReference-FS's target filesystem must have same value of asynchronousrX   )parqparquetr   )'r   r   r   template_overridessimple_templates	templatesfss	_dircachemax_gap	max_blockr6   r9   dictr   r   r   endswithisdirloggerinforj   r;   r   rK   load_process_referencesr   r
   r   rC   r8   r0   callabler   r7   
async_implr   r  r   )r   for   ref_storage_argstarget_protocoltarget_optionsremote_protocolremote_optionsr   r  r  r  r  r   r   dicref_fsfo2r   textrg  optsr<   rC   r   r   s   &&&&&&&&&&&&&&,          r   r   ReferenceFileSystem.__init__o  s   R 	"6""4 0"b# #;;~;;GVC !++//:c:KFCc!455c9J9J BBG"5)# [[T1S11QKK <bA99Q<D 2 ((/AB $$R<b$  "xxz  *GAt !$-- %%aggc1oa&8ADA
  *DH 488#!+F!3> #-R[[%"@"@Abkk  )+HH_%"~~,,.C==%C$kk88=!8 8#HG1E1E2GB)+HHX& / " --/C==%Cc4((SVV"(++"<"<SV"DKHatxx/'K^5I5IrK-/* 0 hh>OF0D0D"FB(*HH_%11z&1HHNN$DAq<<<4QTEVEVW""Q^^33 & 	 %o 211s   "-S$AS S	c           
        V P                  V4      p\        P                  R V 24        V P                  V,          p\        T\        4      '       d   TP                  4       p\        TR4      '       d   TP                  4       p\        T\        4      '       dS   \        P                  RT R24       TP                  R4      '       d   \        P                  ! TR,          4      pTRR3# \        T4      ^8X  d(   \        P                  RT RT 24       T^ ,          pY#rMlTw  rip
\        P                  RT RT R	T	 R
T
 24       Y,           pTe   T^ 8  d
   Y,           pMY,           pMT	pTe   T^ 8  d
   Y,           pMY,           pMTpTf   T P                   pYgT3#   \         d   p\        T4      ThRp?ii ; i)zcat: Nr*  zReference: z, type bytes   base64:   NNz, whole file => z => z	, offset z, size )_strip_protocolr  debugr;   r   r   r6   r9   rM   r,  r*  r.  r   base64	b64decoderQ   r   )r   r:   startendpartr   r   start1end1start0r   end0s   &&&&        r   _cat_commonReferenceFileSystem._cat_common  s   ##D)uTF^$	3??4(D dC  ;;=D4$$==?DdE""LL;tfL9:z**''R1t##t9>LL;tf,<TFCDq'C D $CLL;tfDYvhgdVTU=D A:#^F!\F!8!<D:D;++CD  K  	3#D)s2	3s   F% %G0F<<Gc                   "   V P                  WVR 7      w  rVp\        V\        4      '       d   WRV # \        V4      w  r V P                  V,          P                  WVVR 7      G Rj  xL
 #  L  \         d   p
\        Y4      T
hRp
?
ii ; i5i)r  r  N)r  r6   r.  r   r  	_cat_file	Exceptionr   r   r:   r  r  r   part_or_urlr  r  rC   r   es   &&&&,      r   r  ReferenceFileSystem._cat_file>  s     $($4$4TC$4$P!Tk5))S))$[1	B(+55t 6      	B':A	Bs;   >B'A/ (A-)A/ ,B-A/ /B:BBBc                   V P                  WVR 7      w  rVp\        V\        4      '       d   WRV # \        V4      w  r V P                  V,          P                  WVVR 7      #   \         d   p
\        Y4      T
hRp
?
ii ; ir  )r  r6   r.  r   r  r   r  r   r  s   &&&&,      r   r   ReferenceFileSystem.cat_fileJ  s    $($4$4TC$4$P!Tk5))S))$[1	B88H%..{d.SS 	B':A	Bs   #A# #A?.A::A?c                "    W P                   V&   R# )z2Temporarily add binary data or reference as a fileNr;   )r   r:   r/  r   s   &&&,r   	pipe_fileReferenceFileSystem.pipe_fileT  s     %r   c                &  "   V P                  V4      '       d   \        P                  ! VR R7      # V P                  V4      G Rj  xL
 p\	        VR4      ;_uu_ 4       pVP                  V4       RRR4       R#  L4  + '       g   i     R# ; i5i)Tr   Nwb)r  osr   r  r   r+  )r   rpathlpathr   r   r   s   &&&,  r   	_get_fileReferenceFileSystem._get_fileX  sf     ::e;;ut44^^E**%!GGDM  +s*   ABA;BA=1B=B		Bc                   V P                  V4      '       d   \        P                  ! VR R7      # V P                  ! V3/ VB pVP	                  \        V4      4       \        V4      '       d   VP                  V4       M.\        VR4      ;_uu_ 4       pVP                  V4       RRR4       VP                  \        V4      4       R#   + '       g   i     L,; i)Tr   r  N)
r  r  r   r   set_sizerQ   r   r+  r   absolute_update)r   r  r  callbackr   r   r   s   &&&&,  r   get_fileReferenceFileSystem.get_file_  s    ::e;;ut44}}U-f-#d)$eKKeT""a #  T+ #"s   C

C	c                   V'       d   V P                  R 4       V P                  WR7      p\        P                  ! RRR7      p\	        W4      pV'       d;   T P                  V Uu. uF  qpP                  V4      '       d   K  VNK  	  up4      pMV P                  V4      p\        W4       F%  w  rW9   g   K  VP                  WV	,          4       K'  	  R# u upi )r   r   r|   T)
auto_mkdirN)	r   expand_pathr   r
   r   catr  r^   r  )r   r  r  r   r   r   targetsrr   remotelocals   &&&&,      r   r5   ReferenceFileSystem.getk  s    GGBK   <v$7e+88C1ZZ]QQCDD88E?D 0MF~UL1 1 Ds   &CCc           
        \        V\        4      '       d   V'       d   \        h\        V\        4      '       dI   V'       g;   \        ;QJ d    R  V 4       F  '       g   K   RM	  RM! R  V 4       4      '       d   \        h\        WP                  4      p/ pVP                  4        EF  w  rxV P                  V,          p	. . . . 3w  rrV F|  p V P                  V4      w  ppp\        V\        \        34      '       g   K7   V
P                  V4       VP                  V4       VP                  V4       VP                  V4       K~  	  . p. p. p. p\        4       p\        WW4       F  w  pppp\        V\        4      '       d   WV&   K$  Ve   K*  VP                  V4       VP                  V4       VP                  V4       VP                  V4       VP                  V4       K  	  \        WW4       F[  w  ppppVf   K  VV9  g   K  VP                  V4       VP                  V4       VP                  V4       VP                  V4       K]  	  \!        \        V4      \        V4      \        V4      RV P"                  V P$                  R7      w  pppV	P'                  VVV4      p\        WW4       F  w  ppppW9   d   K  \        VVVV4       F  w  ppppVV8X  d.   Ve   Vf&   \        V\(        4      '       d   VWn&   K3  VVV Wn&   K<  VV8X  g   KE  VV8  g   KN  VV8:  g   KW  \        V\(        4      '       d   VWn&   Ks  TVV,
          VV,
          ;'       g    R Wn&   K  	  K  	  EK  	  VP+                  4       P                  4        Fu  w  p p!\        V!\(        4      '       g   K  V V P                  9   g   K1  VV ,          p"\-        V V P                  V ,          4      p#V"V#n        VR8X  d   V#hVR8w  g   Kp  V#VV &   Kw  	  \1        V4      ^8X  d)   \        V\        4      '       d   RV9  d   \3        V4      # V#   \         d'   pTR8X  d   h TR8w  d   TYn&    Rp?EK   Rp?EK  Rp?ii ; i)c              3   ,   "   T F
  pR V9   x  K  	  R# 5i)*NrX   r   s   & r   r   *ReferenceFileSystem.cat.<locals>.<genexpr>}  s     7O$Qq$   TFraiseomitN)sortr  r  r  )r6   r9   rU  r7   anyrD   r;   r   r  r  r.  r@   r   r   r^   addr   r  r  
cat_rangesr  r@  r   	__cause__rQ   r2   )$r   r:   r   on_errorr   
proto_dictrB   protorA   r   urlsstartsendsvalid_pathsr   urg   r  errurls2starts2ends2paths2whole_files	new_paths
new_startsnew_ends	bytes_outrm   nsnebrg  vexnew_exs$   &&&&,                               r   r  ReferenceFileSystem.catz  s   dC  Y%%dD!!yCC7O$7OCCC7O$7O4O4O%%%dOO<
&,,.LE%B.0"b"n+D$*"..q1GAq!%a%66  7 KKNMM!$KKN&&q)# ( EGEF%K!$B
1aa''FY  OOA&LLONN1%LLOMM!$ C "$B
1a=Qk%9LLONN1%LLOMM!$ C /BUWU../+Iz8 iXFI "$B
1a8%(J)%TMBBQwBJ"*%a33%&CF%&qVCFqQ"Wb%a33%&CF%&q2vR0@0@D%ACF &U Cy /V HHJ$$&DAq!Y''A,@V.q$//!2DE#% w& L'#CF ' s8q=Zc22s$#;
[ ) %7*6)!$ *%s   1QQ<Q77Q<c                    VP                  R R4      pVf   V P                  V4       R# V^8X  d   V P                  WR7       R# \        RV 24      h)versionN)r  z Unknown reference spec version: )r5   _process_references0_process_references1r   )r   r;   r  verss   &&& r   r  'ReferenceFileSystem._process_references  sP    ~~i.<%%j1QY%%j%X?vFGGr   c           	         \        V\        4      '       dQ   VP                  4        UUu/ uF4  w  r#T\        V\        4      '       d   \        P                  ! V4      MTbK6  	  pppWn        R# u uppi )z&Make reference dict for Spec Version 0N)r6   r  r   rK   rL   r;   )r   r;   r   rS   s   &&  r   r  (ReferenceFileSystem._process_references0  sc    j$''
 !+ 0 0 2 2HC 
3(=(=TZZ_3F 2   %	s   :A/c                ^  a a S P                   '       d   S P                  '       d   ^ RIo/ S n        S P	                  VP                  R/ 4      4       \        R4      VV 3R l4       pVP                  R/ 4      P                  4        EFf  w  rE\        V\        4      '       dS   VP                  R4      '       d+   \        P                  ! VR,          4      S P                  V&   VS P                  V&   Kn  \        V\        4      '       d&   \        P                  ! V4      S P                  V&   K  S P                  '       d   V^ ,          pRV9   dX   S P                   '       d>   VP!                  RR	4      P!                  R
R4      P"                  ! R/ S P                  B pMV! V4      p\%        V4      ^8X  d   V.MWe^,          V^,          .S P                  V&   EKW  VS P                  V&   EKi  	  S P                  P'                  S P)                  VP                  R. 4      4      4       R# )r   Nr  i  c                 Z   < SP                  V 4      P                  ! R/ SP                  B # NrX   )Templaterenderr  )r  jinja2r   s   &r   _render_jinja?ReferenceFileSystem._process_references1.<locals>._render_jinja  s$    ??1%,,>t~~>>r   r   zbase64:r  {{{z}}}genrX   )r  r  r  r;   _process_templatesr5   r   r   r6   r9   r   r  r  r  rK   rL   replacerx   rQ   r   _process_gen)r   r;   r  r  rg  r   r  r  s   f&&    @r   r  (ReferenceFileSystem._process_references1  s   $$$
{B ?@	4	? 
	? NN62.446DA!S!!<<	**)/)9)9!B%)@DOOA&%&"At$$%)ZZ]"aD19,,,IIdC0$WT3/#V$ 6&*nn6  *!,,/FaKaSa1qt_"%&") 7* 	t00r1JKLr   c                   a / V n         V P                  e   VP                  V P                  4       VP                  4        F6  w  r#RV9   d   ^ R IoV3V3R llV P                   V&   K(  W0P                   V&   K8  	  R # )Nr  c                 F   < SP                  V 4      P                  ! R/ VB # r  )r  r  )tempr   r  s   &,r   r   8ReferenceFileSystem._process_templates.<locals>.<lambda>  s(    V__>&> >#!>#r   )r  r  r   r   r  )r   tmprg  r   r  s   &&  @r   r  &ReferenceFileSystem._process_templates  se    "".JJt../IIKDAqy01 %#q! %&q!  r   c                  a / pV EF  pVR ,          P                  4        UUu/ uFR  w  rET\        V\        4      '       d   TM3\        VP	                  R^ 4      VR,          VP	                  R^4      4      bKT  	  uppoV3R l\
        P                  ! SP                  4       !   4       pV EF&  p^ RIpVP                  VR,          4      P                  ! R/ VBV P                  B p	VP                  VR,          4      P                  ! R/ VBV P                  B p
RV9   d   R	V9   d   \        VP                  VR,          4      P                  ! R/ VBV P                  B 4      p\        VP                  VR	,          4      P                  ! R/ VBV P                  B 4      pWV.W)&   EK  RV9   R	V9   ,          '       d   \        R
4      hV
.W)&   EK)  	  EK  	  V# u uppi )
dimensionsr  stopstepc              3   j   <"   T F(  p\        \        SP                  4       V4      4      x  K*  	  R # 5ir   )r  r^   r_   )r   r0   	dimensions   & r   r   3ReferenceFileSystem._process_gen.<locals>.<genexpr>,  s.      DF S)6233Ds   03Nr   r   r   lengthz^Both 'offset' and 'length' are required for a reference generator entry if either is provided.rX   )r   r6   r7   r  r5   r{  r|  r0   r  r  r  r  r   r   )r   gensrB   r  rg  r   productsprr  r   r   r   r)  r'  s   &&           @r   r   ReferenceFileSystem._process_gen!  s   C  -335 6DA !!T** quuWa0!F)QUU61=MNO
 6I'//1A1A1CDH ooc%j188P2PPooc%j188P2PPO(c/ H6==UUdnnUF !H6==UUdnnUF !$V4CH#o(c/::$K 
 !$uCH'  B 
As   AG c           
     ,   R . /V n         V P                  P                  4       pV EFi  w  r#\        V\        \
        34      '       g   \        VR4      '       d   \        V4      pM\        V4      ^8X  d   RpMVw   rTRV9   d   VP                  R^4      ^ ,          MR pTpV.pV'       d5   WpP                   9  d%   V P                  V4      pVP                  V4       K<  VP                  4        \        WR,          4       F`  w  rWP                   9  g   Q hWP                   9   g   Q hV P                   V	,          P                  RV
RRR^ /4       . V P                   V
&   Kb  	  V P                   V,          P                  RVRR	RV/4       EKl  	  R# )
r   r*  Nr   :r   NNr   r   r   r   r|   )dircacher;   r   r6   r.  r9   r,  rQ   r   _parentr@   reverser^   )r   r  r:   r  r   r   parpar0subdirsparentchilds   &          r   _dircache_from_items(ReferenceFileSystem._dircache_from_itemsF  sU   R__""$JD$--z1J1J4yTa!
1,/4K$++c1%a(RCDfG4}}4||D)t$OO!$Wbk!:MM111...f%,,UFKC (*e$ "; MM#%%vtVVVT&RS3 r   c                &   V P                  V4      w  rgp\        V\        4      '       d   \        P                  ! WgV 4      # \        V4      w  rVf.   Vf*   V P                  V	,          P                  ! VV3RVRV/VB # \        V VV3RVRV/VB # )N
block_sizecache_options)	r  r6   r.  r   r   r   r  _openReferenceFile)r   r:   moder:  r;  r   r  r  r  rC   r   s   &&&&&,     r   r<  ReferenceFileSystem._opend  s    $($4$4T$:!T k5))::k677$[1>dl88H%++ & ,	
   
 "	

 (
 
 	
r   c                   \         P                  R V4       V P                  V4      p\        V P                  \
        4      '       d    V P                  P                  W4      # V P                  '       g   V P                  4        V P                  V4      pVf   \        V4      hV'       d   V# V Uu. uF  qUR,          NK  	  up#   \         d     Mi ; i\        RT R24      hu upi )zlist %s'z' is not a known keyr   )r  r  r  r6   r;   rj   r   r   r   r/  r7  _ls_from_cache)r   r:   r   r   rB   os   &&&,  r   r   ReferenceFileSystem.ls~  s    Y%##D)doo':;;))$77 }}}%%'!!$';#D))J#&'3a&		3''  #av-A$BCC (s   	C 4C(CCc                V    V P                  V4      ;'       g    V P                  V4      # r   )r  isfiler   r:   r   s   &&,r   r   ReferenceFileSystem.exists  s"    zz$444;;t#44r   c                \  a V P                   '       d   SV P                   9   # \        V P                  \        4      '       d   SV P                  P	                  4       9   # \
        ;QJ d)    V3R  lV P                   4       F  '       g   K   R# 	  R# ! V3R  lV P                   4       4      # )c              3   J   <"   T F  qP                  S R 24      x  K  	  R# 5ir8  r5  )r   r   r:   s   & r   r   ,ReferenceFileSystem.isdir.<locals>.<genexpr>  s!     IA||tfAJ//s    #TF)r/  r6   r;   rj   rO   r  r   r:   s   &fr   r  ReferenceFileSystem.isdir  sx    ===4==(()<==4??22444 3II33I3I3IIIIr   c                    WP                   9   # r   r  rL  s   &&r   rF  ReferenceFileSystem.isfile  s    &&r   c                0   "   V P                   ! W3/ VB # 5ir   )r   )r   r:   r   r   s   &&&,r   _lsReferenceFileSystem._ls  s     wwt.v..s   c           	       <a V'       d   \         SV `  ! S3R VRVRV/VB # S'       d2   V P                  S4      o\        V3R lV P                   4       4      pM\        V P                  4      pV'       dK   V P
                  '       g   V P                  4        V Uu/ uF  qwV P                  V4      ^ ,          bK  	  up# V# u upi )maxdepthwithdirsr   c              3   X   <"   T F  qP                  S4      '       g   K  Vx  K!  	  R # 5ir   r5  )r   rg  r:   s   & r   r   +ReferenceFileSystem.find.<locals>.<genexpr>  s     H/Q\\$5Gqq/s   *
*)r   findr  r   r;   r/  r7  rB  )	r   r:   rT  rU  r   r   r  rg  r   s	   &f&&&,  r   rX  ReferenceFileSystem.find  s    7<'2:CIMS  ''-DH$//HHAt'A===))+:;<!Qt**1-a00!<<H =s   !Cc                   V P                   P                  V4      pVeW   \        V\        \        34      '       d   RVRRR\        V4      /# \        V4      ^8  d   RVRRRV^,          /# RVRRRR /.pMBV P                  VR4      pV Uu. uF  qUR,          V8X  g   K  VNK  	  ppV'       g	   RVRRR^ /# V^ ,          R,          fj   \        V P                   V,          ^ ,          4      w  rgV P                  V,          P                  V P                   V,          ^ ,          4      V^ ,          R&   V^ ,          # u upi )Nr   r   r|   r   Tr   )
r;   r5   r6   r9   r.  rQ   r   r   r  r   )r   r:   r   rB   out0rC  protr   s   &&,     r   r  ReferenceFileSystem.info  s#   oo!!$'?#U|,,fffc#hGGSAfffc!fEEvvvtDE''$%C"8s!i4&7AAsD8fk61EE76?"$T__T%:1%=>GD"hhtn11$//$2G2JKDGFOAw 9s   D< D<c                ,   "   V P                  V4      # 5ir   )r  rG  s   &&,r   _infoReferenceFileSystem._info  s     yyr  c                z   "   V P                   P                  VR 4       V P                  P                  4        R # 5ir   )r;   rY  r/  rX  rG  s   &&,r   _rm_fileReferenceFileSystem._rm_file  s.     $	
 	s   9;c                   "   VR 8X  d   V P                  V4      '       d   \        hW P                  V&   V P                  P	                  4        R# 5i)r   N)r   FileExistsErrorr;   r/  rX  )r   r:   r   r>  r   s   &&&&,r   
_pipe_fileReferenceFileSystem._pipe_file  s=     8D 1 1!! $s
   A0Ac                $  "   VR 8X  d   V P                  V4      '       d   \        h\        VR4      ;_uu_ 4       pVP                  4       V P                  V&   RRR4       V P
                  P                  4        R#   + '       g   i     L,; i5i)r   r  N)r   re  r   readr;   r/  rX  )r   r  r  r>  r   r   s   &&&&, r   	_put_fileReferenceFileSystem._put_file  sa     8E 2 2!!%!%&VVXDOOE"  s!   BBA=$B=B	Bc           
        / pV P                   P                  4        F5  w  rE\        V\        4      '       d    VP	                  R4      W4&   K1  WSV&   K7  	  \        P                  ! VR3/ VB ;_uu_ 4       pVP                  \        P                  ! R^RV/4      P                  4       4       RRR4       R#   \
         d2    R\        P                  ! T4      ,           P	                  4       Y4&    K  i ; i  + '       g   i     R# ; i)z+Write modified references into new locationasciir  r  r  r   N)r;   r   r6   r.  r-  UnicodeDecodeErrorr  	b64encoder   r   r+  rK   rL   rM   )r   r   r   rB   rg  r   r   s   &&,    r   	save_jsonReferenceFileSystem.save_json  s    OO))+DA!U##IXXg.CF A , [[d6o66!GGDJJ	1fc:;BBDE 76	 * I(6+;+;A+>>FFHCFI 766s   B868C788C43C47D	)
r  r/  r  r  r  r;   r  r   r  r  )NNNNNNNNTi   i @Br  r  )F)Fr  r   )r  NN)T)NFF)	overwrite)'r$   r%   r&   r'   r  rC   cachabler   r  r  r   r  r  r	   r  r5   r  r  r  r  r  r  r7  r<  r   r   r  rF  rQ  rX  r  r_  rb  rf  rj  rp  r(   r)   r*   r+   s   @@r   r  r  ]  s      HHaF*!X
BB& /? 
,2`DH	%MB&#JT<
4($5J'/"*F Fr   r  c                   X   a a ] tR tRt oRV 3R llt]R 4       tV 3R ltR tRt	Vt
V ;t# )r=  i  c	                   < \         SV `  ! VV3R VRVRVRVRVRV/V	B  V P                  P                  V P                  4      w  qn        V n        \        V
4      w  rV P                  P                  V,          V n	        Wn
        RV n        R# )r>  r:  
autocommitr   
cache_typer;  N)r   r   r   r  r:   r  r  r   r  src_fssrc_path_f)r   r   r:   r>  r:  rv  rw  r;  r   r   r  rC   r   r   s   &&&&&&&&&,   r   r   ReferenceFile.__init__  s     	
	
 
	
 "	
	

 "
	
 
	
 "
	
 (
	
 
	
 -1GG,?,?		,J)Z$[1ggkk(+#r   c                &   V P                   e   V P                   P                  '       d]   V P                  P                  ! V P                  3RV P
                  RV P                  RV P                  RR/V P                  B V n         V P                   # )Nr>  r:  rv  rw  none)	rz  closedrx  r<  ry  r>  	blocksizerv  r   r!   s   &r   r   ReferenceFile.f  s    77?dggnnnkk''YY  >>  ??	
 " ++DG wwr   c                p   < V P                   e   V P                   P                  4        \        SV `  4       # r   )rz  closer   )r   r   s   &r   r  ReferenceFile.close  s&    77GGMMOw}r   c                    WP                   ,           p\        W P                   ,           V P                  4      pV P                  P	                  V4       V P                  P                  W!,
          4      # r   )r  minr  r   seekri  )r   r  r  s   &&&r   _fetch_rangeReferenceFile._fetch_range   sJ    

"#

"DHH-Evv{{3;''r   )rz  r  rx  ry  r  )r  defaultT	readaheadNN)r$   r%   r&   r'   r   r  r   r  r  r(   r)   r*   r+   s   @@r   r=  r=    s-     : 
 

( (r   r=  )2r  collectionsr   r{  loggingr  r  	functoolsr   r   typingr   r   fsspec.corer   fsspec.specr   ujsonrK   r   fsspec.asynr   fsspec.callbacksr	   r
   r   r   #fsspec.implementations.asyn_wrapperr   fsspec.utilsr   r   r   	getLoggerr  RuntimeErrorr   r2   r=   rD   abc
ValuesViewrF   	ItemsViewr\   rh   MutableMappingrj   r  r=  rX   r   r   <module>r     s     	    	   )  ,
 ( - 8 8 F  
		-	.TL T"?
B[__// 
BAKOO-- A
@+//88 @DP
F/ P
Ff4(( 4(&  s   D DDD