compat.py 109 KB

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