compat.py 111 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from __future__ import division
  4. import base64
  5. import binascii
  6. import collections
  7. import ctypes
  8. import datetime
  9. import email
  10. import getpass
  11. import io
  12. import itertools
  13. import optparse
  14. import os
  15. import platform
  16. import re
  17. import shlex
  18. import socket
  19. import struct
  20. import subprocess
  21. import sys
  22. import types
  23. import xml.etree.ElementTree
  24. _IDENTITY = lambda x: x
  25. # naming convention
  26. # 'compat_' + Python3_name.replace('.', '_')
  27. # other aliases exist for convenience and/or legacy
  28. # wrap disposable test values in type() to reclaim storage
  29. # deal with critical unicode/str things first:
  30. # compat_str, compat_basestring, compat_chr
  31. try:
  32. # Python 2
  33. compat_str, compat_basestring, compat_chr = (
  34. unicode, basestring, unichr
  35. )
  36. except NameError:
  37. compat_str, compat_basestring, compat_chr = (
  38. str, (str, bytes), chr
  39. )
  40. # compat_casefold
  41. try:
  42. compat_str.casefold
  43. compat_casefold = lambda s: s.casefold()
  44. except AttributeError:
  45. from .casefold import _casefold as compat_casefold
  46. # compat_collections_abc
  47. try:
  48. import collections.abc as compat_collections_abc
  49. except ImportError:
  50. import collections as compat_collections_abc
  51. # compat_urllib_request
  52. try:
  53. import urllib.request as compat_urllib_request
  54. except ImportError: # Python 2
  55. import urllib2 as compat_urllib_request
  56. # Also fix up lack of method arg in old Pythons
  57. try:
  58. type(compat_urllib_request.Request('http://127.0.0.1', method='GET'))
  59. except TypeError:
  60. def _add_init_method_arg(cls):
  61. init = cls.__init__
  62. def wrapped_init(self, *args, **kwargs):
  63. method = kwargs.pop('method', 'GET')
  64. init(self, *args, **kwargs)
  65. if any(callable(x.__dict__.get('get_method')) for x in (self.__class__, self) if x != cls):
  66. # allow instance or its subclass to override get_method()
  67. return
  68. if self.has_data() and method == 'GET':
  69. method = 'POST'
  70. self.get_method = types.MethodType(lambda _: method, self)
  71. cls.__init__ = wrapped_init
  72. _add_init_method_arg(compat_urllib_request.Request)
  73. del _add_init_method_arg
  74. # compat_urllib_error
  75. try:
  76. import urllib.error as compat_urllib_error
  77. except ImportError: # Python 2
  78. import urllib2 as compat_urllib_error
  79. # compat_urllib_parse
  80. try:
  81. import urllib.parse as compat_urllib_parse
  82. except ImportError: # Python 2
  83. import urllib as compat_urllib_parse
  84. import urlparse as _urlparse
  85. for a in dir(_urlparse):
  86. if not hasattr(compat_urllib_parse, a):
  87. setattr(compat_urllib_parse, a, getattr(_urlparse, a))
  88. del _urlparse
  89. # unfavoured aliases
  90. compat_urlparse = compat_urllib_parse
  91. compat_urllib_parse_urlparse = compat_urllib_parse.urlparse
  92. # compat_urllib_response
  93. try:
  94. import urllib.response as compat_urllib_response
  95. except ImportError: # Python 2
  96. import urllib as compat_urllib_response
  97. # compat_urllib_response.addinfourl
  98. try:
  99. compat_urllib_response.addinfourl.status
  100. except AttributeError:
  101. # .getcode() is deprecated in Py 3.
  102. compat_urllib_response.addinfourl.status = property(lambda self: self.getcode())
  103. # compat_http_cookiejar
  104. try:
  105. import http.cookiejar as compat_cookiejar
  106. except ImportError: # Python 2
  107. import cookielib as compat_cookiejar
  108. compat_http_cookiejar = compat_cookiejar
  109. if sys.version_info[0] == 2:
  110. class compat_cookiejar_Cookie(compat_cookiejar.Cookie):
  111. def __init__(self, version, name, value, *args, **kwargs):
  112. if isinstance(name, compat_str):
  113. name = name.encode()
  114. if isinstance(value, compat_str):
  115. value = value.encode()
  116. compat_cookiejar.Cookie.__init__(self, version, name, value, *args, **kwargs)
  117. else:
  118. compat_cookiejar_Cookie = compat_cookiejar.Cookie
  119. compat_http_cookiejar_Cookie = compat_cookiejar_Cookie
  120. # compat_http_cookies
  121. try:
  122. import http.cookies as compat_cookies
  123. except ImportError: # Python 2
  124. import Cookie as compat_cookies
  125. compat_http_cookies = compat_cookies
  126. # compat_http_cookies_SimpleCookie
  127. if sys.version_info[0] == 2 or sys.version_info < (3, 3):
  128. class compat_cookies_SimpleCookie(compat_cookies.SimpleCookie):
  129. def load(self, rawdata):
  130. must_have_value = 0
  131. if not isinstance(rawdata, dict):
  132. if sys.version_info[:2] != (2, 7) or sys.platform.startswith('java'):
  133. # attribute must have value for parsing
  134. rawdata, must_have_value = re.subn(
  135. r'(?i)(;\s*)(secure|httponly)(\s*(?:;|$))', r'\1\2=\2\3', rawdata)
  136. if sys.version_info[0] == 2:
  137. if isinstance(rawdata, compat_str):
  138. rawdata = str(rawdata)
  139. super(compat_cookies_SimpleCookie, self).load(rawdata)
  140. if must_have_value > 0:
  141. for morsel in self.values():
  142. for attr in ('secure', 'httponly'):
  143. if morsel.get(attr):
  144. morsel[attr] = True
  145. else:
  146. compat_cookies_SimpleCookie = compat_cookies.SimpleCookie
  147. compat_http_cookies_SimpleCookie = compat_cookies_SimpleCookie
  148. # compat_html_entities, probably useless now
  149. try:
  150. import html.entities as compat_html_entities
  151. except ImportError: # Python 2
  152. import htmlentitydefs as compat_html_entities
  153. # compat_html_entities_html5
  154. try: # Python >= 3.3
  155. compat_html_entities_html5 = compat_html_entities.html5
  156. except AttributeError:
  157. # Copied from CPython 3.5.1 html/entities.py
  158. compat_html_entities_html5 = {
  159. 'Aacute': '\xc1',
  160. 'aacute': '\xe1',
  161. 'Aacute;': '\xc1',
  162. 'aacute;': '\xe1',
  163. 'Abreve;': '\u0102',
  164. 'abreve;': '\u0103',
  165. 'ac;': '\u223e',
  166. 'acd;': '\u223f',
  167. 'acE;': '\u223e\u0333',
  168. 'Acirc': '\xc2',
  169. 'acirc': '\xe2',
  170. 'Acirc;': '\xc2',
  171. 'acirc;': '\xe2',
  172. 'acute': '\xb4',
  173. 'acute;': '\xb4',
  174. 'Acy;': '\u0410',
  175. 'acy;': '\u0430',
  176. 'AElig': '\xc6',
  177. 'aelig': '\xe6',
  178. 'AElig;': '\xc6',
  179. 'aelig;': '\xe6',
  180. 'af;': '\u2061',
  181. 'Afr;': '\U0001d504',
  182. 'afr;': '\U0001d51e',
  183. 'Agrave': '\xc0',
  184. 'agrave': '\xe0',
  185. 'Agrave;': '\xc0',
  186. 'agrave;': '\xe0',
  187. 'alefsym;': '\u2135',
  188. 'aleph;': '\u2135',
  189. 'Alpha;': '\u0391',
  190. 'alpha;': '\u03b1',
  191. 'Amacr;': '\u0100',
  192. 'amacr;': '\u0101',
  193. 'amalg;': '\u2a3f',
  194. 'AMP': '&',
  195. 'amp': '&',
  196. 'AMP;': '&',
  197. 'amp;': '&',
  198. 'And;': '\u2a53',
  199. 'and;': '\u2227',
  200. 'andand;': '\u2a55',
  201. 'andd;': '\u2a5c',
  202. 'andslope;': '\u2a58',
  203. 'andv;': '\u2a5a',
  204. 'ang;': '\u2220',
  205. 'ange;': '\u29a4',
  206. 'angle;': '\u2220',
  207. 'angmsd;': '\u2221',
  208. 'angmsdaa;': '\u29a8',
  209. 'angmsdab;': '\u29a9',
  210. 'angmsdac;': '\u29aa',
  211. 'angmsdad;': '\u29ab',
  212. 'angmsdae;': '\u29ac',
  213. 'angmsdaf;': '\u29ad',
  214. 'angmsdag;': '\u29ae',
  215. 'angmsdah;': '\u29af',
  216. 'angrt;': '\u221f',
  217. 'angrtvb;': '\u22be',
  218. 'angrtvbd;': '\u299d',
  219. 'angsph;': '\u2222',
  220. 'angst;': '\xc5',
  221. 'angzarr;': '\u237c',
  222. 'Aogon;': '\u0104',
  223. 'aogon;': '\u0105',
  224. 'Aopf;': '\U0001d538',
  225. 'aopf;': '\U0001d552',
  226. 'ap;': '\u2248',
  227. 'apacir;': '\u2a6f',
  228. 'apE;': '\u2a70',
  229. 'ape;': '\u224a',
  230. 'apid;': '\u224b',
  231. 'apos;': "'",
  232. 'ApplyFunction;': '\u2061',
  233. 'approx;': '\u2248',
  234. 'approxeq;': '\u224a',
  235. 'Aring': '\xc5',
  236. 'aring': '\xe5',
  237. 'Aring;': '\xc5',
  238. 'aring;': '\xe5',
  239. 'Ascr;': '\U0001d49c',
  240. 'ascr;': '\U0001d4b6',
  241. 'Assign;': '\u2254',
  242. 'ast;': '*',
  243. 'asymp;': '\u2248',
  244. 'asympeq;': '\u224d',
  245. 'Atilde': '\xc3',
  246. 'atilde': '\xe3',
  247. 'Atilde;': '\xc3',
  248. 'atilde;': '\xe3',
  249. 'Auml': '\xc4',
  250. 'auml': '\xe4',
  251. 'Auml;': '\xc4',
  252. 'auml;': '\xe4',
  253. 'awconint;': '\u2233',
  254. 'awint;': '\u2a11',
  255. 'backcong;': '\u224c',
  256. 'backepsilon;': '\u03f6',
  257. 'backprime;': '\u2035',
  258. 'backsim;': '\u223d',
  259. 'backsimeq;': '\u22cd',
  260. 'Backslash;': '\u2216',
  261. 'Barv;': '\u2ae7',
  262. 'barvee;': '\u22bd',
  263. 'Barwed;': '\u2306',
  264. 'barwed;': '\u2305',
  265. 'barwedge;': '\u2305',
  266. 'bbrk;': '\u23b5',
  267. 'bbrktbrk;': '\u23b6',
  268. 'bcong;': '\u224c',
  269. 'Bcy;': '\u0411',
  270. 'bcy;': '\u0431',
  271. 'bdquo;': '\u201e',
  272. 'becaus;': '\u2235',
  273. 'Because;': '\u2235',
  274. 'because;': '\u2235',
  275. 'bemptyv;': '\u29b0',
  276. 'bepsi;': '\u03f6',
  277. 'bernou;': '\u212c',
  278. 'Bernoullis;': '\u212c',
  279. 'Beta;': '\u0392',
  280. 'beta;': '\u03b2',
  281. 'beth;': '\u2136',
  282. 'between;': '\u226c',
  283. 'Bfr;': '\U0001d505',
  284. 'bfr;': '\U0001d51f',
  285. 'bigcap;': '\u22c2',
  286. 'bigcirc;': '\u25ef',
  287. 'bigcup;': '\u22c3',
  288. 'bigodot;': '\u2a00',
  289. 'bigoplus;': '\u2a01',
  290. 'bigotimes;': '\u2a02',
  291. 'bigsqcup;': '\u2a06',
  292. 'bigstar;': '\u2605',
  293. 'bigtriangledown;': '\u25bd',
  294. 'bigtriangleup;': '\u25b3',
  295. 'biguplus;': '\u2a04',
  296. 'bigvee;': '\u22c1',
  297. 'bigwedge;': '\u22c0',
  298. 'bkarow;': '\u290d',
  299. 'blacklozenge;': '\u29eb',
  300. 'blacksquare;': '\u25aa',
  301. 'blacktriangle;': '\u25b4',
  302. 'blacktriangledown;': '\u25be',
  303. 'blacktriangleleft;': '\u25c2',
  304. 'blacktriangleright;': '\u25b8',
  305. 'blank;': '\u2423',
  306. 'blk12;': '\u2592',
  307. 'blk14;': '\u2591',
  308. 'blk34;': '\u2593',
  309. 'block;': '\u2588',
  310. 'bne;': '=\u20e5',
  311. 'bnequiv;': '\u2261\u20e5',
  312. 'bNot;': '\u2aed',
  313. 'bnot;': '\u2310',
  314. 'Bopf;': '\U0001d539',
  315. 'bopf;': '\U0001d553',
  316. 'bot;': '\u22a5',
  317. 'bottom;': '\u22a5',
  318. 'bowtie;': '\u22c8',
  319. 'boxbox;': '\u29c9',
  320. 'boxDL;': '\u2557',
  321. 'boxDl;': '\u2556',
  322. 'boxdL;': '\u2555',
  323. 'boxdl;': '\u2510',
  324. 'boxDR;': '\u2554',
  325. 'boxDr;': '\u2553',
  326. 'boxdR;': '\u2552',
  327. 'boxdr;': '\u250c',
  328. 'boxH;': '\u2550',
  329. 'boxh;': '\u2500',
  330. 'boxHD;': '\u2566',
  331. 'boxHd;': '\u2564',
  332. 'boxhD;': '\u2565',
  333. 'boxhd;': '\u252c',
  334. 'boxHU;': '\u2569',
  335. 'boxHu;': '\u2567',
  336. 'boxhU;': '\u2568',
  337. 'boxhu;': '\u2534',
  338. 'boxminus;': '\u229f',
  339. 'boxplus;': '\u229e',
  340. 'boxtimes;': '\u22a0',
  341. 'boxUL;': '\u255d',
  342. 'boxUl;': '\u255c',
  343. 'boxuL;': '\u255b',
  344. 'boxul;': '\u2518',
  345. 'boxUR;': '\u255a',
  346. 'boxUr;': '\u2559',
  347. 'boxuR;': '\u2558',
  348. 'boxur;': '\u2514',
  349. 'boxV;': '\u2551',
  350. 'boxv;': '\u2502',
  351. 'boxVH;': '\u256c',
  352. 'boxVh;': '\u256b',
  353. 'boxvH;': '\u256a',
  354. 'boxvh;': '\u253c',
  355. 'boxVL;': '\u2563',
  356. 'boxVl;': '\u2562',
  357. 'boxvL;': '\u2561',
  358. 'boxvl;': '\u2524',
  359. 'boxVR;': '\u2560',
  360. 'boxVr;': '\u255f',
  361. 'boxvR;': '\u255e',
  362. 'boxvr;': '\u251c',
  363. 'bprime;': '\u2035',
  364. 'Breve;': '\u02d8',
  365. 'breve;': '\u02d8',
  366. 'brvbar': '\xa6',
  367. 'brvbar;': '\xa6',
  368. 'Bscr;': '\u212c',
  369. 'bscr;': '\U0001d4b7',
  370. 'bsemi;': '\u204f',
  371. 'bsim;': '\u223d',
  372. 'bsime;': '\u22cd',
  373. 'bsol;': '\\',
  374. 'bsolb;': '\u29c5',
  375. 'bsolhsub;': '\u27c8',
  376. 'bull;': '\u2022',
  377. 'bullet;': '\u2022',
  378. 'bump;': '\u224e',
  379. 'bumpE;': '\u2aae',
  380. 'bumpe;': '\u224f',
  381. 'Bumpeq;': '\u224e',
  382. 'bumpeq;': '\u224f',
  383. 'Cacute;': '\u0106',
  384. 'cacute;': '\u0107',
  385. 'Cap;': '\u22d2',
  386. 'cap;': '\u2229',
  387. 'capand;': '\u2a44',
  388. 'capbrcup;': '\u2a49',
  389. 'capcap;': '\u2a4b',
  390. 'capcup;': '\u2a47',
  391. 'capdot;': '\u2a40',
  392. 'CapitalDifferentialD;': '\u2145',
  393. 'caps;': '\u2229\ufe00',
  394. 'caret;': '\u2041',
  395. 'caron;': '\u02c7',
  396. 'Cayleys;': '\u212d',
  397. 'ccaps;': '\u2a4d',
  398. 'Ccaron;': '\u010c',
  399. 'ccaron;': '\u010d',
  400. 'Ccedil': '\xc7',
  401. 'ccedil': '\xe7',
  402. 'Ccedil;': '\xc7',
  403. 'ccedil;': '\xe7',
  404. 'Ccirc;': '\u0108',
  405. 'ccirc;': '\u0109',
  406. 'Cconint;': '\u2230',
  407. 'ccups;': '\u2a4c',
  408. 'ccupssm;': '\u2a50',
  409. 'Cdot;': '\u010a',
  410. 'cdot;': '\u010b',
  411. 'cedil': '\xb8',
  412. 'cedil;': '\xb8',
  413. 'Cedilla;': '\xb8',
  414. 'cemptyv;': '\u29b2',
  415. 'cent': '\xa2',
  416. 'cent;': '\xa2',
  417. 'CenterDot;': '\xb7',
  418. 'centerdot;': '\xb7',
  419. 'Cfr;': '\u212d',
  420. 'cfr;': '\U0001d520',
  421. 'CHcy;': '\u0427',
  422. 'chcy;': '\u0447',
  423. 'check;': '\u2713',
  424. 'checkmark;': '\u2713',
  425. 'Chi;': '\u03a7',
  426. 'chi;': '\u03c7',
  427. 'cir;': '\u25cb',
  428. 'circ;': '\u02c6',
  429. 'circeq;': '\u2257',
  430. 'circlearrowleft;': '\u21ba',
  431. 'circlearrowright;': '\u21bb',
  432. 'circledast;': '\u229b',
  433. 'circledcirc;': '\u229a',
  434. 'circleddash;': '\u229d',
  435. 'CircleDot;': '\u2299',
  436. 'circledR;': '\xae',
  437. 'circledS;': '\u24c8',
  438. 'CircleMinus;': '\u2296',
  439. 'CirclePlus;': '\u2295',
  440. 'CircleTimes;': '\u2297',
  441. 'cirE;': '\u29c3',
  442. 'cire;': '\u2257',
  443. 'cirfnint;': '\u2a10',
  444. 'cirmid;': '\u2aef',
  445. 'cirscir;': '\u29c2',
  446. 'ClockwiseContourIntegral;': '\u2232',
  447. 'CloseCurlyDoubleQuote;': '\u201d',
  448. 'CloseCurlyQuote;': '\u2019',
  449. 'clubs;': '\u2663',
  450. 'clubsuit;': '\u2663',
  451. 'Colon;': '\u2237',
  452. 'colon;': ':',
  453. 'Colone;': '\u2a74',
  454. 'colone;': '\u2254',
  455. 'coloneq;': '\u2254',
  456. 'comma;': ',',
  457. 'commat;': '@',
  458. 'comp;': '\u2201',
  459. 'compfn;': '\u2218',
  460. 'complement;': '\u2201',
  461. 'complexes;': '\u2102',
  462. 'cong;': '\u2245',
  463. 'congdot;': '\u2a6d',
  464. 'Congruent;': '\u2261',
  465. 'Conint;': '\u222f',
  466. 'conint;': '\u222e',
  467. 'ContourIntegral;': '\u222e',
  468. 'Copf;': '\u2102',
  469. 'copf;': '\U0001d554',
  470. 'coprod;': '\u2210',
  471. 'Coproduct;': '\u2210',
  472. 'COPY': '\xa9',
  473. 'copy': '\xa9',
  474. 'COPY;': '\xa9',
  475. 'copy;': '\xa9',
  476. 'copysr;': '\u2117',
  477. 'CounterClockwiseContourIntegral;': '\u2233',
  478. 'crarr;': '\u21b5',
  479. 'Cross;': '\u2a2f',
  480. 'cross;': '\u2717',
  481. 'Cscr;': '\U0001d49e',
  482. 'cscr;': '\U0001d4b8',
  483. 'csub;': '\u2acf',
  484. 'csube;': '\u2ad1',
  485. 'csup;': '\u2ad0',
  486. 'csupe;': '\u2ad2',
  487. 'ctdot;': '\u22ef',
  488. 'cudarrl;': '\u2938',
  489. 'cudarrr;': '\u2935',
  490. 'cuepr;': '\u22de',
  491. 'cuesc;': '\u22df',
  492. 'cularr;': '\u21b6',
  493. 'cularrp;': '\u293d',
  494. 'Cup;': '\u22d3',
  495. 'cup;': '\u222a',
  496. 'cupbrcap;': '\u2a48',
  497. 'CupCap;': '\u224d',
  498. 'cupcap;': '\u2a46',
  499. 'cupcup;': '\u2a4a',
  500. 'cupdot;': '\u228d',
  501. 'cupor;': '\u2a45',
  502. 'cups;': '\u222a\ufe00',
  503. 'curarr;': '\u21b7',
  504. 'curarrm;': '\u293c',
  505. 'curlyeqprec;': '\u22de',
  506. 'curlyeqsucc;': '\u22df',
  507. 'curlyvee;': '\u22ce',
  508. 'curlywedge;': '\u22cf',
  509. 'curren': '\xa4',
  510. 'curren;': '\xa4',
  511. 'curvearrowleft;': '\u21b6',
  512. 'curvearrowright;': '\u21b7',
  513. 'cuvee;': '\u22ce',
  514. 'cuwed;': '\u22cf',
  515. 'cwconint;': '\u2232',
  516. 'cwint;': '\u2231',
  517. 'cylcty;': '\u232d',
  518. 'Dagger;': '\u2021',
  519. 'dagger;': '\u2020',
  520. 'daleth;': '\u2138',
  521. 'Darr;': '\u21a1',
  522. 'dArr;': '\u21d3',
  523. 'darr;': '\u2193',
  524. 'dash;': '\u2010',
  525. 'Dashv;': '\u2ae4',
  526. 'dashv;': '\u22a3',
  527. 'dbkarow;': '\u290f',
  528. 'dblac;': '\u02dd',
  529. 'Dcaron;': '\u010e',
  530. 'dcaron;': '\u010f',
  531. 'Dcy;': '\u0414',
  532. 'dcy;': '\u0434',
  533. 'DD;': '\u2145',
  534. 'dd;': '\u2146',
  535. 'ddagger;': '\u2021',
  536. 'ddarr;': '\u21ca',
  537. 'DDotrahd;': '\u2911',
  538. 'ddotseq;': '\u2a77',
  539. 'deg': '\xb0',
  540. 'deg;': '\xb0',
  541. 'Del;': '\u2207',
  542. 'Delta;': '\u0394',
  543. 'delta;': '\u03b4',
  544. 'demptyv;': '\u29b1',
  545. 'dfisht;': '\u297f',
  546. 'Dfr;': '\U0001d507',
  547. 'dfr;': '\U0001d521',
  548. 'dHar;': '\u2965',
  549. 'dharl;': '\u21c3',
  550. 'dharr;': '\u21c2',
  551. 'DiacriticalAcute;': '\xb4',
  552. 'DiacriticalDot;': '\u02d9',
  553. 'DiacriticalDoubleAcute;': '\u02dd',
  554. 'DiacriticalGrave;': '`',
  555. 'DiacriticalTilde;': '\u02dc',
  556. 'diam;': '\u22c4',
  557. 'Diamond;': '\u22c4',
  558. 'diamond;': '\u22c4',
  559. 'diamondsuit;': '\u2666',
  560. 'diams;': '\u2666',
  561. 'die;': '\xa8',
  562. 'DifferentialD;': '\u2146',
  563. 'digamma;': '\u03dd',
  564. 'disin;': '\u22f2',
  565. 'div;': '\xf7',
  566. 'divide': '\xf7',
  567. 'divide;': '\xf7',
  568. 'divideontimes;': '\u22c7',
  569. 'divonx;': '\u22c7',
  570. 'DJcy;': '\u0402',
  571. 'djcy;': '\u0452',
  572. 'dlcorn;': '\u231e',
  573. 'dlcrop;': '\u230d',
  574. 'dollar;': '$',
  575. 'Dopf;': '\U0001d53b',
  576. 'dopf;': '\U0001d555',
  577. 'Dot;': '\xa8',
  578. 'dot;': '\u02d9',
  579. 'DotDot;': '\u20dc',
  580. 'doteq;': '\u2250',
  581. 'doteqdot;': '\u2251',
  582. 'DotEqual;': '\u2250',
  583. 'dotminus;': '\u2238',
  584. 'dotplus;': '\u2214',
  585. 'dotsquare;': '\u22a1',
  586. 'doublebarwedge;': '\u2306',
  587. 'DoubleContourIntegral;': '\u222f',
  588. 'DoubleDot;': '\xa8',
  589. 'DoubleDownArrow;': '\u21d3',
  590. 'DoubleLeftArrow;': '\u21d0',
  591. 'DoubleLeftRightArrow;': '\u21d4',
  592. 'DoubleLeftTee;': '\u2ae4',
  593. 'DoubleLongLeftArrow;': '\u27f8',
  594. 'DoubleLongLeftRightArrow;': '\u27fa',
  595. 'DoubleLongRightArrow;': '\u27f9',
  596. 'DoubleRightArrow;': '\u21d2',
  597. 'DoubleRightTee;': '\u22a8',
  598. 'DoubleUpArrow;': '\u21d1',
  599. 'DoubleUpDownArrow;': '\u21d5',
  600. 'DoubleVerticalBar;': '\u2225',
  601. 'DownArrow;': '\u2193',
  602. 'Downarrow;': '\u21d3',
  603. 'downarrow;': '\u2193',
  604. 'DownArrowBar;': '\u2913',
  605. 'DownArrowUpArrow;': '\u21f5',
  606. 'DownBreve;': '\u0311',
  607. 'downdownarrows;': '\u21ca',
  608. 'downharpoonleft;': '\u21c3',
  609. 'downharpoonright;': '\u21c2',
  610. 'DownLeftRightVector;': '\u2950',
  611. 'DownLeftTeeVector;': '\u295e',
  612. 'DownLeftVector;': '\u21bd',
  613. 'DownLeftVectorBar;': '\u2956',
  614. 'DownRightTeeVector;': '\u295f',
  615. 'DownRightVector;': '\u21c1',
  616. 'DownRightVectorBar;': '\u2957',
  617. 'DownTee;': '\u22a4',
  618. 'DownTeeArrow;': '\u21a7',
  619. 'drbkarow;': '\u2910',
  620. 'drcorn;': '\u231f',
  621. 'drcrop;': '\u230c',
  622. 'Dscr;': '\U0001d49f',
  623. 'dscr;': '\U0001d4b9',
  624. 'DScy;': '\u0405',
  625. 'dscy;': '\u0455',
  626. 'dsol;': '\u29f6',
  627. 'Dstrok;': '\u0110',
  628. 'dstrok;': '\u0111',
  629. 'dtdot;': '\u22f1',
  630. 'dtri;': '\u25bf',
  631. 'dtrif;': '\u25be',
  632. 'duarr;': '\u21f5',
  633. 'duhar;': '\u296f',
  634. 'dwangle;': '\u29a6',
  635. 'DZcy;': '\u040f',
  636. 'dzcy;': '\u045f',
  637. 'dzigrarr;': '\u27ff',
  638. 'Eacute': '\xc9',
  639. 'eacute': '\xe9',
  640. 'Eacute;': '\xc9',
  641. 'eacute;': '\xe9',
  642. 'easter;': '\u2a6e',
  643. 'Ecaron;': '\u011a',
  644. 'ecaron;': '\u011b',
  645. 'ecir;': '\u2256',
  646. 'Ecirc': '\xca',
  647. 'ecirc': '\xea',
  648. 'Ecirc;': '\xca',
  649. 'ecirc;': '\xea',
  650. 'ecolon;': '\u2255',
  651. 'Ecy;': '\u042d',
  652. 'ecy;': '\u044d',
  653. 'eDDot;': '\u2a77',
  654. 'Edot;': '\u0116',
  655. 'eDot;': '\u2251',
  656. 'edot;': '\u0117',
  657. 'ee;': '\u2147',
  658. 'efDot;': '\u2252',
  659. 'Efr;': '\U0001d508',
  660. 'efr;': '\U0001d522',
  661. 'eg;': '\u2a9a',
  662. 'Egrave': '\xc8',
  663. 'egrave': '\xe8',
  664. 'Egrave;': '\xc8',
  665. 'egrave;': '\xe8',
  666. 'egs;': '\u2a96',
  667. 'egsdot;': '\u2a98',
  668. 'el;': '\u2a99',
  669. 'Element;': '\u2208',
  670. 'elinters;': '\u23e7',
  671. 'ell;': '\u2113',
  672. 'els;': '\u2a95',
  673. 'elsdot;': '\u2a97',
  674. 'Emacr;': '\u0112',
  675. 'emacr;': '\u0113',
  676. 'empty;': '\u2205',
  677. 'emptyset;': '\u2205',
  678. 'EmptySmallSquare;': '\u25fb',
  679. 'emptyv;': '\u2205',
  680. 'EmptyVerySmallSquare;': '\u25ab',
  681. 'emsp13;': '\u2004',
  682. 'emsp14;': '\u2005',
  683. 'emsp;': '\u2003',
  684. 'ENG;': '\u014a',
  685. 'eng;': '\u014b',
  686. 'ensp;': '\u2002',
  687. 'Eogon;': '\u0118',
  688. 'eogon;': '\u0119',
  689. 'Eopf;': '\U0001d53c',
  690. 'eopf;': '\U0001d556',
  691. 'epar;': '\u22d5',
  692. 'eparsl;': '\u29e3',
  693. 'eplus;': '\u2a71',
  694. 'epsi;': '\u03b5',
  695. 'Epsilon;': '\u0395',
  696. 'epsilon;': '\u03b5',
  697. 'epsiv;': '\u03f5',
  698. 'eqcirc;': '\u2256',
  699. 'eqcolon;': '\u2255',
  700. 'eqsim;': '\u2242',
  701. 'eqslantgtr;': '\u2a96',
  702. 'eqslantless;': '\u2a95',
  703. 'Equal;': '\u2a75',
  704. 'equals;': '=',
  705. 'EqualTilde;': '\u2242',
  706. 'equest;': '\u225f',
  707. 'Equilibrium;': '\u21cc',
  708. 'equiv;': '\u2261',
  709. 'equivDD;': '\u2a78',
  710. 'eqvparsl;': '\u29e5',
  711. 'erarr;': '\u2971',
  712. 'erDot;': '\u2253',
  713. 'Escr;': '\u2130',
  714. 'escr;': '\u212f',
  715. 'esdot;': '\u2250',
  716. 'Esim;': '\u2a73',
  717. 'esim;': '\u2242',
  718. 'Eta;': '\u0397',
  719. 'eta;': '\u03b7',
  720. 'ETH': '\xd0',
  721. 'eth': '\xf0',
  722. 'ETH;': '\xd0',
  723. 'eth;': '\xf0',
  724. 'Euml': '\xcb',
  725. 'euml': '\xeb',
  726. 'Euml;': '\xcb',
  727. 'euml;': '\xeb',
  728. 'euro;': '\u20ac',
  729. 'excl;': '!',
  730. 'exist;': '\u2203',
  731. 'Exists;': '\u2203',
  732. 'expectation;': '\u2130',
  733. 'ExponentialE;': '\u2147',
  734. 'exponentiale;': '\u2147',
  735. 'fallingdotseq;': '\u2252',
  736. 'Fcy;': '\u0424',
  737. 'fcy;': '\u0444',
  738. 'female;': '\u2640',
  739. 'ffilig;': '\ufb03',
  740. 'fflig;': '\ufb00',
  741. 'ffllig;': '\ufb04',
  742. 'Ffr;': '\U0001d509',
  743. 'ffr;': '\U0001d523',
  744. 'filig;': '\ufb01',
  745. 'FilledSmallSquare;': '\u25fc',
  746. 'FilledVerySmallSquare;': '\u25aa',
  747. 'fjlig;': 'fj',
  748. 'flat;': '\u266d',
  749. 'fllig;': '\ufb02',
  750. 'fltns;': '\u25b1',
  751. 'fnof;': '\u0192',
  752. 'Fopf;': '\U0001d53d',
  753. 'fopf;': '\U0001d557',
  754. 'ForAll;': '\u2200',
  755. 'forall;': '\u2200',
  756. 'fork;': '\u22d4',
  757. 'forkv;': '\u2ad9',
  758. 'Fouriertrf;': '\u2131',
  759. 'fpartint;': '\u2a0d',
  760. 'frac12': '\xbd',
  761. 'frac12;': '\xbd',
  762. 'frac13;': '\u2153',
  763. 'frac14': '\xbc',
  764. 'frac14;': '\xbc',
  765. 'frac15;': '\u2155',
  766. 'frac16;': '\u2159',
  767. 'frac18;': '\u215b',
  768. 'frac23;': '\u2154',
  769. 'frac25;': '\u2156',
  770. 'frac34': '\xbe',
  771. 'frac34;': '\xbe',
  772. 'frac35;': '\u2157',
  773. 'frac38;': '\u215c',
  774. 'frac45;': '\u2158',
  775. 'frac56;': '\u215a',
  776. 'frac58;': '\u215d',
  777. 'frac78;': '\u215e',
  778. 'frasl;': '\u2044',
  779. 'frown;': '\u2322',
  780. 'Fscr;': '\u2131',
  781. 'fscr;': '\U0001d4bb',
  782. 'gacute;': '\u01f5',
  783. 'Gamma;': '\u0393',
  784. 'gamma;': '\u03b3',
  785. 'Gammad;': '\u03dc',
  786. 'gammad;': '\u03dd',
  787. 'gap;': '\u2a86',
  788. 'Gbreve;': '\u011e',
  789. 'gbreve;': '\u011f',
  790. 'Gcedil;': '\u0122',
  791. 'Gcirc;': '\u011c',
  792. 'gcirc;': '\u011d',
  793. 'Gcy;': '\u0413',
  794. 'gcy;': '\u0433',
  795. 'Gdot;': '\u0120',
  796. 'gdot;': '\u0121',
  797. 'gE;': '\u2267',
  798. 'ge;': '\u2265',
  799. 'gEl;': '\u2a8c',
  800. 'gel;': '\u22db',
  801. 'geq;': '\u2265',
  802. 'geqq;': '\u2267',
  803. 'geqslant;': '\u2a7e',
  804. 'ges;': '\u2a7e',
  805. 'gescc;': '\u2aa9',
  806. 'gesdot;': '\u2a80',
  807. 'gesdoto;': '\u2a82',
  808. 'gesdotol;': '\u2a84',
  809. 'gesl;': '\u22db\ufe00',
  810. 'gesles;': '\u2a94',
  811. 'Gfr;': '\U0001d50a',
  812. 'gfr;': '\U0001d524',
  813. 'Gg;': '\u22d9',
  814. 'gg;': '\u226b',
  815. 'ggg;': '\u22d9',
  816. 'gimel;': '\u2137',
  817. 'GJcy;': '\u0403',
  818. 'gjcy;': '\u0453',
  819. 'gl;': '\u2277',
  820. 'gla;': '\u2aa5',
  821. 'glE;': '\u2a92',
  822. 'glj;': '\u2aa4',
  823. 'gnap;': '\u2a8a',
  824. 'gnapprox;': '\u2a8a',
  825. 'gnE;': '\u2269',
  826. 'gne;': '\u2a88',
  827. 'gneq;': '\u2a88',
  828. 'gneqq;': '\u2269',
  829. 'gnsim;': '\u22e7',
  830. 'Gopf;': '\U0001d53e',
  831. 'gopf;': '\U0001d558',
  832. 'grave;': '`',
  833. 'GreaterEqual;': '\u2265',
  834. 'GreaterEqualLess;': '\u22db',
  835. 'GreaterFullEqual;': '\u2267',
  836. 'GreaterGreater;': '\u2aa2',
  837. 'GreaterLess;': '\u2277',
  838. 'GreaterSlantEqual;': '\u2a7e',
  839. 'GreaterTilde;': '\u2273',
  840. 'Gscr;': '\U0001d4a2',
  841. 'gscr;': '\u210a',
  842. 'gsim;': '\u2273',
  843. 'gsime;': '\u2a8e',
  844. 'gsiml;': '\u2a90',
  845. 'GT': '>',
  846. 'gt': '>',
  847. 'GT;': '>',
  848. 'Gt;': '\u226b',
  849. 'gt;': '>',
  850. 'gtcc;': '\u2aa7',
  851. 'gtcir;': '\u2a7a',
  852. 'gtdot;': '\u22d7',
  853. 'gtlPar;': '\u2995',
  854. 'gtquest;': '\u2a7c',
  855. 'gtrapprox;': '\u2a86',
  856. 'gtrarr;': '\u2978',
  857. 'gtrdot;': '\u22d7',
  858. 'gtreqless;': '\u22db',
  859. 'gtreqqless;': '\u2a8c',
  860. 'gtrless;': '\u2277',
  861. 'gtrsim;': '\u2273',
  862. 'gvertneqq;': '\u2269\ufe00',
  863. 'gvnE;': '\u2269\ufe00',
  864. 'Hacek;': '\u02c7',
  865. 'hairsp;': '\u200a',
  866. 'half;': '\xbd',
  867. 'hamilt;': '\u210b',
  868. 'HARDcy;': '\u042a',
  869. 'hardcy;': '\u044a',
  870. 'hArr;': '\u21d4',
  871. 'harr;': '\u2194',
  872. 'harrcir;': '\u2948',
  873. 'harrw;': '\u21ad',
  874. 'Hat;': '^',
  875. 'hbar;': '\u210f',
  876. 'Hcirc;': '\u0124',
  877. 'hcirc;': '\u0125',
  878. 'hearts;': '\u2665',
  879. 'heartsuit;': '\u2665',
  880. 'hellip;': '\u2026',
  881. 'hercon;': '\u22b9',
  882. 'Hfr;': '\u210c',
  883. 'hfr;': '\U0001d525',
  884. 'HilbertSpace;': '\u210b',
  885. 'hksearow;': '\u2925',
  886. 'hkswarow;': '\u2926',
  887. 'hoarr;': '\u21ff',
  888. 'homtht;': '\u223b',
  889. 'hookleftarrow;': '\u21a9',
  890. 'hookrightarrow;': '\u21aa',
  891. 'Hopf;': '\u210d',
  892. 'hopf;': '\U0001d559',
  893. 'horbar;': '\u2015',
  894. 'HorizontalLine;': '\u2500',
  895. 'Hscr;': '\u210b',
  896. 'hscr;': '\U0001d4bd',
  897. 'hslash;': '\u210f',
  898. 'Hstrok;': '\u0126',
  899. 'hstrok;': '\u0127',
  900. 'HumpDownHump;': '\u224e',
  901. 'HumpEqual;': '\u224f',
  902. 'hybull;': '\u2043',
  903. 'hyphen;': '\u2010',
  904. 'Iacute': '\xcd',
  905. 'iacute': '\xed',
  906. 'Iacute;': '\xcd',
  907. 'iacute;': '\xed',
  908. 'ic;': '\u2063',
  909. 'Icirc': '\xce',
  910. 'icirc': '\xee',
  911. 'Icirc;': '\xce',
  912. 'icirc;': '\xee',
  913. 'Icy;': '\u0418',
  914. 'icy;': '\u0438',
  915. 'Idot;': '\u0130',
  916. 'IEcy;': '\u0415',
  917. 'iecy;': '\u0435',
  918. 'iexcl': '\xa1',
  919. 'iexcl;': '\xa1',
  920. 'iff;': '\u21d4',
  921. 'Ifr;': '\u2111',
  922. 'ifr;': '\U0001d526',
  923. 'Igrave': '\xcc',
  924. 'igrave': '\xec',
  925. 'Igrave;': '\xcc',
  926. 'igrave;': '\xec',
  927. 'ii;': '\u2148',
  928. 'iiiint;': '\u2a0c',
  929. 'iiint;': '\u222d',
  930. 'iinfin;': '\u29dc',
  931. 'iiota;': '\u2129',
  932. 'IJlig;': '\u0132',
  933. 'ijlig;': '\u0133',
  934. 'Im;': '\u2111',
  935. 'Imacr;': '\u012a',
  936. 'imacr;': '\u012b',
  937. 'image;': '\u2111',
  938. 'ImaginaryI;': '\u2148',
  939. 'imagline;': '\u2110',
  940. 'imagpart;': '\u2111',
  941. 'imath;': '\u0131',
  942. 'imof;': '\u22b7',
  943. 'imped;': '\u01b5',
  944. 'Implies;': '\u21d2',
  945. 'in;': '\u2208',
  946. 'incare;': '\u2105',
  947. 'infin;': '\u221e',
  948. 'infintie;': '\u29dd',
  949. 'inodot;': '\u0131',
  950. 'Int;': '\u222c',
  951. 'int;': '\u222b',
  952. 'intcal;': '\u22ba',
  953. 'integers;': '\u2124',
  954. 'Integral;': '\u222b',
  955. 'intercal;': '\u22ba',
  956. 'Intersection;': '\u22c2',
  957. 'intlarhk;': '\u2a17',
  958. 'intprod;': '\u2a3c',
  959. 'InvisibleComma;': '\u2063',
  960. 'InvisibleTimes;': '\u2062',
  961. 'IOcy;': '\u0401',
  962. 'iocy;': '\u0451',
  963. 'Iogon;': '\u012e',
  964. 'iogon;': '\u012f',
  965. 'Iopf;': '\U0001d540',
  966. 'iopf;': '\U0001d55a',
  967. 'Iota;': '\u0399',
  968. 'iota;': '\u03b9',
  969. 'iprod;': '\u2a3c',
  970. 'iquest': '\xbf',
  971. 'iquest;': '\xbf',
  972. 'Iscr;': '\u2110',
  973. 'iscr;': '\U0001d4be',
  974. 'isin;': '\u2208',
  975. 'isindot;': '\u22f5',
  976. 'isinE;': '\u22f9',
  977. 'isins;': '\u22f4',
  978. 'isinsv;': '\u22f3',
  979. 'isinv;': '\u2208',
  980. 'it;': '\u2062',
  981. 'Itilde;': '\u0128',
  982. 'itilde;': '\u0129',
  983. 'Iukcy;': '\u0406',
  984. 'iukcy;': '\u0456',
  985. 'Iuml': '\xcf',
  986. 'iuml': '\xef',
  987. 'Iuml;': '\xcf',
  988. 'iuml;': '\xef',
  989. 'Jcirc;': '\u0134',
  990. 'jcirc;': '\u0135',
  991. 'Jcy;': '\u0419',
  992. 'jcy;': '\u0439',
  993. 'Jfr;': '\U0001d50d',
  994. 'jfr;': '\U0001d527',
  995. 'jmath;': '\u0237',
  996. 'Jopf;': '\U0001d541',
  997. 'jopf;': '\U0001d55b',
  998. 'Jscr;': '\U0001d4a5',
  999. 'jscr;': '\U0001d4bf',
  1000. 'Jsercy;': '\u0408',
  1001. 'jsercy;': '\u0458',
  1002. 'Jukcy;': '\u0404',
  1003. 'jukcy;': '\u0454',
  1004. 'Kappa;': '\u039a',
  1005. 'kappa;': '\u03ba',
  1006. 'kappav;': '\u03f0',
  1007. 'Kcedil;': '\u0136',
  1008. 'kcedil;': '\u0137',
  1009. 'Kcy;': '\u041a',
  1010. 'kcy;': '\u043a',
  1011. 'Kfr;': '\U0001d50e',
  1012. 'kfr;': '\U0001d528',
  1013. 'kgreen;': '\u0138',
  1014. 'KHcy;': '\u0425',
  1015. 'khcy;': '\u0445',
  1016. 'KJcy;': '\u040c',
  1017. 'kjcy;': '\u045c',
  1018. 'Kopf;': '\U0001d542',
  1019. 'kopf;': '\U0001d55c',
  1020. 'Kscr;': '\U0001d4a6',
  1021. 'kscr;': '\U0001d4c0',
  1022. 'lAarr;': '\u21da',
  1023. 'Lacute;': '\u0139',
  1024. 'lacute;': '\u013a',
  1025. 'laemptyv;': '\u29b4',
  1026. 'lagran;': '\u2112',
  1027. 'Lambda;': '\u039b',
  1028. 'lambda;': '\u03bb',
  1029. 'Lang;': '\u27ea',
  1030. 'lang;': '\u27e8',
  1031. 'langd;': '\u2991',
  1032. 'langle;': '\u27e8',
  1033. 'lap;': '\u2a85',
  1034. 'Laplacetrf;': '\u2112',
  1035. 'laquo': '\xab',
  1036. 'laquo;': '\xab',
  1037. 'Larr;': '\u219e',
  1038. 'lArr;': '\u21d0',
  1039. 'larr;': '\u2190',
  1040. 'larrb;': '\u21e4',
  1041. 'larrbfs;': '\u291f',
  1042. 'larrfs;': '\u291d',
  1043. 'larrhk;': '\u21a9',
  1044. 'larrlp;': '\u21ab',
  1045. 'larrpl;': '\u2939',
  1046. 'larrsim;': '\u2973',
  1047. 'larrtl;': '\u21a2',
  1048. 'lat;': '\u2aab',
  1049. 'lAtail;': '\u291b',
  1050. 'latail;': '\u2919',
  1051. 'late;': '\u2aad',
  1052. 'lates;': '\u2aad\ufe00',
  1053. 'lBarr;': '\u290e',
  1054. 'lbarr;': '\u290c',
  1055. 'lbbrk;': '\u2772',
  1056. 'lbrace;': '{',
  1057. 'lbrack;': '[',
  1058. 'lbrke;': '\u298b',
  1059. 'lbrksld;': '\u298f',
  1060. 'lbrkslu;': '\u298d',
  1061. 'Lcaron;': '\u013d',
  1062. 'lcaron;': '\u013e',
  1063. 'Lcedil;': '\u013b',
  1064. 'lcedil;': '\u013c',
  1065. 'lceil;': '\u2308',
  1066. 'lcub;': '{',
  1067. 'Lcy;': '\u041b',
  1068. 'lcy;': '\u043b',
  1069. 'ldca;': '\u2936',
  1070. 'ldquo;': '\u201c',
  1071. 'ldquor;': '\u201e',
  1072. 'ldrdhar;': '\u2967',
  1073. 'ldrushar;': '\u294b',
  1074. 'ldsh;': '\u21b2',
  1075. 'lE;': '\u2266',
  1076. 'le;': '\u2264',
  1077. 'LeftAngleBracket;': '\u27e8',
  1078. 'LeftArrow;': '\u2190',
  1079. 'Leftarrow;': '\u21d0',
  1080. 'leftarrow;': '\u2190',
  1081. 'LeftArrowBar;': '\u21e4',
  1082. 'LeftArrowRightArrow;': '\u21c6',
  1083. 'leftarrowtail;': '\u21a2',
  1084. 'LeftCeiling;': '\u2308',
  1085. 'LeftDoubleBracket;': '\u27e6',
  1086. 'LeftDownTeeVector;': '\u2961',
  1087. 'LeftDownVector;': '\u21c3',
  1088. 'LeftDownVectorBar;': '\u2959',
  1089. 'LeftFloor;': '\u230a',
  1090. 'leftharpoondown;': '\u21bd',
  1091. 'leftharpoonup;': '\u21bc',
  1092. 'leftleftarrows;': '\u21c7',
  1093. 'LeftRightArrow;': '\u2194',
  1094. 'Leftrightarrow;': '\u21d4',
  1095. 'leftrightarrow;': '\u2194',
  1096. 'leftrightarrows;': '\u21c6',
  1097. 'leftrightharpoons;': '\u21cb',
  1098. 'leftrightsquigarrow;': '\u21ad',
  1099. 'LeftRightVector;': '\u294e',
  1100. 'LeftTee;': '\u22a3',
  1101. 'LeftTeeArrow;': '\u21a4',
  1102. 'LeftTeeVector;': '\u295a',
  1103. 'leftthreetimes;': '\u22cb',
  1104. 'LeftTriangle;': '\u22b2',
  1105. 'LeftTriangleBar;': '\u29cf',
  1106. 'LeftTriangleEqual;': '\u22b4',
  1107. 'LeftUpDownVector;': '\u2951',
  1108. 'LeftUpTeeVector;': '\u2960',
  1109. 'LeftUpVector;': '\u21bf',
  1110. 'LeftUpVectorBar;': '\u2958',
  1111. 'LeftVector;': '\u21bc',
  1112. 'LeftVectorBar;': '\u2952',
  1113. 'lEg;': '\u2a8b',
  1114. 'leg;': '\u22da',
  1115. 'leq;': '\u2264',
  1116. 'leqq;': '\u2266',
  1117. 'leqslant;': '\u2a7d',
  1118. 'les;': '\u2a7d',
  1119. 'lescc;': '\u2aa8',
  1120. 'lesdot;': '\u2a7f',
  1121. 'lesdoto;': '\u2a81',
  1122. 'lesdotor;': '\u2a83',
  1123. 'lesg;': '\u22da\ufe00',
  1124. 'lesges;': '\u2a93',
  1125. 'lessapprox;': '\u2a85',
  1126. 'lessdot;': '\u22d6',
  1127. 'lesseqgtr;': '\u22da',
  1128. 'lesseqqgtr;': '\u2a8b',
  1129. 'LessEqualGreater;': '\u22da',
  1130. 'LessFullEqual;': '\u2266',
  1131. 'LessGreater;': '\u2276',
  1132. 'lessgtr;': '\u2276',
  1133. 'LessLess;': '\u2aa1',
  1134. 'lesssim;': '\u2272',
  1135. 'LessSlantEqual;': '\u2a7d',
  1136. 'LessTilde;': '\u2272',
  1137. 'lfisht;': '\u297c',
  1138. 'lfloor;': '\u230a',
  1139. 'Lfr;': '\U0001d50f',
  1140. 'lfr;': '\U0001d529',
  1141. 'lg;': '\u2276',
  1142. 'lgE;': '\u2a91',
  1143. 'lHar;': '\u2962',
  1144. 'lhard;': '\u21bd',
  1145. 'lharu;': '\u21bc',
  1146. 'lharul;': '\u296a',
  1147. 'lhblk;': '\u2584',
  1148. 'LJcy;': '\u0409',
  1149. 'ljcy;': '\u0459',
  1150. 'Ll;': '\u22d8',
  1151. 'll;': '\u226a',
  1152. 'llarr;': '\u21c7',
  1153. 'llcorner;': '\u231e',
  1154. 'Lleftarrow;': '\u21da',
  1155. 'llhard;': '\u296b',
  1156. 'lltri;': '\u25fa',
  1157. 'Lmidot;': '\u013f',
  1158. 'lmidot;': '\u0140',
  1159. 'lmoust;': '\u23b0',
  1160. 'lmoustache;': '\u23b0',
  1161. 'lnap;': '\u2a89',
  1162. 'lnapprox;': '\u2a89',
  1163. 'lnE;': '\u2268',
  1164. 'lne;': '\u2a87',
  1165. 'lneq;': '\u2a87',
  1166. 'lneqq;': '\u2268',
  1167. 'lnsim;': '\u22e6',
  1168. 'loang;': '\u27ec',
  1169. 'loarr;': '\u21fd',
  1170. 'lobrk;': '\u27e6',
  1171. 'LongLeftArrow;': '\u27f5',
  1172. 'Longleftarrow;': '\u27f8',
  1173. 'longleftarrow;': '\u27f5',
  1174. 'LongLeftRightArrow;': '\u27f7',
  1175. 'Longleftrightarrow;': '\u27fa',
  1176. 'longleftrightarrow;': '\u27f7',
  1177. 'longmapsto;': '\u27fc',
  1178. 'LongRightArrow;': '\u27f6',
  1179. 'Longrightarrow;': '\u27f9',
  1180. 'longrightarrow;': '\u27f6',
  1181. 'looparrowleft;': '\u21ab',
  1182. 'looparrowright;': '\u21ac',
  1183. 'lopar;': '\u2985',
  1184. 'Lopf;': '\U0001d543',
  1185. 'lopf;': '\U0001d55d',
  1186. 'loplus;': '\u2a2d',
  1187. 'lotimes;': '\u2a34',
  1188. 'lowast;': '\u2217',
  1189. 'lowbar;': '_',
  1190. 'LowerLeftArrow;': '\u2199',
  1191. 'LowerRightArrow;': '\u2198',
  1192. 'loz;': '\u25ca',
  1193. 'lozenge;': '\u25ca',
  1194. 'lozf;': '\u29eb',
  1195. 'lpar;': '(',
  1196. 'lparlt;': '\u2993',
  1197. 'lrarr;': '\u21c6',
  1198. 'lrcorner;': '\u231f',
  1199. 'lrhar;': '\u21cb',
  1200. 'lrhard;': '\u296d',
  1201. 'lrm;': '\u200e',
  1202. 'lrtri;': '\u22bf',
  1203. 'lsaquo;': '\u2039',
  1204. 'Lscr;': '\u2112',
  1205. 'lscr;': '\U0001d4c1',
  1206. 'Lsh;': '\u21b0',
  1207. 'lsh;': '\u21b0',
  1208. 'lsim;': '\u2272',
  1209. 'lsime;': '\u2a8d',
  1210. 'lsimg;': '\u2a8f',
  1211. 'lsqb;': '[',
  1212. 'lsquo;': '\u2018',
  1213. 'lsquor;': '\u201a',
  1214. 'Lstrok;': '\u0141',
  1215. 'lstrok;': '\u0142',
  1216. 'LT': '<',
  1217. 'lt': '<',
  1218. 'LT;': '<',
  1219. 'Lt;': '\u226a',
  1220. 'lt;': '<',
  1221. 'ltcc;': '\u2aa6',
  1222. 'ltcir;': '\u2a79',
  1223. 'ltdot;': '\u22d6',
  1224. 'lthree;': '\u22cb',
  1225. 'ltimes;': '\u22c9',
  1226. 'ltlarr;': '\u2976',
  1227. 'ltquest;': '\u2a7b',
  1228. 'ltri;': '\u25c3',
  1229. 'ltrie;': '\u22b4',
  1230. 'ltrif;': '\u25c2',
  1231. 'ltrPar;': '\u2996',
  1232. 'lurdshar;': '\u294a',
  1233. 'luruhar;': '\u2966',
  1234. 'lvertneqq;': '\u2268\ufe00',
  1235. 'lvnE;': '\u2268\ufe00',
  1236. 'macr': '\xaf',
  1237. 'macr;': '\xaf',
  1238. 'male;': '\u2642',
  1239. 'malt;': '\u2720',
  1240. 'maltese;': '\u2720',
  1241. 'Map;': '\u2905',
  1242. 'map;': '\u21a6',
  1243. 'mapsto;': '\u21a6',
  1244. 'mapstodown;': '\u21a7',
  1245. 'mapstoleft;': '\u21a4',
  1246. 'mapstoup;': '\u21a5',
  1247. 'marker;': '\u25ae',
  1248. 'mcomma;': '\u2a29',
  1249. 'Mcy;': '\u041c',
  1250. 'mcy;': '\u043c',
  1251. 'mdash;': '\u2014',
  1252. 'mDDot;': '\u223a',
  1253. 'measuredangle;': '\u2221',
  1254. 'MediumSpace;': '\u205f',
  1255. 'Mellintrf;': '\u2133',
  1256. 'Mfr;': '\U0001d510',
  1257. 'mfr;': '\U0001d52a',
  1258. 'mho;': '\u2127',
  1259. 'micro': '\xb5',
  1260. 'micro;': '\xb5',
  1261. 'mid;': '\u2223',
  1262. 'midast;': '*',
  1263. 'midcir;': '\u2af0',
  1264. 'middot': '\xb7',
  1265. 'middot;': '\xb7',
  1266. 'minus;': '\u2212',
  1267. 'minusb;': '\u229f',
  1268. 'minusd;': '\u2238',
  1269. 'minusdu;': '\u2a2a',
  1270. 'MinusPlus;': '\u2213',
  1271. 'mlcp;': '\u2adb',
  1272. 'mldr;': '\u2026',
  1273. 'mnplus;': '\u2213',
  1274. 'models;': '\u22a7',
  1275. 'Mopf;': '\U0001d544',
  1276. 'mopf;': '\U0001d55e',
  1277. 'mp;': '\u2213',
  1278. 'Mscr;': '\u2133',
  1279. 'mscr;': '\U0001d4c2',
  1280. 'mstpos;': '\u223e',
  1281. 'Mu;': '\u039c',
  1282. 'mu;': '\u03bc',
  1283. 'multimap;': '\u22b8',
  1284. 'mumap;': '\u22b8',
  1285. 'nabla;': '\u2207',
  1286. 'Nacute;': '\u0143',
  1287. 'nacute;': '\u0144',
  1288. 'nang;': '\u2220\u20d2',
  1289. 'nap;': '\u2249',
  1290. 'napE;': '\u2a70\u0338',
  1291. 'napid;': '\u224b\u0338',
  1292. 'napos;': '\u0149',
  1293. 'napprox;': '\u2249',
  1294. 'natur;': '\u266e',
  1295. 'natural;': '\u266e',
  1296. 'naturals;': '\u2115',
  1297. 'nbsp': '\xa0',
  1298. 'nbsp;': '\xa0',
  1299. 'nbump;': '\u224e\u0338',
  1300. 'nbumpe;': '\u224f\u0338',
  1301. 'ncap;': '\u2a43',
  1302. 'Ncaron;': '\u0147',
  1303. 'ncaron;': '\u0148',
  1304. 'Ncedil;': '\u0145',
  1305. 'ncedil;': '\u0146',
  1306. 'ncong;': '\u2247',
  1307. 'ncongdot;': '\u2a6d\u0338',
  1308. 'ncup;': '\u2a42',
  1309. 'Ncy;': '\u041d',
  1310. 'ncy;': '\u043d',
  1311. 'ndash;': '\u2013',
  1312. 'ne;': '\u2260',
  1313. 'nearhk;': '\u2924',
  1314. 'neArr;': '\u21d7',
  1315. 'nearr;': '\u2197',
  1316. 'nearrow;': '\u2197',
  1317. 'nedot;': '\u2250\u0338',
  1318. 'NegativeMediumSpace;': '\u200b',
  1319. 'NegativeThickSpace;': '\u200b',
  1320. 'NegativeThinSpace;': '\u200b',
  1321. 'NegativeVeryThinSpace;': '\u200b',
  1322. 'nequiv;': '\u2262',
  1323. 'nesear;': '\u2928',
  1324. 'nesim;': '\u2242\u0338',
  1325. 'NestedGreaterGreater;': '\u226b',
  1326. 'NestedLessLess;': '\u226a',
  1327. 'NewLine;': '\n',
  1328. 'nexist;': '\u2204',
  1329. 'nexists;': '\u2204',
  1330. 'Nfr;': '\U0001d511',
  1331. 'nfr;': '\U0001d52b',
  1332. 'ngE;': '\u2267\u0338',
  1333. 'nge;': '\u2271',
  1334. 'ngeq;': '\u2271',
  1335. 'ngeqq;': '\u2267\u0338',
  1336. 'ngeqslant;': '\u2a7e\u0338',
  1337. 'nges;': '\u2a7e\u0338',
  1338. 'nGg;': '\u22d9\u0338',
  1339. 'ngsim;': '\u2275',
  1340. 'nGt;': '\u226b\u20d2',
  1341. 'ngt;': '\u226f',
  1342. 'ngtr;': '\u226f',
  1343. 'nGtv;': '\u226b\u0338',
  1344. 'nhArr;': '\u21ce',
  1345. 'nharr;': '\u21ae',
  1346. 'nhpar;': '\u2af2',
  1347. 'ni;': '\u220b',
  1348. 'nis;': '\u22fc',
  1349. 'nisd;': '\u22fa',
  1350. 'niv;': '\u220b',
  1351. 'NJcy;': '\u040a',
  1352. 'njcy;': '\u045a',
  1353. 'nlArr;': '\u21cd',
  1354. 'nlarr;': '\u219a',
  1355. 'nldr;': '\u2025',
  1356. 'nlE;': '\u2266\u0338',
  1357. 'nle;': '\u2270',
  1358. 'nLeftarrow;': '\u21cd',
  1359. 'nleftarrow;': '\u219a',
  1360. 'nLeftrightarrow;': '\u21ce',
  1361. 'nleftrightarrow;': '\u21ae',
  1362. 'nleq;': '\u2270',
  1363. 'nleqq;': '\u2266\u0338',
  1364. 'nleqslant;': '\u2a7d\u0338',
  1365. 'nles;': '\u2a7d\u0338',
  1366. 'nless;': '\u226e',
  1367. 'nLl;': '\u22d8\u0338',
  1368. 'nlsim;': '\u2274',
  1369. 'nLt;': '\u226a\u20d2',
  1370. 'nlt;': '\u226e',
  1371. 'nltri;': '\u22ea',
  1372. 'nltrie;': '\u22ec',
  1373. 'nLtv;': '\u226a\u0338',
  1374. 'nmid;': '\u2224',
  1375. 'NoBreak;': '\u2060',
  1376. 'NonBreakingSpace;': '\xa0',
  1377. 'Nopf;': '\u2115',
  1378. 'nopf;': '\U0001d55f',
  1379. 'not': '\xac',
  1380. 'Not;': '\u2aec',
  1381. 'not;': '\xac',
  1382. 'NotCongruent;': '\u2262',
  1383. 'NotCupCap;': '\u226d',
  1384. 'NotDoubleVerticalBar;': '\u2226',
  1385. 'NotElement;': '\u2209',
  1386. 'NotEqual;': '\u2260',
  1387. 'NotEqualTilde;': '\u2242\u0338',
  1388. 'NotExists;': '\u2204',
  1389. 'NotGreater;': '\u226f',
  1390. 'NotGreaterEqual;': '\u2271',
  1391. 'NotGreaterFullEqual;': '\u2267\u0338',
  1392. 'NotGreaterGreater;': '\u226b\u0338',
  1393. 'NotGreaterLess;': '\u2279',
  1394. 'NotGreaterSlantEqual;': '\u2a7e\u0338',
  1395. 'NotGreaterTilde;': '\u2275',
  1396. 'NotHumpDownHump;': '\u224e\u0338',
  1397. 'NotHumpEqual;': '\u224f\u0338',
  1398. 'notin;': '\u2209',
  1399. 'notindot;': '\u22f5\u0338',
  1400. 'notinE;': '\u22f9\u0338',
  1401. 'notinva;': '\u2209',
  1402. 'notinvb;': '\u22f7',
  1403. 'notinvc;': '\u22f6',
  1404. 'NotLeftTriangle;': '\u22ea',
  1405. 'NotLeftTriangleBar;': '\u29cf\u0338',
  1406. 'NotLeftTriangleEqual;': '\u22ec',
  1407. 'NotLess;': '\u226e',
  1408. 'NotLessEqual;': '\u2270',
  1409. 'NotLessGreater;': '\u2278',
  1410. 'NotLessLess;': '\u226a\u0338',
  1411. 'NotLessSlantEqual;': '\u2a7d\u0338',
  1412. 'NotLessTilde;': '\u2274',
  1413. 'NotNestedGreaterGreater;': '\u2aa2\u0338',
  1414. 'NotNestedLessLess;': '\u2aa1\u0338',
  1415. 'notni;': '\u220c',
  1416. 'notniva;': '\u220c',
  1417. 'notnivb;': '\u22fe',
  1418. 'notnivc;': '\u22fd',
  1419. 'NotPrecedes;': '\u2280',
  1420. 'NotPrecedesEqual;': '\u2aaf\u0338',
  1421. 'NotPrecedesSlantEqual;': '\u22e0',
  1422. 'NotReverseElement;': '\u220c',
  1423. 'NotRightTriangle;': '\u22eb',
  1424. 'NotRightTriangleBar;': '\u29d0\u0338',
  1425. 'NotRightTriangleEqual;': '\u22ed',
  1426. 'NotSquareSubset;': '\u228f\u0338',
  1427. 'NotSquareSubsetEqual;': '\u22e2',
  1428. 'NotSquareSuperset;': '\u2290\u0338',
  1429. 'NotSquareSupersetEqual;': '\u22e3',
  1430. 'NotSubset;': '\u2282\u20d2',
  1431. 'NotSubsetEqual;': '\u2288',
  1432. 'NotSucceeds;': '\u2281',
  1433. 'NotSucceedsEqual;': '\u2ab0\u0338',
  1434. 'NotSucceedsSlantEqual;': '\u22e1',
  1435. 'NotSucceedsTilde;': '\u227f\u0338',
  1436. 'NotSuperset;': '\u2283\u20d2',
  1437. 'NotSupersetEqual;': '\u2289',
  1438. 'NotTilde;': '\u2241',
  1439. 'NotTildeEqual;': '\u2244',
  1440. 'NotTildeFullEqual;': '\u2247',
  1441. 'NotTildeTilde;': '\u2249',
  1442. 'NotVerticalBar;': '\u2224',
  1443. 'npar;': '\u2226',
  1444. 'nparallel;': '\u2226',
  1445. 'nparsl;': '\u2afd\u20e5',
  1446. 'npart;': '\u2202\u0338',
  1447. 'npolint;': '\u2a14',
  1448. 'npr;': '\u2280',
  1449. 'nprcue;': '\u22e0',
  1450. 'npre;': '\u2aaf\u0338',
  1451. 'nprec;': '\u2280',
  1452. 'npreceq;': '\u2aaf\u0338',
  1453. 'nrArr;': '\u21cf',
  1454. 'nrarr;': '\u219b',
  1455. 'nrarrc;': '\u2933\u0338',
  1456. 'nrarrw;': '\u219d\u0338',
  1457. 'nRightarrow;': '\u21cf',
  1458. 'nrightarrow;': '\u219b',
  1459. 'nrtri;': '\u22eb',
  1460. 'nrtrie;': '\u22ed',
  1461. 'nsc;': '\u2281',
  1462. 'nsccue;': '\u22e1',
  1463. 'nsce;': '\u2ab0\u0338',
  1464. 'Nscr;': '\U0001d4a9',
  1465. 'nscr;': '\U0001d4c3',
  1466. 'nshortmid;': '\u2224',
  1467. 'nshortparallel;': '\u2226',
  1468. 'nsim;': '\u2241',
  1469. 'nsime;': '\u2244',
  1470. 'nsimeq;': '\u2244',
  1471. 'nsmid;': '\u2224',
  1472. 'nspar;': '\u2226',
  1473. 'nsqsube;': '\u22e2',
  1474. 'nsqsupe;': '\u22e3',
  1475. 'nsub;': '\u2284',
  1476. 'nsubE;': '\u2ac5\u0338',
  1477. 'nsube;': '\u2288',
  1478. 'nsubset;': '\u2282\u20d2',
  1479. 'nsubseteq;': '\u2288',
  1480. 'nsubseteqq;': '\u2ac5\u0338',
  1481. 'nsucc;': '\u2281',
  1482. 'nsucceq;': '\u2ab0\u0338',
  1483. 'nsup;': '\u2285',
  1484. 'nsupE;': '\u2ac6\u0338',
  1485. 'nsupe;': '\u2289',
  1486. 'nsupset;': '\u2283\u20d2',
  1487. 'nsupseteq;': '\u2289',
  1488. 'nsupseteqq;': '\u2ac6\u0338',
  1489. 'ntgl;': '\u2279',
  1490. 'Ntilde': '\xd1',
  1491. 'ntilde': '\xf1',
  1492. 'Ntilde;': '\xd1',
  1493. 'ntilde;': '\xf1',
  1494. 'ntlg;': '\u2278',
  1495. 'ntriangleleft;': '\u22ea',
  1496. 'ntrianglelefteq;': '\u22ec',
  1497. 'ntriangleright;': '\u22eb',
  1498. 'ntrianglerighteq;': '\u22ed',
  1499. 'Nu;': '\u039d',
  1500. 'nu;': '\u03bd',
  1501. 'num;': '#',
  1502. 'numero;': '\u2116',
  1503. 'numsp;': '\u2007',
  1504. 'nvap;': '\u224d\u20d2',
  1505. 'nVDash;': '\u22af',
  1506. 'nVdash;': '\u22ae',
  1507. 'nvDash;': '\u22ad',
  1508. 'nvdash;': '\u22ac',
  1509. 'nvge;': '\u2265\u20d2',
  1510. 'nvgt;': '>\u20d2',
  1511. 'nvHarr;': '\u2904',
  1512. 'nvinfin;': '\u29de',
  1513. 'nvlArr;': '\u2902',
  1514. 'nvle;': '\u2264\u20d2',
  1515. 'nvlt;': '<\u20d2',
  1516. 'nvltrie;': '\u22b4\u20d2',
  1517. 'nvrArr;': '\u2903',
  1518. 'nvrtrie;': '\u22b5\u20d2',
  1519. 'nvsim;': '\u223c\u20d2',
  1520. 'nwarhk;': '\u2923',
  1521. 'nwArr;': '\u21d6',
  1522. 'nwarr;': '\u2196',
  1523. 'nwarrow;': '\u2196',
  1524. 'nwnear;': '\u2927',
  1525. 'Oacute': '\xd3',
  1526. 'oacute': '\xf3',
  1527. 'Oacute;': '\xd3',
  1528. 'oacute;': '\xf3',
  1529. 'oast;': '\u229b',
  1530. 'ocir;': '\u229a',
  1531. 'Ocirc': '\xd4',
  1532. 'ocirc': '\xf4',
  1533. 'Ocirc;': '\xd4',
  1534. 'ocirc;': '\xf4',
  1535. 'Ocy;': '\u041e',
  1536. 'ocy;': '\u043e',
  1537. 'odash;': '\u229d',
  1538. 'Odblac;': '\u0150',
  1539. 'odblac;': '\u0151',
  1540. 'odiv;': '\u2a38',
  1541. 'odot;': '\u2299',
  1542. 'odsold;': '\u29bc',
  1543. 'OElig;': '\u0152',
  1544. 'oelig;': '\u0153',
  1545. 'ofcir;': '\u29bf',
  1546. 'Ofr;': '\U0001d512',
  1547. 'ofr;': '\U0001d52c',
  1548. 'ogon;': '\u02db',
  1549. 'Ograve': '\xd2',
  1550. 'ograve': '\xf2',
  1551. 'Ograve;': '\xd2',
  1552. 'ograve;': '\xf2',
  1553. 'ogt;': '\u29c1',
  1554. 'ohbar;': '\u29b5',
  1555. 'ohm;': '\u03a9',
  1556. 'oint;': '\u222e',
  1557. 'olarr;': '\u21ba',
  1558. 'olcir;': '\u29be',
  1559. 'olcross;': '\u29bb',
  1560. 'oline;': '\u203e',
  1561. 'olt;': '\u29c0',
  1562. 'Omacr;': '\u014c',
  1563. 'omacr;': '\u014d',
  1564. 'Omega;': '\u03a9',
  1565. 'omega;': '\u03c9',
  1566. 'Omicron;': '\u039f',
  1567. 'omicron;': '\u03bf',
  1568. 'omid;': '\u29b6',
  1569. 'ominus;': '\u2296',
  1570. 'Oopf;': '\U0001d546',
  1571. 'oopf;': '\U0001d560',
  1572. 'opar;': '\u29b7',
  1573. 'OpenCurlyDoubleQuote;': '\u201c',
  1574. 'OpenCurlyQuote;': '\u2018',
  1575. 'operp;': '\u29b9',
  1576. 'oplus;': '\u2295',
  1577. 'Or;': '\u2a54',
  1578. 'or;': '\u2228',
  1579. 'orarr;': '\u21bb',
  1580. 'ord;': '\u2a5d',
  1581. 'order;': '\u2134',
  1582. 'orderof;': '\u2134',
  1583. 'ordf': '\xaa',
  1584. 'ordf;': '\xaa',
  1585. 'ordm': '\xba',
  1586. 'ordm;': '\xba',
  1587. 'origof;': '\u22b6',
  1588. 'oror;': '\u2a56',
  1589. 'orslope;': '\u2a57',
  1590. 'orv;': '\u2a5b',
  1591. 'oS;': '\u24c8',
  1592. 'Oscr;': '\U0001d4aa',
  1593. 'oscr;': '\u2134',
  1594. 'Oslash': '\xd8',
  1595. 'oslash': '\xf8',
  1596. 'Oslash;': '\xd8',
  1597. 'oslash;': '\xf8',
  1598. 'osol;': '\u2298',
  1599. 'Otilde': '\xd5',
  1600. 'otilde': '\xf5',
  1601. 'Otilde;': '\xd5',
  1602. 'otilde;': '\xf5',
  1603. 'Otimes;': '\u2a37',
  1604. 'otimes;': '\u2297',
  1605. 'otimesas;': '\u2a36',
  1606. 'Ouml': '\xd6',
  1607. 'ouml': '\xf6',
  1608. 'Ouml;': '\xd6',
  1609. 'ouml;': '\xf6',
  1610. 'ovbar;': '\u233d',
  1611. 'OverBar;': '\u203e',
  1612. 'OverBrace;': '\u23de',
  1613. 'OverBracket;': '\u23b4',
  1614. 'OverParenthesis;': '\u23dc',
  1615. 'par;': '\u2225',
  1616. 'para': '\xb6',
  1617. 'para;': '\xb6',
  1618. 'parallel;': '\u2225',
  1619. 'parsim;': '\u2af3',
  1620. 'parsl;': '\u2afd',
  1621. 'part;': '\u2202',
  1622. 'PartialD;': '\u2202',
  1623. 'Pcy;': '\u041f',
  1624. 'pcy;': '\u043f',
  1625. 'percnt;': '%',
  1626. 'period;': '.',
  1627. 'permil;': '\u2030',
  1628. 'perp;': '\u22a5',
  1629. 'pertenk;': '\u2031',
  1630. 'Pfr;': '\U0001d513',
  1631. 'pfr;': '\U0001d52d',
  1632. 'Phi;': '\u03a6',
  1633. 'phi;': '\u03c6',
  1634. 'phiv;': '\u03d5',
  1635. 'phmmat;': '\u2133',
  1636. 'phone;': '\u260e',
  1637. 'Pi;': '\u03a0',
  1638. 'pi;': '\u03c0',
  1639. 'pitchfork;': '\u22d4',
  1640. 'piv;': '\u03d6',
  1641. 'planck;': '\u210f',
  1642. 'planckh;': '\u210e',
  1643. 'plankv;': '\u210f',
  1644. 'plus;': '+',
  1645. 'plusacir;': '\u2a23',
  1646. 'plusb;': '\u229e',
  1647. 'pluscir;': '\u2a22',
  1648. 'plusdo;': '\u2214',
  1649. 'plusdu;': '\u2a25',
  1650. 'pluse;': '\u2a72',
  1651. 'PlusMinus;': '\xb1',
  1652. 'plusmn': '\xb1',
  1653. 'plusmn;': '\xb1',
  1654. 'plussim;': '\u2a26',
  1655. 'plustwo;': '\u2a27',
  1656. 'pm;': '\xb1',
  1657. 'Poincareplane;': '\u210c',
  1658. 'pointint;': '\u2a15',
  1659. 'Popf;': '\u2119',
  1660. 'popf;': '\U0001d561',
  1661. 'pound': '\xa3',
  1662. 'pound;': '\xa3',
  1663. 'Pr;': '\u2abb',
  1664. 'pr;': '\u227a',
  1665. 'prap;': '\u2ab7',
  1666. 'prcue;': '\u227c',
  1667. 'prE;': '\u2ab3',
  1668. 'pre;': '\u2aaf',
  1669. 'prec;': '\u227a',
  1670. 'precapprox;': '\u2ab7',
  1671. 'preccurlyeq;': '\u227c',
  1672. 'Precedes;': '\u227a',
  1673. 'PrecedesEqual;': '\u2aaf',
  1674. 'PrecedesSlantEqual;': '\u227c',
  1675. 'PrecedesTilde;': '\u227e',
  1676. 'preceq;': '\u2aaf',
  1677. 'precnapprox;': '\u2ab9',
  1678. 'precneqq;': '\u2ab5',
  1679. 'precnsim;': '\u22e8',
  1680. 'precsim;': '\u227e',
  1681. 'Prime;': '\u2033',
  1682. 'prime;': '\u2032',
  1683. 'primes;': '\u2119',
  1684. 'prnap;': '\u2ab9',
  1685. 'prnE;': '\u2ab5',
  1686. 'prnsim;': '\u22e8',
  1687. 'prod;': '\u220f',
  1688. 'Product;': '\u220f',
  1689. 'profalar;': '\u232e',
  1690. 'profline;': '\u2312',
  1691. 'profsurf;': '\u2313',
  1692. 'prop;': '\u221d',
  1693. 'Proportion;': '\u2237',
  1694. 'Proportional;': '\u221d',
  1695. 'propto;': '\u221d',
  1696. 'prsim;': '\u227e',
  1697. 'prurel;': '\u22b0',
  1698. 'Pscr;': '\U0001d4ab',
  1699. 'pscr;': '\U0001d4c5',
  1700. 'Psi;': '\u03a8',
  1701. 'psi;': '\u03c8',
  1702. 'puncsp;': '\u2008',
  1703. 'Qfr;': '\U0001d514',
  1704. 'qfr;': '\U0001d52e',
  1705. 'qint;': '\u2a0c',
  1706. 'Qopf;': '\u211a',
  1707. 'qopf;': '\U0001d562',
  1708. 'qprime;': '\u2057',
  1709. 'Qscr;': '\U0001d4ac',
  1710. 'qscr;': '\U0001d4c6',
  1711. 'quaternions;': '\u210d',
  1712. 'quatint;': '\u2a16',
  1713. 'quest;': '?',
  1714. 'questeq;': '\u225f',
  1715. 'QUOT': '"',
  1716. 'quot': '"',
  1717. 'QUOT;': '"',
  1718. 'quot;': '"',
  1719. 'rAarr;': '\u21db',
  1720. 'race;': '\u223d\u0331',
  1721. 'Racute;': '\u0154',
  1722. 'racute;': '\u0155',
  1723. 'radic;': '\u221a',
  1724. 'raemptyv;': '\u29b3',
  1725. 'Rang;': '\u27eb',
  1726. 'rang;': '\u27e9',
  1727. 'rangd;': '\u2992',
  1728. 'range;': '\u29a5',
  1729. 'rangle;': '\u27e9',
  1730. 'raquo': '\xbb',
  1731. 'raquo;': '\xbb',
  1732. 'Rarr;': '\u21a0',
  1733. 'rArr;': '\u21d2',
  1734. 'rarr;': '\u2192',
  1735. 'rarrap;': '\u2975',
  1736. 'rarrb;': '\u21e5',
  1737. 'rarrbfs;': '\u2920',
  1738. 'rarrc;': '\u2933',
  1739. 'rarrfs;': '\u291e',
  1740. 'rarrhk;': '\u21aa',
  1741. 'rarrlp;': '\u21ac',
  1742. 'rarrpl;': '\u2945',
  1743. 'rarrsim;': '\u2974',
  1744. 'Rarrtl;': '\u2916',
  1745. 'rarrtl;': '\u21a3',
  1746. 'rarrw;': '\u219d',
  1747. 'rAtail;': '\u291c',
  1748. 'ratail;': '\u291a',
  1749. 'ratio;': '\u2236',
  1750. 'rationals;': '\u211a',
  1751. 'RBarr;': '\u2910',
  1752. 'rBarr;': '\u290f',
  1753. 'rbarr;': '\u290d',
  1754. 'rbbrk;': '\u2773',
  1755. 'rbrace;': '}',
  1756. 'rbrack;': ']',
  1757. 'rbrke;': '\u298c',
  1758. 'rbrksld;': '\u298e',
  1759. 'rbrkslu;': '\u2990',
  1760. 'Rcaron;': '\u0158',
  1761. 'rcaron;': '\u0159',
  1762. 'Rcedil;': '\u0156',
  1763. 'rcedil;': '\u0157',
  1764. 'rceil;': '\u2309',
  1765. 'rcub;': '}',
  1766. 'Rcy;': '\u0420',
  1767. 'rcy;': '\u0440',
  1768. 'rdca;': '\u2937',
  1769. 'rdldhar;': '\u2969',
  1770. 'rdquo;': '\u201d',
  1771. 'rdquor;': '\u201d',
  1772. 'rdsh;': '\u21b3',
  1773. 'Re;': '\u211c',
  1774. 'real;': '\u211c',
  1775. 'realine;': '\u211b',
  1776. 'realpart;': '\u211c',
  1777. 'reals;': '\u211d',
  1778. 'rect;': '\u25ad',
  1779. 'REG': '\xae',
  1780. 'reg': '\xae',
  1781. 'REG;': '\xae',
  1782. 'reg;': '\xae',
  1783. 'ReverseElement;': '\u220b',
  1784. 'ReverseEquilibrium;': '\u21cb',
  1785. 'ReverseUpEquilibrium;': '\u296f',
  1786. 'rfisht;': '\u297d',
  1787. 'rfloor;': '\u230b',
  1788. 'Rfr;': '\u211c',
  1789. 'rfr;': '\U0001d52f',
  1790. 'rHar;': '\u2964',
  1791. 'rhard;': '\u21c1',
  1792. 'rharu;': '\u21c0',
  1793. 'rharul;': '\u296c',
  1794. 'Rho;': '\u03a1',
  1795. 'rho;': '\u03c1',
  1796. 'rhov;': '\u03f1',
  1797. 'RightAngleBracket;': '\u27e9',
  1798. 'RightArrow;': '\u2192',
  1799. 'Rightarrow;': '\u21d2',
  1800. 'rightarrow;': '\u2192',
  1801. 'RightArrowBar;': '\u21e5',
  1802. 'RightArrowLeftArrow;': '\u21c4',
  1803. 'rightarrowtail;': '\u21a3',
  1804. 'RightCeiling;': '\u2309',
  1805. 'RightDoubleBracket;': '\u27e7',
  1806. 'RightDownTeeVector;': '\u295d',
  1807. 'RightDownVector;': '\u21c2',
  1808. 'RightDownVectorBar;': '\u2955',
  1809. 'RightFloor;': '\u230b',
  1810. 'rightharpoondown;': '\u21c1',
  1811. 'rightharpoonup;': '\u21c0',
  1812. 'rightleftarrows;': '\u21c4',
  1813. 'rightleftharpoons;': '\u21cc',
  1814. 'rightrightarrows;': '\u21c9',
  1815. 'rightsquigarrow;': '\u219d',
  1816. 'RightTee;': '\u22a2',
  1817. 'RightTeeArrow;': '\u21a6',
  1818. 'RightTeeVector;': '\u295b',
  1819. 'rightthreetimes;': '\u22cc',
  1820. 'RightTriangle;': '\u22b3',
  1821. 'RightTriangleBar;': '\u29d0',
  1822. 'RightTriangleEqual;': '\u22b5',
  1823. 'RightUpDownVector;': '\u294f',
  1824. 'RightUpTeeVector;': '\u295c',
  1825. 'RightUpVector;': '\u21be',
  1826. 'RightUpVectorBar;': '\u2954',
  1827. 'RightVector;': '\u21c0',
  1828. 'RightVectorBar;': '\u2953',
  1829. 'ring;': '\u02da',
  1830. 'risingdotseq;': '\u2253',
  1831. 'rlarr;': '\u21c4',
  1832. 'rlhar;': '\u21cc',
  1833. 'rlm;': '\u200f',
  1834. 'rmoust;': '\u23b1',
  1835. 'rmoustache;': '\u23b1',
  1836. 'rnmid;': '\u2aee',
  1837. 'roang;': '\u27ed',
  1838. 'roarr;': '\u21fe',
  1839. 'robrk;': '\u27e7',
  1840. 'ropar;': '\u2986',
  1841. 'Ropf;': '\u211d',
  1842. 'ropf;': '\U0001d563',
  1843. 'roplus;': '\u2a2e',
  1844. 'rotimes;': '\u2a35',
  1845. 'RoundImplies;': '\u2970',
  1846. 'rpar;': ')',
  1847. 'rpargt;': '\u2994',
  1848. 'rppolint;': '\u2a12',
  1849. 'rrarr;': '\u21c9',
  1850. 'Rrightarrow;': '\u21db',
  1851. 'rsaquo;': '\u203a',
  1852. 'Rscr;': '\u211b',
  1853. 'rscr;': '\U0001d4c7',
  1854. 'Rsh;': '\u21b1',
  1855. 'rsh;': '\u21b1',
  1856. 'rsqb;': ']',
  1857. 'rsquo;': '\u2019',
  1858. 'rsquor;': '\u2019',
  1859. 'rthree;': '\u22cc',
  1860. 'rtimes;': '\u22ca',
  1861. 'rtri;': '\u25b9',
  1862. 'rtrie;': '\u22b5',
  1863. 'rtrif;': '\u25b8',
  1864. 'rtriltri;': '\u29ce',
  1865. 'RuleDelayed;': '\u29f4',
  1866. 'ruluhar;': '\u2968',
  1867. 'rx;': '\u211e',
  1868. 'Sacute;': '\u015a',
  1869. 'sacute;': '\u015b',
  1870. 'sbquo;': '\u201a',
  1871. 'Sc;': '\u2abc',
  1872. 'sc;': '\u227b',
  1873. 'scap;': '\u2ab8',
  1874. 'Scaron;': '\u0160',
  1875. 'scaron;': '\u0161',
  1876. 'sccue;': '\u227d',
  1877. 'scE;': '\u2ab4',
  1878. 'sce;': '\u2ab0',
  1879. 'Scedil;': '\u015e',
  1880. 'scedil;': '\u015f',
  1881. 'Scirc;': '\u015c',
  1882. 'scirc;': '\u015d',
  1883. 'scnap;': '\u2aba',
  1884. 'scnE;': '\u2ab6',
  1885. 'scnsim;': '\u22e9',
  1886. 'scpolint;': '\u2a13',
  1887. 'scsim;': '\u227f',
  1888. 'Scy;': '\u0421',
  1889. 'scy;': '\u0441',
  1890. 'sdot;': '\u22c5',
  1891. 'sdotb;': '\u22a1',
  1892. 'sdote;': '\u2a66',
  1893. 'searhk;': '\u2925',
  1894. 'seArr;': '\u21d8',
  1895. 'searr;': '\u2198',
  1896. 'searrow;': '\u2198',
  1897. 'sect': '\xa7',
  1898. 'sect;': '\xa7',
  1899. 'semi;': ';',
  1900. 'seswar;': '\u2929',
  1901. 'setminus;': '\u2216',
  1902. 'setmn;': '\u2216',
  1903. 'sext;': '\u2736',
  1904. 'Sfr;': '\U0001d516',
  1905. 'sfr;': '\U0001d530',
  1906. 'sfrown;': '\u2322',
  1907. 'sharp;': '\u266f',
  1908. 'SHCHcy;': '\u0429',
  1909. 'shchcy;': '\u0449',
  1910. 'SHcy;': '\u0428',
  1911. 'shcy;': '\u0448',
  1912. 'ShortDownArrow;': '\u2193',
  1913. 'ShortLeftArrow;': '\u2190',
  1914. 'shortmid;': '\u2223',
  1915. 'shortparallel;': '\u2225',
  1916. 'ShortRightArrow;': '\u2192',
  1917. 'ShortUpArrow;': '\u2191',
  1918. 'shy': '\xad',
  1919. 'shy;': '\xad',
  1920. 'Sigma;': '\u03a3',
  1921. 'sigma;': '\u03c3',
  1922. 'sigmaf;': '\u03c2',
  1923. 'sigmav;': '\u03c2',
  1924. 'sim;': '\u223c',
  1925. 'simdot;': '\u2a6a',
  1926. 'sime;': '\u2243',
  1927. 'simeq;': '\u2243',
  1928. 'simg;': '\u2a9e',
  1929. 'simgE;': '\u2aa0',
  1930. 'siml;': '\u2a9d',
  1931. 'simlE;': '\u2a9f',
  1932. 'simne;': '\u2246',
  1933. 'simplus;': '\u2a24',
  1934. 'simrarr;': '\u2972',
  1935. 'slarr;': '\u2190',
  1936. 'SmallCircle;': '\u2218',
  1937. 'smallsetminus;': '\u2216',
  1938. 'smashp;': '\u2a33',
  1939. 'smeparsl;': '\u29e4',
  1940. 'smid;': '\u2223',
  1941. 'smile;': '\u2323',
  1942. 'smt;': '\u2aaa',
  1943. 'smte;': '\u2aac',
  1944. 'smtes;': '\u2aac\ufe00',
  1945. 'SOFTcy;': '\u042c',
  1946. 'softcy;': '\u044c',
  1947. 'sol;': '/',
  1948. 'solb;': '\u29c4',
  1949. 'solbar;': '\u233f',
  1950. 'Sopf;': '\U0001d54a',
  1951. 'sopf;': '\U0001d564',
  1952. 'spades;': '\u2660',
  1953. 'spadesuit;': '\u2660',
  1954. 'spar;': '\u2225',
  1955. 'sqcap;': '\u2293',
  1956. 'sqcaps;': '\u2293\ufe00',
  1957. 'sqcup;': '\u2294',
  1958. 'sqcups;': '\u2294\ufe00',
  1959. 'Sqrt;': '\u221a',
  1960. 'sqsub;': '\u228f',
  1961. 'sqsube;': '\u2291',
  1962. 'sqsubset;': '\u228f',
  1963. 'sqsubseteq;': '\u2291',
  1964. 'sqsup;': '\u2290',
  1965. 'sqsupe;': '\u2292',
  1966. 'sqsupset;': '\u2290',
  1967. 'sqsupseteq;': '\u2292',
  1968. 'squ;': '\u25a1',
  1969. 'Square;': '\u25a1',
  1970. 'square;': '\u25a1',
  1971. 'SquareIntersection;': '\u2293',
  1972. 'SquareSubset;': '\u228f',
  1973. 'SquareSubsetEqual;': '\u2291',
  1974. 'SquareSuperset;': '\u2290',
  1975. 'SquareSupersetEqual;': '\u2292',
  1976. 'SquareUnion;': '\u2294',
  1977. 'squarf;': '\u25aa',
  1978. 'squf;': '\u25aa',
  1979. 'srarr;': '\u2192',
  1980. 'Sscr;': '\U0001d4ae',
  1981. 'sscr;': '\U0001d4c8',
  1982. 'ssetmn;': '\u2216',
  1983. 'ssmile;': '\u2323',
  1984. 'sstarf;': '\u22c6',
  1985. 'Star;': '\u22c6',
  1986. 'star;': '\u2606',
  1987. 'starf;': '\u2605',
  1988. 'straightepsilon;': '\u03f5',
  1989. 'straightphi;': '\u03d5',
  1990. 'strns;': '\xaf',
  1991. 'Sub;': '\u22d0',
  1992. 'sub;': '\u2282',
  1993. 'subdot;': '\u2abd',
  1994. 'subE;': '\u2ac5',
  1995. 'sube;': '\u2286',
  1996. 'subedot;': '\u2ac3',
  1997. 'submult;': '\u2ac1',
  1998. 'subnE;': '\u2acb',
  1999. 'subne;': '\u228a',
  2000. 'subplus;': '\u2abf',
  2001. 'subrarr;': '\u2979',
  2002. 'Subset;': '\u22d0',
  2003. 'subset;': '\u2282',
  2004. 'subseteq;': '\u2286',
  2005. 'subseteqq;': '\u2ac5',
  2006. 'SubsetEqual;': '\u2286',
  2007. 'subsetneq;': '\u228a',
  2008. 'subsetneqq;': '\u2acb',
  2009. 'subsim;': '\u2ac7',
  2010. 'subsub;': '\u2ad5',
  2011. 'subsup;': '\u2ad3',
  2012. 'succ;': '\u227b',
  2013. 'succapprox;': '\u2ab8',
  2014. 'succcurlyeq;': '\u227d',
  2015. 'Succeeds;': '\u227b',
  2016. 'SucceedsEqual;': '\u2ab0',
  2017. 'SucceedsSlantEqual;': '\u227d',
  2018. 'SucceedsTilde;': '\u227f',
  2019. 'succeq;': '\u2ab0',
  2020. 'succnapprox;': '\u2aba',
  2021. 'succneqq;': '\u2ab6',
  2022. 'succnsim;': '\u22e9',
  2023. 'succsim;': '\u227f',
  2024. 'SuchThat;': '\u220b',
  2025. 'Sum;': '\u2211',
  2026. 'sum;': '\u2211',
  2027. 'sung;': '\u266a',
  2028. 'sup1': '\xb9',
  2029. 'sup1;': '\xb9',
  2030. 'sup2': '\xb2',
  2031. 'sup2;': '\xb2',
  2032. 'sup3': '\xb3',
  2033. 'sup3;': '\xb3',
  2034. 'Sup;': '\u22d1',
  2035. 'sup;': '\u2283',
  2036. 'supdot;': '\u2abe',
  2037. 'supdsub;': '\u2ad8',
  2038. 'supE;': '\u2ac6',
  2039. 'supe;': '\u2287',
  2040. 'supedot;': '\u2ac4',
  2041. 'Superset;': '\u2283',
  2042. 'SupersetEqual;': '\u2287',
  2043. 'suphsol;': '\u27c9',
  2044. 'suphsub;': '\u2ad7',
  2045. 'suplarr;': '\u297b',
  2046. 'supmult;': '\u2ac2',
  2047. 'supnE;': '\u2acc',
  2048. 'supne;': '\u228b',
  2049. 'supplus;': '\u2ac0',
  2050. 'Supset;': '\u22d1',
  2051. 'supset;': '\u2283',
  2052. 'supseteq;': '\u2287',
  2053. 'supseteqq;': '\u2ac6',
  2054. 'supsetneq;': '\u228b',
  2055. 'supsetneqq;': '\u2acc',
  2056. 'supsim;': '\u2ac8',
  2057. 'supsub;': '\u2ad4',
  2058. 'supsup;': '\u2ad6',
  2059. 'swarhk;': '\u2926',
  2060. 'swArr;': '\u21d9',
  2061. 'swarr;': '\u2199',
  2062. 'swarrow;': '\u2199',
  2063. 'swnwar;': '\u292a',
  2064. 'szlig': '\xdf',
  2065. 'szlig;': '\xdf',
  2066. 'Tab;': '\t',
  2067. 'target;': '\u2316',
  2068. 'Tau;': '\u03a4',
  2069. 'tau;': '\u03c4',
  2070. 'tbrk;': '\u23b4',
  2071. 'Tcaron;': '\u0164',
  2072. 'tcaron;': '\u0165',
  2073. 'Tcedil;': '\u0162',
  2074. 'tcedil;': '\u0163',
  2075. 'Tcy;': '\u0422',
  2076. 'tcy;': '\u0442',
  2077. 'tdot;': '\u20db',
  2078. 'telrec;': '\u2315',
  2079. 'Tfr;': '\U0001d517',
  2080. 'tfr;': '\U0001d531',
  2081. 'there4;': '\u2234',
  2082. 'Therefore;': '\u2234',
  2083. 'therefore;': '\u2234',
  2084. 'Theta;': '\u0398',
  2085. 'theta;': '\u03b8',
  2086. 'thetasym;': '\u03d1',
  2087. 'thetav;': '\u03d1',
  2088. 'thickapprox;': '\u2248',
  2089. 'thicksim;': '\u223c',
  2090. 'ThickSpace;': '\u205f\u200a',
  2091. 'thinsp;': '\u2009',
  2092. 'ThinSpace;': '\u2009',
  2093. 'thkap;': '\u2248',
  2094. 'thksim;': '\u223c',
  2095. 'THORN': '\xde',
  2096. 'thorn': '\xfe',
  2097. 'THORN;': '\xde',
  2098. 'thorn;': '\xfe',
  2099. 'Tilde;': '\u223c',
  2100. 'tilde;': '\u02dc',
  2101. 'TildeEqual;': '\u2243',
  2102. 'TildeFullEqual;': '\u2245',
  2103. 'TildeTilde;': '\u2248',
  2104. 'times': '\xd7',
  2105. 'times;': '\xd7',
  2106. 'timesb;': '\u22a0',
  2107. 'timesbar;': '\u2a31',
  2108. 'timesd;': '\u2a30',
  2109. 'tint;': '\u222d',
  2110. 'toea;': '\u2928',
  2111. 'top;': '\u22a4',
  2112. 'topbot;': '\u2336',
  2113. 'topcir;': '\u2af1',
  2114. 'Topf;': '\U0001d54b',
  2115. 'topf;': '\U0001d565',
  2116. 'topfork;': '\u2ada',
  2117. 'tosa;': '\u2929',
  2118. 'tprime;': '\u2034',
  2119. 'TRADE;': '\u2122',
  2120. 'trade;': '\u2122',
  2121. 'triangle;': '\u25b5',
  2122. 'triangledown;': '\u25bf',
  2123. 'triangleleft;': '\u25c3',
  2124. 'trianglelefteq;': '\u22b4',
  2125. 'triangleq;': '\u225c',
  2126. 'triangleright;': '\u25b9',
  2127. 'trianglerighteq;': '\u22b5',
  2128. 'tridot;': '\u25ec',
  2129. 'trie;': '\u225c',
  2130. 'triminus;': '\u2a3a',
  2131. 'TripleDot;': '\u20db',
  2132. 'triplus;': '\u2a39',
  2133. 'trisb;': '\u29cd',
  2134. 'tritime;': '\u2a3b',
  2135. 'trpezium;': '\u23e2',
  2136. 'Tscr;': '\U0001d4af',
  2137. 'tscr;': '\U0001d4c9',
  2138. 'TScy;': '\u0426',
  2139. 'tscy;': '\u0446',
  2140. 'TSHcy;': '\u040b',
  2141. 'tshcy;': '\u045b',
  2142. 'Tstrok;': '\u0166',
  2143. 'tstrok;': '\u0167',
  2144. 'twixt;': '\u226c',
  2145. 'twoheadleftarrow;': '\u219e',
  2146. 'twoheadrightarrow;': '\u21a0',
  2147. 'Uacute': '\xda',
  2148. 'uacute': '\xfa',
  2149. 'Uacute;': '\xda',
  2150. 'uacute;': '\xfa',
  2151. 'Uarr;': '\u219f',
  2152. 'uArr;': '\u21d1',
  2153. 'uarr;': '\u2191',
  2154. 'Uarrocir;': '\u2949',
  2155. 'Ubrcy;': '\u040e',
  2156. 'ubrcy;': '\u045e',
  2157. 'Ubreve;': '\u016c',
  2158. 'ubreve;': '\u016d',
  2159. 'Ucirc': '\xdb',
  2160. 'ucirc': '\xfb',
  2161. 'Ucirc;': '\xdb',
  2162. 'ucirc;': '\xfb',
  2163. 'Ucy;': '\u0423',
  2164. 'ucy;': '\u0443',
  2165. 'udarr;': '\u21c5',
  2166. 'Udblac;': '\u0170',
  2167. 'udblac;': '\u0171',
  2168. 'udhar;': '\u296e',
  2169. 'ufisht;': '\u297e',
  2170. 'Ufr;': '\U0001d518',
  2171. 'ufr;': '\U0001d532',
  2172. 'Ugrave': '\xd9',
  2173. 'ugrave': '\xf9',
  2174. 'Ugrave;': '\xd9',
  2175. 'ugrave;': '\xf9',
  2176. 'uHar;': '\u2963',
  2177. 'uharl;': '\u21bf',
  2178. 'uharr;': '\u21be',
  2179. 'uhblk;': '\u2580',
  2180. 'ulcorn;': '\u231c',
  2181. 'ulcorner;': '\u231c',
  2182. 'ulcrop;': '\u230f',
  2183. 'ultri;': '\u25f8',
  2184. 'Umacr;': '\u016a',
  2185. 'umacr;': '\u016b',
  2186. 'uml': '\xa8',
  2187. 'uml;': '\xa8',
  2188. 'UnderBar;': '_',
  2189. 'UnderBrace;': '\u23df',
  2190. 'UnderBracket;': '\u23b5',
  2191. 'UnderParenthesis;': '\u23dd',
  2192. 'Union;': '\u22c3',
  2193. 'UnionPlus;': '\u228e',
  2194. 'Uogon;': '\u0172',
  2195. 'uogon;': '\u0173',
  2196. 'Uopf;': '\U0001d54c',
  2197. 'uopf;': '\U0001d566',
  2198. 'UpArrow;': '\u2191',
  2199. 'Uparrow;': '\u21d1',
  2200. 'uparrow;': '\u2191',
  2201. 'UpArrowBar;': '\u2912',
  2202. 'UpArrowDownArrow;': '\u21c5',
  2203. 'UpDownArrow;': '\u2195',
  2204. 'Updownarrow;': '\u21d5',
  2205. 'updownarrow;': '\u2195',
  2206. 'UpEquilibrium;': '\u296e',
  2207. 'upharpoonleft;': '\u21bf',
  2208. 'upharpoonright;': '\u21be',
  2209. 'uplus;': '\u228e',
  2210. 'UpperLeftArrow;': '\u2196',
  2211. 'UpperRightArrow;': '\u2197',
  2212. 'Upsi;': '\u03d2',
  2213. 'upsi;': '\u03c5',
  2214. 'upsih;': '\u03d2',
  2215. 'Upsilon;': '\u03a5',
  2216. 'upsilon;': '\u03c5',
  2217. 'UpTee;': '\u22a5',
  2218. 'UpTeeArrow;': '\u21a5',
  2219. 'upuparrows;': '\u21c8',
  2220. 'urcorn;': '\u231d',
  2221. 'urcorner;': '\u231d',
  2222. 'urcrop;': '\u230e',
  2223. 'Uring;': '\u016e',
  2224. 'uring;': '\u016f',
  2225. 'urtri;': '\u25f9',
  2226. 'Uscr;': '\U0001d4b0',
  2227. 'uscr;': '\U0001d4ca',
  2228. 'utdot;': '\u22f0',
  2229. 'Utilde;': '\u0168',
  2230. 'utilde;': '\u0169',
  2231. 'utri;': '\u25b5',
  2232. 'utrif;': '\u25b4',
  2233. 'uuarr;': '\u21c8',
  2234. 'Uuml': '\xdc',
  2235. 'uuml': '\xfc',
  2236. 'Uuml;': '\xdc',
  2237. 'uuml;': '\xfc',
  2238. 'uwangle;': '\u29a7',
  2239. 'vangrt;': '\u299c',
  2240. 'varepsilon;': '\u03f5',
  2241. 'varkappa;': '\u03f0',
  2242. 'varnothing;': '\u2205',
  2243. 'varphi;': '\u03d5',
  2244. 'varpi;': '\u03d6',
  2245. 'varpropto;': '\u221d',
  2246. 'vArr;': '\u21d5',
  2247. 'varr;': '\u2195',
  2248. 'varrho;': '\u03f1',
  2249. 'varsigma;': '\u03c2',
  2250. 'varsubsetneq;': '\u228a\ufe00',
  2251. 'varsubsetneqq;': '\u2acb\ufe00',
  2252. 'varsupsetneq;': '\u228b\ufe00',
  2253. 'varsupsetneqq;': '\u2acc\ufe00',
  2254. 'vartheta;': '\u03d1',
  2255. 'vartriangleleft;': '\u22b2',
  2256. 'vartriangleright;': '\u22b3',
  2257. 'Vbar;': '\u2aeb',
  2258. 'vBar;': '\u2ae8',
  2259. 'vBarv;': '\u2ae9',
  2260. 'Vcy;': '\u0412',
  2261. 'vcy;': '\u0432',
  2262. 'VDash;': '\u22ab',
  2263. 'Vdash;': '\u22a9',
  2264. 'vDash;': '\u22a8',
  2265. 'vdash;': '\u22a2',
  2266. 'Vdashl;': '\u2ae6',
  2267. 'Vee;': '\u22c1',
  2268. 'vee;': '\u2228',
  2269. 'veebar;': '\u22bb',
  2270. 'veeeq;': '\u225a',
  2271. 'vellip;': '\u22ee',
  2272. 'Verbar;': '\u2016',
  2273. 'verbar;': '|',
  2274. 'Vert;': '\u2016',
  2275. 'vert;': '|',
  2276. 'VerticalBar;': '\u2223',
  2277. 'VerticalLine;': '|',
  2278. 'VerticalSeparator;': '\u2758',
  2279. 'VerticalTilde;': '\u2240',
  2280. 'VeryThinSpace;': '\u200a',
  2281. 'Vfr;': '\U0001d519',
  2282. 'vfr;': '\U0001d533',
  2283. 'vltri;': '\u22b2',
  2284. 'vnsub;': '\u2282\u20d2',
  2285. 'vnsup;': '\u2283\u20d2',
  2286. 'Vopf;': '\U0001d54d',
  2287. 'vopf;': '\U0001d567',
  2288. 'vprop;': '\u221d',
  2289. 'vrtri;': '\u22b3',
  2290. 'Vscr;': '\U0001d4b1',
  2291. 'vscr;': '\U0001d4cb',
  2292. 'vsubnE;': '\u2acb\ufe00',
  2293. 'vsubne;': '\u228a\ufe00',
  2294. 'vsupnE;': '\u2acc\ufe00',
  2295. 'vsupne;': '\u228b\ufe00',
  2296. 'Vvdash;': '\u22aa',
  2297. 'vzigzag;': '\u299a',
  2298. 'Wcirc;': '\u0174',
  2299. 'wcirc;': '\u0175',
  2300. 'wedbar;': '\u2a5f',
  2301. 'Wedge;': '\u22c0',
  2302. 'wedge;': '\u2227',
  2303. 'wedgeq;': '\u2259',
  2304. 'weierp;': '\u2118',
  2305. 'Wfr;': '\U0001d51a',
  2306. 'wfr;': '\U0001d534',
  2307. 'Wopf;': '\U0001d54e',
  2308. 'wopf;': '\U0001d568',
  2309. 'wp;': '\u2118',
  2310. 'wr;': '\u2240',
  2311. 'wreath;': '\u2240',
  2312. 'Wscr;': '\U0001d4b2',
  2313. 'wscr;': '\U0001d4cc',
  2314. 'xcap;': '\u22c2',
  2315. 'xcirc;': '\u25ef',
  2316. 'xcup;': '\u22c3',
  2317. 'xdtri;': '\u25bd',
  2318. 'Xfr;': '\U0001d51b',
  2319. 'xfr;': '\U0001d535',
  2320. 'xhArr;': '\u27fa',
  2321. 'xharr;': '\u27f7',
  2322. 'Xi;': '\u039e',
  2323. 'xi;': '\u03be',
  2324. 'xlArr;': '\u27f8',
  2325. 'xlarr;': '\u27f5',
  2326. 'xmap;': '\u27fc',
  2327. 'xnis;': '\u22fb',
  2328. 'xodot;': '\u2a00',
  2329. 'Xopf;': '\U0001d54f',
  2330. 'xopf;': '\U0001d569',
  2331. 'xoplus;': '\u2a01',
  2332. 'xotime;': '\u2a02',
  2333. 'xrArr;': '\u27f9',
  2334. 'xrarr;': '\u27f6',
  2335. 'Xscr;': '\U0001d4b3',
  2336. 'xscr;': '\U0001d4cd',
  2337. 'xsqcup;': '\u2a06',
  2338. 'xuplus;': '\u2a04',
  2339. 'xutri;': '\u25b3',
  2340. 'xvee;': '\u22c1',
  2341. 'xwedge;': '\u22c0',
  2342. 'Yacute': '\xdd',
  2343. 'yacute': '\xfd',
  2344. 'Yacute;': '\xdd',
  2345. 'yacute;': '\xfd',
  2346. 'YAcy;': '\u042f',
  2347. 'yacy;': '\u044f',
  2348. 'Ycirc;': '\u0176',
  2349. 'ycirc;': '\u0177',
  2350. 'Ycy;': '\u042b',
  2351. 'ycy;': '\u044b',
  2352. 'yen': '\xa5',
  2353. 'yen;': '\xa5',
  2354. 'Yfr;': '\U0001d51c',
  2355. 'yfr;': '\U0001d536',
  2356. 'YIcy;': '\u0407',
  2357. 'yicy;': '\u0457',
  2358. 'Yopf;': '\U0001d550',
  2359. 'yopf;': '\U0001d56a',
  2360. 'Yscr;': '\U0001d4b4',
  2361. 'yscr;': '\U0001d4ce',
  2362. 'YUcy;': '\u042e',
  2363. 'yucy;': '\u044e',
  2364. 'yuml': '\xff',
  2365. 'Yuml;': '\u0178',
  2366. 'yuml;': '\xff',
  2367. 'Zacute;': '\u0179',
  2368. 'zacute;': '\u017a',
  2369. 'Zcaron;': '\u017d',
  2370. 'zcaron;': '\u017e',
  2371. 'Zcy;': '\u0417',
  2372. 'zcy;': '\u0437',
  2373. 'Zdot;': '\u017b',
  2374. 'zdot;': '\u017c',
  2375. 'zeetrf;': '\u2128',
  2376. 'ZeroWidthSpace;': '\u200b',
  2377. 'Zeta;': '\u0396',
  2378. 'zeta;': '\u03b6',
  2379. 'Zfr;': '\u2128',
  2380. 'zfr;': '\U0001d537',
  2381. 'ZHcy;': '\u0416',
  2382. 'zhcy;': '\u0436',
  2383. 'zigrarr;': '\u21dd',
  2384. 'Zopf;': '\u2124',
  2385. 'zopf;': '\U0001d56b',
  2386. 'Zscr;': '\U0001d4b5',
  2387. 'zscr;': '\U0001d4cf',
  2388. 'zwj;': '\u200d',
  2389. 'zwnj;': '\u200c',
  2390. }
  2391. try:
  2392. import http.client as compat_http_client
  2393. except ImportError: # Python 2
  2394. import httplib as compat_http_client
  2395. try:
  2396. compat_http_client.HTTPResponse.getcode
  2397. except AttributeError:
  2398. # Py < 3.1
  2399. compat_http_client.HTTPResponse.getcode = lambda self: self.status
  2400. # compat_urllib_HTTPError
  2401. try:
  2402. from urllib.error import HTTPError as compat_HTTPError
  2403. except ImportError: # Python 2
  2404. from urllib2 import HTTPError as compat_HTTPError
  2405. compat_urllib_HTTPError = compat_HTTPError
  2406. # compat_urllib_request_urlretrieve
  2407. try:
  2408. from urllib.request import urlretrieve as compat_urlretrieve
  2409. except ImportError: # Python 2
  2410. from urllib import urlretrieve as compat_urlretrieve
  2411. compat_urllib_request_urlretrieve = compat_urlretrieve
  2412. # compat_html_parser_HTMLParser, compat_html_parser_HTMLParseError
  2413. try:
  2414. from HTMLParser import (
  2415. HTMLParser as compat_HTMLParser,
  2416. HTMLParseError as compat_HTMLParseError)
  2417. except ImportError: # Python 3
  2418. from html.parser import HTMLParser as compat_HTMLParser
  2419. try:
  2420. from html.parser import HTMLParseError as compat_HTMLParseError
  2421. except ImportError: # Python >3.4
  2422. # HTMLParseError was deprecated in Python 3.3 and removed in
  2423. # Python 3.5. Introducing dummy exception for Python >3.5 for compatible
  2424. # and uniform cross-version exception handling
  2425. class compat_HTMLParseError(Exception):
  2426. pass
  2427. compat_html_parser_HTMLParser = compat_HTMLParser
  2428. compat_html_parser_HTMLParseError = compat_HTMLParseError
  2429. # compat_subprocess_get_DEVNULL
  2430. try:
  2431. _DEVNULL = subprocess.DEVNULL
  2432. compat_subprocess_get_DEVNULL = lambda: _DEVNULL
  2433. except AttributeError:
  2434. compat_subprocess_get_DEVNULL = lambda: open(os.path.devnull, 'w')
  2435. # compat_http_server
  2436. try:
  2437. import http.server as compat_http_server
  2438. except ImportError:
  2439. import BaseHTTPServer as compat_http_server
  2440. # compat_urllib_parse_unquote_to_bytes,
  2441. # compat_urllib_parse_unquote, compat_urllib_parse_unquote_plus,
  2442. # compat_urllib_parse_urlencode,
  2443. # compat_urllib_parse_parse_qs
  2444. try:
  2445. from urllib.parse import unquote_to_bytes as compat_urllib_parse_unquote_to_bytes
  2446. from urllib.parse import unquote as compat_urllib_parse_unquote
  2447. from urllib.parse import unquote_plus as compat_urllib_parse_unquote_plus
  2448. from urllib.parse import urlencode as compat_urllib_parse_urlencode
  2449. from urllib.parse import parse_qs as compat_parse_qs
  2450. except ImportError: # Python 2
  2451. _asciire = (compat_urllib_parse._asciire if hasattr(compat_urllib_parse, '_asciire')
  2452. else re.compile(r'([\x00-\x7f]+)'))
  2453. # HACK: The following are the correct unquote_to_bytes, unquote and unquote_plus
  2454. # implementations from cpython 3.4.3's stdlib. Python 2's version
  2455. # is apparently broken (see https://github.com/ytdl-org/youtube-dl/pull/6244)
  2456. def compat_urllib_parse_unquote_to_bytes(string):
  2457. """unquote_to_bytes('abc%20def') -> b'abc def'."""
  2458. # Note: strings are encoded as UTF-8. This is only an issue if it contains
  2459. # unescaped non-ASCII characters, which URIs should not.
  2460. if not string:
  2461. # Is it a string-like object?
  2462. string.split
  2463. return b''
  2464. if isinstance(string, compat_str):
  2465. string = string.encode('utf-8')
  2466. bits = string.split(b'%')
  2467. if len(bits) == 1:
  2468. return string
  2469. res = [bits[0]]
  2470. append = res.append
  2471. for item in bits[1:]:
  2472. try:
  2473. append(compat_urllib_parse._hextochr[item[:2]])
  2474. append(item[2:])
  2475. except KeyError:
  2476. append(b'%')
  2477. append(item)
  2478. return b''.join(res)
  2479. def compat_urllib_parse_unquote(string, encoding='utf-8', errors='replace'):
  2480. """Replace %xx escapes by their single-character equivalent. The optional
  2481. encoding and errors parameters specify how to decode percent-encoded
  2482. sequences into Unicode characters, as accepted by the bytes.decode()
  2483. method.
  2484. By default, percent-encoded sequences are decoded with UTF-8, and invalid
  2485. sequences are replaced by a placeholder character.
  2486. unquote('abc%20def') -> 'abc def'.
  2487. """
  2488. if '%' not in string:
  2489. string.split
  2490. return string
  2491. if encoding is None:
  2492. encoding = 'utf-8'
  2493. if errors is None:
  2494. errors = 'replace'
  2495. bits = _asciire.split(string)
  2496. res = [bits[0]]
  2497. append = res.append
  2498. for i in range(1, len(bits), 2):
  2499. append(compat_urllib_parse_unquote_to_bytes(bits[i]).decode(encoding, errors))
  2500. append(bits[i + 1])
  2501. return ''.join(res)
  2502. def compat_urllib_parse_unquote_plus(string, encoding='utf-8', errors='replace'):
  2503. """Like unquote(), but also replace plus signs by spaces, as required for
  2504. unquoting HTML form values.
  2505. unquote_plus('%7e/abc+def') -> '~/abc def'
  2506. """
  2507. string = string.replace('+', ' ')
  2508. return compat_urllib_parse_unquote(string, encoding, errors)
  2509. # Python 2 will choke in urlencode on mixture of byte and unicode strings.
  2510. # Possible solutions are to either port it from python 3 with all
  2511. # the friends or manually ensure input query contains only byte strings.
  2512. # We will stick with latter thus recursively encoding the whole query.
  2513. def compat_urllib_parse_urlencode(query, doseq=0, encoding='utf-8'):
  2514. def encode_elem(e):
  2515. if isinstance(e, dict):
  2516. e = encode_dict(e)
  2517. elif isinstance(e, (list, tuple,)):
  2518. list_e = encode_list(e)
  2519. e = tuple(list_e) if isinstance(e, tuple) else list_e
  2520. elif isinstance(e, compat_str):
  2521. e = e.encode(encoding)
  2522. return e
  2523. def encode_dict(d):
  2524. return dict((encode_elem(k), encode_elem(v)) for k, v in d.items())
  2525. def encode_list(l):
  2526. return [encode_elem(e) for e in l]
  2527. return compat_urllib_parse._urlencode(encode_elem(query), doseq=doseq)
  2528. # HACK: The following is the correct parse_qs implementation from cpython 3's stdlib.
  2529. # Python 2's version is apparently totally broken
  2530. def _parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
  2531. encoding='utf-8', errors='replace'):
  2532. qs, _coerce_result = qs, compat_str
  2533. pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
  2534. r = []
  2535. for name_value in pairs:
  2536. if not name_value and not strict_parsing:
  2537. continue
  2538. nv = name_value.split('=', 1)
  2539. if len(nv) != 2:
  2540. if strict_parsing:
  2541. raise ValueError('bad query field: %r' % (name_value,))
  2542. # Handle case of a control-name with no equal sign
  2543. if keep_blank_values:
  2544. nv.append('')
  2545. else:
  2546. continue
  2547. if len(nv[1]) or keep_blank_values:
  2548. name = nv[0].replace('+', ' ')
  2549. name = compat_urllib_parse_unquote(
  2550. name, encoding=encoding, errors=errors)
  2551. name = _coerce_result(name)
  2552. value = nv[1].replace('+', ' ')
  2553. value = compat_urllib_parse_unquote(
  2554. value, encoding=encoding, errors=errors)
  2555. value = _coerce_result(value)
  2556. r.append((name, value))
  2557. return r
  2558. def compat_parse_qs(qs, keep_blank_values=False, strict_parsing=False,
  2559. encoding='utf-8', errors='replace'):
  2560. parsed_result = {}
  2561. pairs = _parse_qsl(qs, keep_blank_values, strict_parsing,
  2562. encoding=encoding, errors=errors)
  2563. for name, value in pairs:
  2564. if name in parsed_result:
  2565. parsed_result[name].append(value)
  2566. else:
  2567. parsed_result[name] = [value]
  2568. return parsed_result
  2569. setattr(compat_urllib_parse, '_urlencode',
  2570. getattr(compat_urllib_parse, 'urlencode'))
  2571. for name, fix in (
  2572. ('unquote_to_bytes', compat_urllib_parse_unquote_to_bytes),
  2573. ('parse_unquote', compat_urllib_parse_unquote),
  2574. ('unquote_plus', compat_urllib_parse_unquote_plus),
  2575. ('urlencode', compat_urllib_parse_urlencode),
  2576. ('parse_qs', compat_parse_qs)):
  2577. setattr(compat_urllib_parse, name, fix)
  2578. compat_urllib_parse_parse_qs = compat_parse_qs
  2579. # compat_urllib_request_DataHandler
  2580. try:
  2581. from urllib.request import DataHandler as compat_urllib_request_DataHandler
  2582. except ImportError: # Python < 3.4
  2583. # Ported from CPython 98774:1733b3bd46db, Lib/urllib/request.py
  2584. class compat_urllib_request_DataHandler(compat_urllib_request.BaseHandler):
  2585. def data_open(self, req):
  2586. # data URLs as specified in RFC 2397.
  2587. #
  2588. # ignores POSTed data
  2589. #
  2590. # syntax:
  2591. # dataurl := "data:" [ mediatype ] [ ";base64" ] "," data
  2592. # mediatype := [ type "/" subtype ] *( ";" parameter )
  2593. # data := *urlchar
  2594. # parameter := attribute "=" value
  2595. url = req.get_full_url()
  2596. scheme, data = url.split(':', 1)
  2597. mediatype, data = data.split(',', 1)
  2598. # even base64 encoded data URLs might be quoted so unquote in any case:
  2599. data = compat_urllib_parse_unquote_to_bytes(data)
  2600. if mediatype.endswith(';base64'):
  2601. data = binascii.a2b_base64(data)
  2602. mediatype = mediatype[:-7]
  2603. if not mediatype:
  2604. mediatype = 'text/plain;charset=US-ASCII'
  2605. headers = email.message_from_string(
  2606. 'Content-type: %s\nContent-length: %d\n' % (mediatype, len(data)))
  2607. return compat_urllib_response.addinfourl(io.BytesIO(data), headers, url)
  2608. # compat_xml_etree_ElementTree_ParseError
  2609. try:
  2610. from xml.etree.ElementTree import ParseError as compat_xml_parse_error
  2611. except ImportError: # Python 2.6
  2612. from xml.parsers.expat import ExpatError as compat_xml_parse_error
  2613. compat_xml_etree_ElementTree_ParseError = compat_xml_parse_error
  2614. # compat_xml_etree_ElementTree_Element
  2615. _etree = xml.etree.ElementTree
  2616. class _TreeBuilder(_etree.TreeBuilder):
  2617. def doctype(self, name, pubid, system):
  2618. pass
  2619. try:
  2620. # xml.etree.ElementTree.Element is a method in Python <=2.6 and
  2621. # the following will crash with:
  2622. # TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types
  2623. isinstance(None, _etree.Element)
  2624. from xml.etree.ElementTree import Element as compat_etree_Element
  2625. except TypeError: # Python <=2.6
  2626. from xml.etree.ElementTree import _ElementInterface as compat_etree_Element
  2627. compat_xml_etree_ElementTree_Element = compat_etree_Element
  2628. if sys.version_info[0] >= 3:
  2629. def compat_etree_fromstring(text):
  2630. return _etree.XML(text, parser=_etree.XMLParser(target=_TreeBuilder()))
  2631. else:
  2632. # python 2.x tries to encode unicode strings with ascii (see the
  2633. # XMLParser._fixtext method)
  2634. try:
  2635. _etree_iter = _etree.Element.iter
  2636. except AttributeError: # Python <=2.6
  2637. def _etree_iter(root):
  2638. for el in root.findall('*'):
  2639. yield el
  2640. for sub in _etree_iter(el):
  2641. yield sub
  2642. # on 2.6 XML doesn't have a parser argument, function copied from CPython
  2643. # 2.7 source
  2644. def _XML(text, parser=None):
  2645. if not parser:
  2646. parser = _etree.XMLParser(target=_TreeBuilder())
  2647. parser.feed(text)
  2648. return parser.close()
  2649. def _element_factory(*args, **kwargs):
  2650. el = _etree.Element(*args, **kwargs)
  2651. for k, v in el.items():
  2652. if isinstance(v, bytes):
  2653. el.set(k, v.decode('utf-8'))
  2654. return el
  2655. def compat_etree_fromstring(text):
  2656. doc = _XML(text, parser=_etree.XMLParser(target=_TreeBuilder(element_factory=_element_factory)))
  2657. for el in _etree_iter(doc):
  2658. if el.text is not None and isinstance(el.text, bytes):
  2659. el.text = el.text.decode('utf-8')
  2660. return doc
  2661. # compat_xml_etree_register_namespace
  2662. try:
  2663. compat_etree_register_namespace = _etree.register_namespace
  2664. except AttributeError:
  2665. def compat_etree_register_namespace(prefix, uri):
  2666. """Register a namespace prefix.
  2667. The registry is global, and any existing mapping for either the
  2668. given prefix or the namespace URI will be removed.
  2669. *prefix* is the namespace prefix, *uri* is a namespace uri. Tags and
  2670. attributes in this namespace will be serialized with prefix if possible.
  2671. ValueError is raised if prefix is reserved or is invalid.
  2672. """
  2673. if re.match(r'ns\d+$', prefix):
  2674. raise ValueError('Prefix format reserved for internal use')
  2675. for k, v in list(_etree._namespace_map.items()):
  2676. if k == uri or v == prefix:
  2677. del _etree._namespace_map[k]
  2678. _etree._namespace_map[uri] = prefix
  2679. compat_xml_etree_register_namespace = compat_etree_register_namespace
  2680. # compat_xpath, compat_etree_iterfind
  2681. if sys.version_info < (2, 7):
  2682. # Here comes the crazy part: In 2.6, if the xpath is a unicode,
  2683. # .//node does not match if a node is a direct child of . !
  2684. def compat_xpath(xpath):
  2685. if isinstance(xpath, compat_str):
  2686. xpath = xpath.encode('ascii')
  2687. return xpath
  2688. # further code below based on CPython 2.7 source
  2689. import functools
  2690. _xpath_tokenizer_re = re.compile(r'''(?x)
  2691. ( # (1)
  2692. '[^']*'|"[^"]*"| # quoted strings, or
  2693. ::|//?|\.\.|\(\)|[/.*:[\]()@=] # navigation specials
  2694. )| # or (2)
  2695. ((?:\{[^}]+\})?[^/[\]()@=\s]+)| # token: optional {ns}, no specials
  2696. \s+ # or white space
  2697. ''')
  2698. def _xpath_tokenizer(pattern, namespaces=None):
  2699. for token in _xpath_tokenizer_re.findall(pattern):
  2700. tag = token[1]
  2701. if tag and tag[0] != "{" and ":" in tag:
  2702. try:
  2703. if not namespaces:
  2704. raise KeyError
  2705. prefix, uri = tag.split(":", 1)
  2706. yield token[0], "{%s}%s" % (namespaces[prefix], uri)
  2707. except KeyError:
  2708. raise SyntaxError("prefix %r not found in prefix map" % prefix)
  2709. else:
  2710. yield token
  2711. def _get_parent_map(context):
  2712. parent_map = context.parent_map
  2713. if parent_map is None:
  2714. context.parent_map = parent_map = {}
  2715. for p in context.root.getiterator():
  2716. for e in p:
  2717. parent_map[e] = p
  2718. return parent_map
  2719. def _select(context, result, filter_fn=lambda *_: True):
  2720. for elem in result:
  2721. for e in elem:
  2722. if filter_fn(e, elem):
  2723. yield e
  2724. def _prepare_child(next_, token):
  2725. tag = token[1]
  2726. return functools.partial(_select, filter_fn=lambda e, _: e.tag == tag)
  2727. def _prepare_star(next_, token):
  2728. return _select
  2729. def _prepare_self(next_, token):
  2730. return lambda _, result: (e for e in result)
  2731. def _prepare_descendant(next_, token):
  2732. token = next(next_)
  2733. if token[0] == "*":
  2734. tag = "*"
  2735. elif not token[0]:
  2736. tag = token[1]
  2737. else:
  2738. raise SyntaxError("invalid descendant")
  2739. def select(context, result):
  2740. for elem in result:
  2741. for e in elem.getiterator(tag):
  2742. if e is not elem:
  2743. yield e
  2744. return select
  2745. def _prepare_parent(next_, token):
  2746. def select(context, result):
  2747. # FIXME: raise error if .. is applied at toplevel?
  2748. parent_map = _get_parent_map(context)
  2749. result_map = {}
  2750. for elem in result:
  2751. if elem in parent_map:
  2752. parent = parent_map[elem]
  2753. if parent not in result_map:
  2754. result_map[parent] = None
  2755. yield parent
  2756. return select
  2757. def _prepare_predicate(next_, token):
  2758. signature = []
  2759. predicate = []
  2760. for token in next_:
  2761. if token[0] == "]":
  2762. break
  2763. if token[0] and token[0][:1] in "'\"":
  2764. token = "'", token[0][1:-1]
  2765. signature.append(token[0] or "-")
  2766. predicate.append(token[1])
  2767. def select(context, result, filter_fn=lambda _: True):
  2768. for elem in result:
  2769. if filter_fn(elem):
  2770. yield elem
  2771. signature = "".join(signature)
  2772. # use signature to determine predicate type
  2773. if signature == "@-":
  2774. # [@attribute] predicate
  2775. key = predicate[1]
  2776. return functools.partial(
  2777. select, filter_fn=lambda el: el.get(key) is not None)
  2778. if signature == "@-='":
  2779. # [@attribute='value']
  2780. key = predicate[1]
  2781. value = predicate[-1]
  2782. return functools.partial(
  2783. select, filter_fn=lambda el: el.get(key) == value)
  2784. if signature == "-" and not re.match(r"\d+$", predicate[0]):
  2785. # [tag]
  2786. tag = predicate[0]
  2787. return functools.partial(
  2788. select, filter_fn=lambda el: el.find(tag) is not None)
  2789. if signature == "-='" and not re.match(r"\d+$", predicate[0]):
  2790. # [tag='value']
  2791. tag = predicate[0]
  2792. value = predicate[-1]
  2793. def itertext(el):
  2794. for e in el.getiterator():
  2795. e = e.text
  2796. if e:
  2797. yield e
  2798. def select(context, result):
  2799. for elem in result:
  2800. for e in elem.findall(tag):
  2801. if "".join(itertext(e)) == value:
  2802. yield elem
  2803. break
  2804. return select
  2805. if signature == "-" or signature == "-()" or signature == "-()-":
  2806. # [index] or [last()] or [last()-index]
  2807. if signature == "-":
  2808. index = int(predicate[0]) - 1
  2809. else:
  2810. if predicate[0] != "last":
  2811. raise SyntaxError("unsupported function")
  2812. if signature == "-()-":
  2813. try:
  2814. index = int(predicate[2]) - 1
  2815. except ValueError:
  2816. raise SyntaxError("unsupported expression")
  2817. else:
  2818. index = -1
  2819. def select(context, result):
  2820. parent_map = _get_parent_map(context)
  2821. for elem in result:
  2822. try:
  2823. parent = parent_map[elem]
  2824. # FIXME: what if the selector is "*" ?
  2825. elems = list(parent.findall(elem.tag))
  2826. if elems[index] is elem:
  2827. yield elem
  2828. except (IndexError, KeyError):
  2829. pass
  2830. return select
  2831. raise SyntaxError("invalid predicate")
  2832. ops = {
  2833. "": _prepare_child,
  2834. "*": _prepare_star,
  2835. ".": _prepare_self,
  2836. "..": _prepare_parent,
  2837. "//": _prepare_descendant,
  2838. "[": _prepare_predicate,
  2839. }
  2840. _cache = {}
  2841. class _SelectorContext:
  2842. parent_map = None
  2843. def __init__(self, root):
  2844. self.root = root
  2845. # Generate all matching objects.
  2846. def compat_etree_iterfind(elem, path, namespaces=None):
  2847. # compile selector pattern
  2848. if path[-1:] == "/":
  2849. path = path + "*" # implicit all (FIXME: keep this?)
  2850. try:
  2851. selector = _cache[path]
  2852. except KeyError:
  2853. if len(_cache) > 100:
  2854. _cache.clear()
  2855. if path[:1] == "/":
  2856. raise SyntaxError("cannot use absolute path on element")
  2857. tokens = _xpath_tokenizer(path, namespaces)
  2858. selector = []
  2859. for token in tokens:
  2860. if token[0] == "/":
  2861. continue
  2862. try:
  2863. selector.append(ops[token[0]](tokens, token))
  2864. except StopIteration:
  2865. raise SyntaxError("invalid path")
  2866. _cache[path] = selector
  2867. # execute selector pattern
  2868. result = [elem]
  2869. context = _SelectorContext(elem)
  2870. for select in selector:
  2871. result = select(context, result)
  2872. return result
  2873. # end of code based on CPython 2.7 source
  2874. else:
  2875. compat_etree_iterfind = lambda element, match: element.iterfind(match)
  2876. compat_xpath = _IDENTITY
  2877. # compat_os_name
  2878. compat_os_name = os._name if os.name == 'java' else os.name
  2879. # compat_shlex_quote
  2880. if compat_os_name == 'nt':
  2881. def compat_shlex_quote(s):
  2882. return s if re.match(r'^[-_\w./]+$', s) else '"%s"' % s.replace('"', '\\"')
  2883. else:
  2884. try:
  2885. from shlex import quote as compat_shlex_quote
  2886. except ImportError: # Python < 3.3
  2887. def compat_shlex_quote(s):
  2888. if re.match(r'^[-_\w./]+$', s):
  2889. return s
  2890. else:
  2891. return "'" + s.replace("'", "'\"'\"'") + "'"
  2892. # compat_shlex.split
  2893. try:
  2894. args = shlex.split('中文')
  2895. assert (isinstance(args, list)
  2896. and isinstance(args[0], compat_str)
  2897. and args[0] == '中文')
  2898. compat_shlex_split = shlex.split
  2899. except (AssertionError, UnicodeEncodeError):
  2900. # Working around shlex issue with unicode strings on some python 2
  2901. # versions (see http://bugs.python.org/issue1548891)
  2902. def compat_shlex_split(s, comments=False, posix=True):
  2903. if isinstance(s, compat_str):
  2904. s = s.encode('utf-8')
  2905. return list(map(lambda s: s.decode('utf-8'), shlex.split(s, comments, posix)))
  2906. # compat_ord
  2907. def compat_ord(c):
  2908. if isinstance(c, int):
  2909. return c
  2910. else:
  2911. return ord(c)
  2912. # compat_getenv, compat_os_path_expanduser, compat_setenv
  2913. if sys.version_info >= (3, 0):
  2914. compat_getenv = os.getenv
  2915. compat_expanduser = os.path.expanduser
  2916. def compat_setenv(key, value, env=os.environ):
  2917. env[key] = value
  2918. else:
  2919. # Environment variables should be decoded with filesystem encoding.
  2920. # Otherwise it will fail if any non-ASCII characters present (see #3854 #3217 #2918)
  2921. def compat_getenv(key, default=None):
  2922. from .utils import get_filesystem_encoding
  2923. env = os.getenv(key, default)
  2924. if env:
  2925. env = env.decode(get_filesystem_encoding())
  2926. return env
  2927. def compat_setenv(key, value, env=os.environ):
  2928. def encode(v):
  2929. from .utils import get_filesystem_encoding
  2930. return v.encode(get_filesystem_encoding()) if isinstance(v, compat_str) else v
  2931. env[encode(key)] = encode(value)
  2932. # HACK: The default implementations of os.path.expanduser from cpython do not decode
  2933. # environment variables with filesystem encoding. We will work around this by
  2934. # providing adjusted implementations.
  2935. # The following are os.path.expanduser implementations from cpython 2.7.8 stdlib
  2936. # for different platforms with correct environment variables decoding.
  2937. if compat_os_name == 'posix':
  2938. def compat_expanduser(path):
  2939. """Expand ~ and ~user constructions. If user or $HOME is unknown,
  2940. do nothing."""
  2941. if not path.startswith('~'):
  2942. return path
  2943. i = path.find('/', 1)
  2944. if i < 0:
  2945. i = len(path)
  2946. if i == 1:
  2947. if 'HOME' not in os.environ:
  2948. import pwd
  2949. userhome = pwd.getpwuid(os.getuid()).pw_dir
  2950. else:
  2951. userhome = compat_getenv('HOME')
  2952. else:
  2953. import pwd
  2954. try:
  2955. pwent = pwd.getpwnam(path[1:i])
  2956. except KeyError:
  2957. return path
  2958. userhome = pwent.pw_dir
  2959. userhome = userhome.rstrip('/')
  2960. return (userhome + path[i:]) or '/'
  2961. elif compat_os_name in ('nt', 'ce'):
  2962. def compat_expanduser(path):
  2963. """Expand ~ and ~user constructs.
  2964. If user or $HOME is unknown, do nothing."""
  2965. if path[:1] != '~':
  2966. return path
  2967. i, n = 1, len(path)
  2968. while i < n and path[i] not in '/\\':
  2969. i = i + 1
  2970. if 'HOME' in os.environ:
  2971. userhome = compat_getenv('HOME')
  2972. elif 'USERPROFILE' in os.environ:
  2973. userhome = compat_getenv('USERPROFILE')
  2974. elif 'HOMEPATH' not in os.environ:
  2975. return path
  2976. else:
  2977. try:
  2978. drive = compat_getenv('HOMEDRIVE')
  2979. except KeyError:
  2980. drive = ''
  2981. userhome = os.path.join(drive, compat_getenv('HOMEPATH'))
  2982. if i != 1: # ~user
  2983. userhome = os.path.join(os.path.dirname(userhome), path[1:i])
  2984. return userhome + path[i:]
  2985. else:
  2986. compat_expanduser = os.path.expanduser
  2987. compat_os_path_expanduser = compat_expanduser
  2988. # compat_os_makedirs
  2989. try:
  2990. os.makedirs('.', exist_ok=True)
  2991. compat_os_makedirs = os.makedirs
  2992. except TypeError: # < Py3.2
  2993. from errno import EEXIST as _errno_EEXIST
  2994. def compat_os_makedirs(name, mode=0o777, exist_ok=False):
  2995. try:
  2996. return os.makedirs(name, mode=mode)
  2997. except OSError as ose:
  2998. if not (exist_ok and ose.errno == _errno_EEXIST):
  2999. raise
  3000. # compat_os_path_realpath
  3001. if compat_os_name == 'nt' and sys.version_info < (3, 8):
  3002. # os.path.realpath on Windows does not follow symbolic links
  3003. # prior to Python 3.8 (see https://bugs.python.org/issue9949)
  3004. def compat_realpath(path):
  3005. while os.path.islink(path):
  3006. path = os.path.abspath(os.readlink(path))
  3007. return path
  3008. else:
  3009. compat_realpath = os.path.realpath
  3010. compat_os_path_realpath = compat_realpath
  3011. # compat_print
  3012. if sys.version_info < (3, 0):
  3013. def compat_print(s):
  3014. from .utils import preferredencoding
  3015. print(s.encode(preferredencoding(), 'xmlcharrefreplace'))
  3016. else:
  3017. def compat_print(s):
  3018. assert isinstance(s, compat_str)
  3019. print(s)
  3020. # compat_getpass_getpass
  3021. if sys.version_info < (3, 0) and sys.platform == 'win32':
  3022. def compat_getpass(prompt, *args, **kwargs):
  3023. if isinstance(prompt, compat_str):
  3024. from .utils import preferredencoding
  3025. prompt = prompt.encode(preferredencoding())
  3026. return getpass.getpass(prompt, *args, **kwargs)
  3027. else:
  3028. compat_getpass = getpass.getpass
  3029. compat_getpass_getpass = compat_getpass
  3030. # compat_input
  3031. try:
  3032. compat_input = raw_input
  3033. except NameError: # Python 3
  3034. compat_input = input
  3035. # compat_kwargs
  3036. # Python < 2.6.5 require kwargs to be bytes
  3037. try:
  3038. (lambda x: x)(**{'x': 0})
  3039. except TypeError:
  3040. def compat_kwargs(kwargs):
  3041. return dict((bytes(k), v) for k, v in kwargs.items())
  3042. else:
  3043. compat_kwargs = _IDENTITY
  3044. # compat_numeric_types
  3045. try:
  3046. compat_numeric_types = (int, float, long, complex)
  3047. except NameError: # Python 3
  3048. compat_numeric_types = (int, float, complex)
  3049. # compat_integer_types
  3050. try:
  3051. compat_integer_types = (int, long)
  3052. except NameError: # Python 3
  3053. compat_integer_types = (int, )
  3054. # compat_int
  3055. compat_int = compat_integer_types[-1]
  3056. # compat_socket_create_connection
  3057. if sys.version_info < (2, 7):
  3058. def compat_socket_create_connection(address, timeout, source_address=None):
  3059. host, port = address
  3060. err = None
  3061. for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
  3062. af, socktype, proto, canonname, sa = res
  3063. sock = None
  3064. try:
  3065. sock = socket.socket(af, socktype, proto)
  3066. sock.settimeout(timeout)
  3067. if source_address:
  3068. sock.bind(source_address)
  3069. sock.connect(sa)
  3070. return sock
  3071. except socket.error as _:
  3072. err = _
  3073. if sock is not None:
  3074. sock.close()
  3075. if err is not None:
  3076. raise err
  3077. else:
  3078. raise socket.error('getaddrinfo returns an empty list')
  3079. else:
  3080. compat_socket_create_connection = socket.create_connection
  3081. # compat_contextlib_suppress
  3082. try:
  3083. from contextlib import suppress as compat_contextlib_suppress
  3084. except ImportError:
  3085. class compat_contextlib_suppress(object):
  3086. _exceptions = None
  3087. def __init__(self, *exceptions):
  3088. super(compat_contextlib_suppress, self).__init__()
  3089. # TODO: [Base]ExceptionGroup (3.12+)
  3090. self._exceptions = exceptions
  3091. def __enter__(self):
  3092. return self
  3093. def __exit__(self, exc_type, exc_val, exc_tb):
  3094. return exc_type is not None and issubclass(exc_type, self._exceptions or tuple())
  3095. # subprocess.Popen context manager
  3096. # avoids leaking handles if .communicate() is not called
  3097. try:
  3098. _Popen = subprocess.Popen
  3099. # check for required context manager attributes
  3100. _Popen.__enter__ and _Popen.__exit__
  3101. compat_subprocess_Popen = _Popen
  3102. except AttributeError:
  3103. # not a context manager - make one
  3104. from contextlib import contextmanager
  3105. @contextmanager
  3106. def compat_subprocess_Popen(*args, **kwargs):
  3107. popen = None
  3108. try:
  3109. popen = _Popen(*args, **kwargs)
  3110. yield popen
  3111. finally:
  3112. if popen:
  3113. for f in (popen.stdin, popen.stdout, popen.stderr):
  3114. if f:
  3115. # repeated .close() is OK, but just in case
  3116. with compat_contextlib_suppress(EnvironmentError):
  3117. f.close()
  3118. popen.wait()
  3119. # Fix https://github.com/ytdl-org/youtube-dl/issues/4223
  3120. # See http://bugs.python.org/issue9161 for what is broken
  3121. def _workaround_optparse_bug9161():
  3122. op = optparse.OptionParser()
  3123. og = optparse.OptionGroup(op, 'foo')
  3124. try:
  3125. og.add_option('-t')
  3126. except TypeError:
  3127. real_add_option = optparse.OptionGroup.add_option
  3128. def _compat_add_option(self, *args, **kwargs):
  3129. enc = lambda v: (
  3130. v.encode('ascii', 'replace') if isinstance(v, compat_str)
  3131. else v)
  3132. bargs = [enc(a) for a in args]
  3133. bkwargs = dict(
  3134. (k, enc(v)) for k, v in kwargs.items())
  3135. return real_add_option(self, *bargs, **bkwargs)
  3136. optparse.OptionGroup.add_option = _compat_add_option
  3137. # compat_shutil_get_terminal_size
  3138. try:
  3139. from shutil import get_terminal_size as compat_get_terminal_size # Python >= 3.3
  3140. except ImportError:
  3141. _terminal_size = collections.namedtuple('terminal_size', ['columns', 'lines'])
  3142. def compat_get_terminal_size(fallback=(80, 24)):
  3143. from .utils import process_communicate_or_kill
  3144. columns = compat_getenv('COLUMNS')
  3145. if columns:
  3146. columns = int(columns)
  3147. else:
  3148. columns = None
  3149. lines = compat_getenv('LINES')
  3150. if lines:
  3151. lines = int(lines)
  3152. else:
  3153. lines = None
  3154. if columns is None or lines is None or columns <= 0 or lines <= 0:
  3155. try:
  3156. sp = subprocess.Popen(
  3157. ['stty', 'size'],
  3158. stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  3159. out, err = process_communicate_or_kill(sp)
  3160. _lines, _columns = map(int, out.split())
  3161. except Exception:
  3162. _columns, _lines = _terminal_size(*fallback)
  3163. if columns is None or columns <= 0:
  3164. columns = _columns
  3165. if lines is None or lines <= 0:
  3166. lines = _lines
  3167. return _terminal_size(columns, lines)
  3168. compat_shutil_get_terminal_size = compat_get_terminal_size
  3169. # compat_itertools_count
  3170. try:
  3171. type(itertools.count(start=0, step=1))
  3172. compat_itertools_count = itertools.count
  3173. except TypeError: # Python 2.6 lacks step
  3174. def compat_itertools_count(start=0, step=1):
  3175. while True:
  3176. yield start
  3177. start += step
  3178. # compat_tokenize_tokenize
  3179. if sys.version_info >= (3, 0):
  3180. from tokenize import tokenize as compat_tokenize_tokenize
  3181. else:
  3182. from tokenize import generate_tokens as compat_tokenize_tokenize
  3183. # compat_struct_pack, compat_struct_unpack, compat_Struct
  3184. try:
  3185. type(struct.pack('!I', 0))
  3186. except TypeError:
  3187. # In Python 2.6 and 2.7.x < 2.7.7, struct requires a bytes argument
  3188. # See https://bugs.python.org/issue19099
  3189. def compat_struct_pack(spec, *args):
  3190. if isinstance(spec, compat_str):
  3191. spec = spec.encode('ascii')
  3192. return struct.pack(spec, *args)
  3193. def compat_struct_unpack(spec, *args):
  3194. if isinstance(spec, compat_str):
  3195. spec = spec.encode('ascii')
  3196. return struct.unpack(spec, *args)
  3197. class compat_Struct(struct.Struct):
  3198. def __init__(self, fmt):
  3199. if isinstance(fmt, compat_str):
  3200. fmt = fmt.encode('ascii')
  3201. super(compat_Struct, self).__init__(fmt)
  3202. else:
  3203. compat_struct_pack = struct.pack
  3204. compat_struct_unpack = struct.unpack
  3205. if platform.python_implementation() == 'IronPython' and sys.version_info < (2, 7, 8):
  3206. class compat_Struct(struct.Struct):
  3207. def unpack(self, string):
  3208. if not isinstance(string, buffer): # noqa: F821
  3209. string = buffer(string) # noqa: F821
  3210. return super(compat_Struct, self).unpack(string)
  3211. else:
  3212. compat_Struct = struct.Struct
  3213. # builtins returning an iterator
  3214. # compat_map, compat_filter
  3215. # supposedly the same versioning as for zip below
  3216. try:
  3217. from future_builtins import map as compat_map
  3218. except ImportError:
  3219. try:
  3220. from itertools import imap as compat_map
  3221. except ImportError:
  3222. compat_map = map
  3223. try:
  3224. from future_builtins import filter as compat_filter
  3225. except ImportError:
  3226. try:
  3227. from itertools import ifilter as compat_filter
  3228. except ImportError:
  3229. compat_filter = filter
  3230. # compat_zip
  3231. try:
  3232. from future_builtins import zip as compat_zip
  3233. except ImportError: # not 2.6+ or is 3.x
  3234. try:
  3235. from itertools import izip as compat_zip # < 2.5 or 3.x
  3236. except ImportError:
  3237. compat_zip = zip
  3238. # compat_itertools_zip_longest
  3239. # method renamed between Py2/3
  3240. try:
  3241. from itertools import zip_longest as compat_itertools_zip_longest
  3242. except ImportError:
  3243. from itertools import izip_longest as compat_itertools_zip_longest
  3244. # compat_collections_chain_map
  3245. # collections.ChainMap: new class
  3246. try:
  3247. from collections import ChainMap as compat_collections_chain_map
  3248. # Py3.3's ChainMap is deficient
  3249. if sys.version_info < (3, 4):
  3250. raise ImportError
  3251. except ImportError:
  3252. # Py <= 3.3
  3253. class compat_collections_chain_map(compat_collections_abc.MutableMapping):
  3254. maps = [{}]
  3255. def __init__(self, *maps):
  3256. self.maps = list(maps) or [{}]
  3257. def __getitem__(self, k):
  3258. for m in self.maps:
  3259. if k in m:
  3260. return m[k]
  3261. raise KeyError(k)
  3262. def __setitem__(self, k, v):
  3263. self.maps[0].__setitem__(k, v)
  3264. return
  3265. def __contains__(self, k):
  3266. return any((k in m) for m in self.maps)
  3267. def __delitem(self, k):
  3268. if k in self.maps[0]:
  3269. del self.maps[0][k]
  3270. return
  3271. raise KeyError(k)
  3272. def __delitem__(self, k):
  3273. self.__delitem(k)
  3274. def __iter__(self):
  3275. return itertools.chain(*reversed(self.maps))
  3276. def __len__(self):
  3277. return len(iter(self))
  3278. # to match Py3, don't del directly
  3279. def pop(self, k, *args):
  3280. if self.__contains__(k):
  3281. off = self.__getitem__(k)
  3282. self.__delitem(k)
  3283. return off
  3284. elif len(args) > 0:
  3285. return args[0]
  3286. raise KeyError(k)
  3287. def new_child(self, m=None, **kwargs):
  3288. m = m or {}
  3289. m.update(kwargs)
  3290. # support inheritance !
  3291. return type(self)(m, *self.maps)
  3292. @property
  3293. def parents(self):
  3294. return type(self)(*(self.maps[1:]))
  3295. # compat_re_Pattern, compat_re_Match
  3296. # Pythons disagree on the type of a pattern (RegexObject, _sre.SRE_Pattern, Pattern, ...?)
  3297. compat_re_Pattern = type(re.compile(''))
  3298. # and on the type of a match
  3299. compat_re_Match = type(re.match('a', 'a'))
  3300. # compat_base64_b64decode
  3301. if sys.version_info < (3, 3):
  3302. def compat_b64decode(s, *args, **kwargs):
  3303. if isinstance(s, compat_str):
  3304. s = s.encode('ascii')
  3305. return base64.b64decode(s, *args, **kwargs)
  3306. else:
  3307. compat_b64decode = base64.b64decode
  3308. compat_base64_b64decode = compat_b64decode
  3309. # compat_ctypes_WINFUNCTYPE
  3310. if platform.python_implementation() == 'PyPy' and sys.pypy_version_info < (5, 4, 0):
  3311. # PyPy2 prior to version 5.4.0 expects byte strings as Windows function
  3312. # names, see the original PyPy issue [1] and the youtube-dl one [2].
  3313. # 1. https://bitbucket.org/pypy/pypy/issues/2360/windows-ctypescdll-typeerror-function-name
  3314. # 2. https://github.com/ytdl-org/youtube-dl/pull/4392
  3315. def compat_ctypes_WINFUNCTYPE(*args, **kwargs):
  3316. real = ctypes.WINFUNCTYPE(*args, **kwargs)
  3317. def resf(tpl, *args, **kwargs):
  3318. funcname, dll = tpl
  3319. return real((str(funcname), dll), *args, **kwargs)
  3320. return resf
  3321. else:
  3322. def compat_ctypes_WINFUNCTYPE(*args, **kwargs):
  3323. return ctypes.WINFUNCTYPE(*args, **kwargs)
  3324. # compat_open
  3325. if sys.version_info < (3, 0):
  3326. # open(file, mode='r', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True) not: opener=None
  3327. def compat_open(file_, *args, **kwargs):
  3328. if len(args) > 6 or 'opener' in kwargs:
  3329. raise ValueError('open: unsupported argument "opener"')
  3330. return io.open(file_, *args, **kwargs)
  3331. else:
  3332. compat_open = open
  3333. # compat_register_utf8
  3334. def compat_register_utf8():
  3335. if sys.platform == 'win32':
  3336. # https://github.com/ytdl-org/youtube-dl/issues/820
  3337. from codecs import register, lookup
  3338. register(
  3339. lambda name: lookup('utf-8') if name == 'cp65001' else None)
  3340. # compat_datetime_timedelta_total_seconds
  3341. try:
  3342. compat_datetime_timedelta_total_seconds = datetime.timedelta.total_seconds
  3343. except AttributeError:
  3344. # Py 2.6
  3345. def compat_datetime_timedelta_total_seconds(td):
  3346. return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
  3347. # optional decompression packages
  3348. # compat_brotli
  3349. # PyPi brotli package implements 'br' Content-Encoding
  3350. try:
  3351. import brotli as compat_brotli
  3352. except ImportError:
  3353. compat_brotli = None
  3354. # compat_ncompress
  3355. # PyPi ncompress package implements 'compress' Content-Encoding
  3356. try:
  3357. import ncompress as compat_ncompress
  3358. except ImportError:
  3359. compat_ncompress = None
  3360. # compat_zstandard
  3361. # PyPi zstandard package implements 'zstd' Content-Encoding (RFC 8878 7.2)
  3362. try:
  3363. import zstandard as compat_zstandard
  3364. except ImportError:
  3365. compat_zstandard = None
  3366. legacy = [
  3367. 'compat_HTMLParseError',
  3368. 'compat_HTMLParser',
  3369. 'compat_HTTPError',
  3370. 'compat_b64decode',
  3371. 'compat_cookiejar',
  3372. 'compat_cookiejar_Cookie',
  3373. 'compat_cookies',
  3374. 'compat_cookies_SimpleCookie',
  3375. 'compat_etree_Element',
  3376. 'compat_etree_register_namespace',
  3377. 'compat_expanduser',
  3378. 'compat_getpass',
  3379. 'compat_parse_qs',
  3380. 'compat_realpath',
  3381. 'compat_shlex_split',
  3382. 'compat_urllib_parse_parse_qs',
  3383. 'compat_urllib_parse_unquote',
  3384. 'compat_urllib_parse_unquote_plus',
  3385. 'compat_urllib_parse_unquote_to_bytes',
  3386. 'compat_urllib_parse_urlencode',
  3387. 'compat_urllib_parse_urlparse',
  3388. 'compat_urlparse',
  3389. 'compat_urlretrieve',
  3390. 'compat_xml_parse_error',
  3391. ]
  3392. __all__ = [
  3393. 'compat_Struct',
  3394. 'compat_base64_b64decode',
  3395. 'compat_basestring',
  3396. 'compat_brotli',
  3397. 'compat_casefold',
  3398. 'compat_chr',
  3399. 'compat_collections_abc',
  3400. 'compat_collections_chain_map',
  3401. 'compat_contextlib_suppress',
  3402. 'compat_ctypes_WINFUNCTYPE',
  3403. 'compat_datetime_timedelta_total_seconds',
  3404. 'compat_etree_fromstring',
  3405. 'compat_etree_iterfind',
  3406. 'compat_filter',
  3407. 'compat_get_terminal_size',
  3408. 'compat_getenv',
  3409. 'compat_getpass_getpass',
  3410. 'compat_html_entities',
  3411. 'compat_html_entities_html5',
  3412. 'compat_html_parser_HTMLParseError',
  3413. 'compat_html_parser_HTMLParser',
  3414. 'compat_http_cookiejar',
  3415. 'compat_http_cookiejar_Cookie',
  3416. 'compat_http_cookies',
  3417. 'compat_http_cookies_SimpleCookie',
  3418. 'compat_http_client',
  3419. 'compat_http_server',
  3420. 'compat_input',
  3421. 'compat_int',
  3422. 'compat_integer_types',
  3423. 'compat_itertools_count',
  3424. 'compat_itertools_zip_longest',
  3425. 'compat_kwargs',
  3426. 'compat_map',
  3427. 'compat_ncompress',
  3428. 'compat_numeric_types',
  3429. 'compat_open',
  3430. 'compat_ord',
  3431. 'compat_os_makedirs',
  3432. 'compat_os_name',
  3433. 'compat_os_path_expanduser',
  3434. 'compat_os_path_realpath',
  3435. 'compat_print',
  3436. 'compat_re_Match',
  3437. 'compat_re_Pattern',
  3438. 'compat_register_utf8',
  3439. 'compat_setenv',
  3440. 'compat_shlex_quote',
  3441. 'compat_shutil_get_terminal_size',
  3442. 'compat_socket_create_connection',
  3443. 'compat_str',
  3444. 'compat_struct_pack',
  3445. 'compat_struct_unpack',
  3446. 'compat_subprocess_get_DEVNULL',
  3447. 'compat_subprocess_Popen',
  3448. 'compat_tokenize_tokenize',
  3449. 'compat_urllib_error',
  3450. 'compat_urllib_parse',
  3451. 'compat_urllib_request',
  3452. 'compat_urllib_request_DataHandler',
  3453. 'compat_urllib_response',
  3454. 'compat_urllib_request_urlretrieve',
  3455. 'compat_urllib_HTTPError',
  3456. 'compat_xml_etree_ElementTree_Element',
  3457. 'compat_xml_etree_ElementTree_ParseError',
  3458. 'compat_xml_etree_register_namespace',
  3459. 'compat_xpath',
  3460. 'compat_zip',
  3461. 'compat_zstandard',
  3462. ]