logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

compat.py (115707B)


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