U adI @sdZddlZddlZddlZddlZddlZddlZejdkZejdkZ ejdkZ ejdkZ ejdkZ e dkZe dkZejd Zejd Zd ekZeeZejZejZejZeZed d ddddddgZGdddeZz ddl Z Wne!k rddl"Z YnXddZ#e r6ddl$m%Z&nddl&Z&ddZ'e rddl(Z(ddl)Z)ddl*Z*ddl+Z+ddl,Z,ddl-m.Z.ddl/m0Z1ddl/m2Z2ddl+m3Z3ddl4m5Z5dd l6m7Z7m8Z8m9Z9m:Z:m;Z;efZ?e>Z@elcm8Z8dd?ldm9Z9dd@l\meZeGdAdBdBeZ]z ddlfZ,Wne!k rNddl,Z,YnXegfZ=e>fZ?eeprrrimportlib_metadata_getvs  rD)reduce)BytesIO)StringIO) zip_longest) perf_counter) quote_plus unquote_plus parse_qslquoteunquoteexec __import__printcCs |dS)Nzlatin-1)encodesrrrbsrUcCst|dSNascii)base64 b64decoderRxrrrrYsrYcCst|dSrV)rX b64encodedecoderZrrrr\sr\cCs|j|ddS)Nbackslashreplaceerrors)r]textencodingrrrdecode_backslashreplacesrdcCs||k||kSrr)arUrrrcmpsrfFcCsH|dk r||}|dk r"||_n|dk r0||_z|W5~~~~XdS)a{implement "raise" with cause support. :param exception: exception to raise :param with_traceback: will call exception.with_traceback() :param replace_context: an as-yet-unsupported feature. This is an exception object which we are "replacing", e.g., it's our "cause" but we don't want it printed. Basically just what ``__suppress_context__`` does but we don't want to suppress the enclosing context, if any. So for now we make it the cause. :param from\_: the cause. this actually sets the cause and doesn't hope to hide it someday. NF)with_traceback __cause__) exceptionrgZreplace_contextfrom_rrrraise_s rkcCs|SrrrSrrrusrlcCs|SrrrSrrruesrm) TYPE_CHECKING)ABCcCs|jSr)r )fnrrr _qualnamesrq) izip_longest)clock)rM)rJ)rN)rK)rL)ABCMetac@seZdZeZdS)roN)rrr rt __metaclass__rrrrrosrocCs|SrrrSrrrrUscCs|dkrtdntddS)Nzexec func_text in globals_zexec func_text in globals_, lcl)rO)Z func_textglobals_Zlclrrrexec_s rwcCsdd|DS)Ncss|]}t|VqdSr)ord).0byterrr sziterbytes..r)bufrrr iterbytessr}cGs4t|dkr,|dddd|dDf}t|S)NrrcSsg|] }t|qSr)str)ryargrrr szimport_..)lenrP)r rrrimport_s  rcOsH|dtj}|dkrdSt|D] }t|ts8t|}||q"dS)Nfile)popsysstdout enumerate isinstance basestringrwrite)r kwargsfprrrrprint_#s  rcCs t|dS)Nzutf-8unicoderSrrrrl,scCs t|dS)NZunicode_escaperrSrrrrm3scCs:z ||WStk r4t|ddYSXdS)Nr")r]UnicodeDecodeErrorreprrarrrrd6s cCs<t|tst|jdddSt|tr4|jdddS|SdS)NrWr^r_)r string_typesrrRrbrrrsafe_bytestring?s  rzdef raise_(exception, with_traceback=None, replace_context=None, from_=False): if with_traceback: raise type(exception), exception, with_traceback else: raise exception cCs4|jjD]}|j|jkrq$q|jSd|j|jfS)z6return __qualname__ equivalent for a method on a classz%s.%s)Zim_class__mro__r__dict__)methclsrrrrqUs   cCsVt|dddkr t|ddSt|trN|jd|fkr>|jS|jd|jSt|S)zvendored from python 3.7rNtypingztyping.builtins.)getattrrreplacertyperr ) annotation base_modulerrr_formatannotationcs rrcCsd|S)N*rnamerrrwrcCsd|S)Nz**rrrrrrxrcCs dt|S)N=)r)valuerrrryrcCsd|S)Nz -> rrrrrrzrc s fdd} g}|r(t|t|}t|D]:\}}| |}|r`||kr`|| |||}||q0|dk r||| |n|r|d|r|D]2}| |}|r||kr|| ||7}||q|dk r|| | |dd|d}dkr|| d7}|S) abCopy formatargspec from python 3.7 standard library. Python 3 has deprecated formatargspec and requested that Signature be used instead, however this requires a full reimplementation of formatargspec() in terms of creating Parameter objects and such. Instead of introducing all the object-creation overhead and having to reinvent from scratch, just copy their compatibility routine. Ultimately we would need to rewrite our "decorator" routine completely which is not really worth it right now, until all Python 2.x support is dropped. cs(|}|kr$|d|7}|S)Nz: r)rresultrformatannotation formatargrrformatargandannotationsz5inspect_formatargspec..formatargandannotationNr(z, )return)rrappendjoin)r r r rrrrr formatvarargs formatvarkw formatvalue formatreturnsrrspecs firstdefaultirspec kwonlyargrrrrinspect_formatargspecns2      r) formatargspeccOst|dd|S)Nrr~)_inspect_formatargspec)rkwrrrrscCst|rt|SgSdS)zSReturn a sequence of all dataclasses.Field objects associated with a class.N) dataclasses is_dataclassfieldsrrrrdataclass_fieldss  rcsJt|rBt|jD]}t|qfddt|DSgSdS)zReturn a sequence of all dataclasses.Field objects associated with a class, excluding those that originate from a superclass.csg|]}|kr|qSrr)ryfZ super_fieldsrrrsz*local_dataclass_fields..N)rrset __bases__updaterr)rsuprrrlocal_dataclass_fieldss   rcCsgSrrrrrrrscCsgSrrrrrrrscCsB|dkrt}|\}}}||k r&|nd}tt||||ddS)legacy. use raise\_()N)tbcause)rexc_inforeraiser)rirexc_type exc_valueexc_tbrrrrraise_from_causes  rcCst|||ddS)r)rgrjN)rk)tprrrrrrrsrcs$Gfddd}|ddiS)zCreate a base class with a metaclass. Drops the middle class upon creation. Source: https://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/ cs(eZdZejZejZfddZdS)z!with_metaclass..metaclasscsP|dkrt||d|}n ||}t|drLt|jdrL|jj|f|S)Nr__init_subclass__r%)r__new__rArr%)rr this_basesdbasesrmetarrrs  z)with_metaclass..metaclass.__new__N)rrr r__call__rrrrrr metaclasssrtemporary_classNr)rrrrrrrwith_metaclasss r)timezone)datetime timedelta)tzinfoc@seZdZdZdZddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ eddZeddZeddZedddZe ZdS)rz(Minimal port of python 3 timezone object_offsetcCs>t|tstd|j|kr*|jks4ntd||_dS)Nzoffset must be a timedeltazYoffset must be a timedelta strictly between -timedelta(hours=24) and timedelta(hours=24).)rrr' _minoffset _maxoffset ValueErrorr)roffsetrrrrs ztimezone.__init__cCst|tkrdS|j|jkS)NF)rrr)rotherrrr__eq__'s ztimezone.__eq__cCs t|jSr)hashrrrrr__hash__,sztimezone.__hash__cCsd|jj|jfS)Nzsqlalchemy.util.%s(%r)) __class__rrrrrr__repr__/sztimezone.__repr__cCs |dSr)tznamerrrr__str__5sztimezone.__str__cCs|jSr)rrdtrrr utcoffset8sztimezone.utcoffsetcCs ||jSr)_name_from_offsetrrrrrr;sztimezone.tznamecCsdSrrrrrrdst>sz timezone.dstcCs2t|tr&|j|k rtd||jStddS)Nzfromutc: dt.tzinfo is not selfz6fromutc() argument must be a datetime instance or None)rrrrrr'rrrrfromutcAs   ztimezone.fromutccCs|jd|jd|jS)z(backport of timedelta._to_microseconds()iQi@B)daysseconds microsecondsrrrr_timedelta_to_microsecondsJs z#timezone._timedelta_to_microsecondscCs*tt|t|\}}|tdd|fS)z backport of timedelta.__divmod__r)divmodrrr)rerUqrrrr_divmod_timedeltasQs ztimezone._divmod_timedeltascCs|sdS|tdkr d}| }nd}t|tdd\}}t|tdd\}}d|||f}|jrt|d |jf7}|jr|d |jf7}|S) NUTCr-+r")hours)minuteszUTC%s%02d:%02dz:%02dz.%06d)rrrrr)deltasignrrestrrrrrr[s( ztimezone._name_from_offset;)rrN)rrr r! __slots__rrrrrrrrr staticmethodrrrrrrrrrrrs&      r)NNF)N)N)N)NN)r! collections contextlibr#operatorplatformr version_infoZpy310Zpy38Zpy37r-Zpy2kpython_implementationpypycpython startswithwin32ZosxmachinelowerarmboolZhas_refcount_gccontextmanager attrgetterZ dottedgetter namedtuplenextr objectr threading ImportErrorZdummy_threadingr; importlibr<r?rDrXr configparser itertoolspickle functoolsrEiorFZ byte_bufferrGrHtimerI urllib.parserJrKrLrMrNrrbytesZ binary_types binary_type text_typeint int_typesiterr}Z long_type filterfalseZitertools_filterfalsefilterZitertools_filtermapZitertools_imaprrwrrrUrYr\rdrfrkrlrmrrncallableabcrorq ConfigParser cStringIOrrrsurlliburlparsertcPicklerrlong ifilterfalseifilterimaprrOrrrrcollections.abccollections_abcrrrrrrrrrrutcrrrrsH          &         %                      C      ]